BranchMetrics / capacitor-branch-deep-links

Capacitor plugin for branch.io deep links
MIT License
32 stars 44 forks source link

Android Fatal Error - "You need to use a Theme.AppCompat theme" #57

Closed michaelbutler1998 closed 1 year ago

michaelbutler1998 commented 2 years ago

I have followed the installation instructions found here: https://help.branch.io/developers-hub/docs/capacitor for Android precisely

When trying to run the app on on an emulator in Android Studio, the app will not start (message saying the app "keeps stopping")

I'm met with the following logs:

image

Then just below is the following:

2022-03-30 09:58:21.551 8066-8066/com.aks.cardTwist E/m.aks.cardTwis: Invalid ID 0x00000000.
2022-03-30 09:58:21.554 8066-8066/com.aks.cardTwist D/AndroidRuntime: Shutting down VM
2022-03-30 09:58:21.557 8066-8066/com.aks.cardTwist E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.aks.cardTwist, PID: 8066
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.aks.cardTwist/com.aks.cardTwister.MainActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3449)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:223)
        at android.app.ActivityThread.main(ActivityThread.java:7656)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
     Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
        at androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor(AppCompatDelegateImpl.java:843)
        at androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor(AppCompatDelegateImpl.java:806)
        at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:693)
        at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:170)
        at com.getcapacitor.BridgeActivity.onCreate(BridgeActivity.java:28)
        at com.aks.cardTwister.MainActivity.onCreate(MainActivity.java:22)
        at android.app.Activity.performCreate(Activity.java:7994)
        at android.app.Activity.performCreate(Activity.java:7978)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3422)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601) 
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85) 
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) 
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        at android.os.Looper.loop(Looper.java:223) 
        at android.app.ActivityThread.main(ActivityThread.java:7656) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947) 
michaelbutler1998 commented 2 years ago

I have isolated the code causing the issue to this line:

image

Without this line, the app runs