Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: [Android] App crash on logout on Flutter 3.24.0 #118

Open
wrbl606 opened this issue Aug 12, 2024 · 1 comment
Open

fix: [Android] App crash on logout on Flutter 3.24.0 #118

wrbl606 opened this issue Aug 12, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@wrbl606
Copy link

wrbl606 commented Aug 12, 2024

Description

Since Flutter 3.24.0, the framework expects activities to be Theme.AppCompat descendants but net.openid.appauth.RedirectUriReceiverActivity isn't, causing the app to crash at logout, and preventing the user from logging out completely given the logout process cannot pass fully.

Steps To Reproduce

On Android:

  1. Successful .loginPassword(...)
  2. Attempt .logout(...)

Expected Behavior

.logout closes current user session as it did on Flutter 3.22.3 and earlier.

Additional Context

The issue is known and fixed in other, related projects: AppAuth-Android, flutter_appauth

E/AndroidRuntime(25794): java.lang.RuntimeException: Unable to start activity ComponentInfo{[REDACTED]/net.openid.appauth.RedirectUriReceiverActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
E/AndroidRuntime(25794): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4164)
E/AndroidRuntime(25794): 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4322)
E/AndroidRuntime(25794): 	at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
E/AndroidRuntime(25794): 	at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:139)
E/AndroidRuntime(25794): 	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:96)
E/AndroidRuntime(25794): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2685)
E/AndroidRuntime(25794): 	at android.os.Handler.dispatchMessage(Handler.java:106)
E/AndroidRuntime(25794): 	at android.os.Looper.loopOnce(Looper.java:230)
E/AndroidRuntime(25794): 	at android.os.Looper.loop(Looper.java:319)
E/AndroidRuntime(25794): 	at android.app.ActivityThread.main(ActivityThread.java:8934)
E/AndroidRuntime(25794): 	at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(25794): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:578)
E/AndroidRuntime(25794): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)
E/AndroidRuntime(25794): Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
E/AndroidRuntime(25794): 	at androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor(AppCompatDelegateImpl.java:846)
E/AndroidRuntime(25794): 	at androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor(AppCompatDelegateImpl.java:809)
E/AndroidRuntime(25794): 	at androidx.appcompat.app.AppCompatDelegateImpl.initWindowDecorActionBar(AppCompatDelegateImpl.java:550)
E/AndroidRuntime(25794): 	at androidx.appcompat.app.AppCompatDelegateImpl.getSupportActionBar(AppCompatDelegateImpl.java:537)
E/AndroidRuntime(25794): 	at androidx.appcompat.app.AppCompatDelegateImpl.invalidateOptionsMenu(AppCompatDelegateImpl.java:1220)
E/AndroidRuntime(25794): 	at androidx.appcompat.app.AppCompatActivity.invalidateOptionsMenu(AppCompatActivity.java:314)
E/AndroidRuntime(25794): 	at androidx.activity.ComponentActivity.invalidateMenu(ComponentActivity.java:567)
E/AndroidRuntime(25794): 	at androidx.activity.ComponentActivity$$ExternalSyntheticLambda0.run(Unknown Source:2)
E/AndroidRuntime(25794): 	at androidx.core.view.MenuHostHelper.addMenuProvider(MenuHostHelper.java:133)
E/AndroidRuntime(25794): 	at androidx.activity.ComponentActivity.addMenuProvider(ComponentActivity.java:545)
E/AndroidRuntime(25794): 	at androidx.fragment.app.FragmentActivity$HostCallbacks.addMenuProvider(FragmentActivity.java:735)
E/AndroidRuntime(25794): 	at androidx.fragment.app.FragmentManager.attachController(FragmentManager.java:3014)
E/AndroidRuntime(25794): 	at androidx.fragment.app.FragmentController.attachHost(FragmentController.java:117)
E/AndroidRuntime(25794): 	at androidx.fragment.app.FragmentActivity.lambda$init$3$androidx-fragment-app-FragmentActivity(FragmentActivity.java:139)
E/AndroidRuntime(25794): 	at androidx.fragment.app.FragmentActivity$$ExternalSyntheticLambda3.onContextAvailable(Unknown Source:2)
E/AndroidRuntime(25794): 	at androidx.activity.contextaware.ContextAwareHelper.dispatchOnContextAvailable(ContextAwareHelper.kt:84)
E/AndroidRuntime(25794): 	at androidx.activity.ComponentActivity.onCreate(ComponentActivity.java:358)
E/AndroidRuntime(25794): 	at androidx.fragment.app.FragmentActivity.onCreate(FragmentActivity.java:216)
E/AndroidRuntime(25794): 	at net.openid.appauth.RedirectUriReceiverActivity.onCreate(RedirectUriReceiverActivity.java:49)
E/AndroidRuntime(25794): 	at android.app.Activity.performCreate(Activity.java:8995)
E/AndroidRuntime(25794): 	at android.app.Activity.performCreate(Activity.java:8964)
E/AndroidRuntime(25794): 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1456)
E/AndroidRuntime(25794): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4146)
E/AndroidRuntime(25794): 	... 12 more
@wrbl606 wrbl606 added the bug Something isn't working label Aug 12, 2024
@wrbl606
Copy link
Author

wrbl606 commented Aug 12, 2024

Here's a fix for those using manifestPlaceholders in build.gradle:

Add this to your main AndroidManifest.xml:

<!-- The android:theme of the extenal net.openid.appauth.RedirectUriReceiverActivity
        have to be an Theme.AppCompat descendant since Flutter 3.24.0.
        Until this is fixed on the package level (https://github.com/Bdaya-Dev/oidc/issues/118)
        we have to use this workaround based on AndroidManifest merging logic:
        https://developer.android.com/build/manage-manifests -->
<activity
    android:name="net.openid.appauth.RedirectUriReceiverActivity"
    android:theme="@style/Theme.AppCompat.Translucent.NoTitleBar">
</activity>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant