MaikuB / flutter_appauth

A Flutter wrapper for AppAuth iOS and Android SDKs
274 stars 246 forks source link

App crashes on Android with Flutter v3.24.0 #515

Closed zigapovhe closed 3 months ago

zigapovhe commented 3 months ago

We have been using your package for quite some time and it really works well. Yesterday, as Flutter v3.24.0 came out, and we soon figured out that the the package stopped working in all of our apps after upgrading the Flutter to the latest stable version.

The WebView is opened normally, but after login is successful, we get this error and app crashes:

D/AndroidRuntime( 7684): Shutting down VM E/AndroidRuntime( 7684): FATAL EXCEPTION: main E/AndroidRuntime( 7684): Process: com.ourcompany.app, PID: 7684 E/AndroidRuntime( 7684): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ourcompany.app/net.openid.appauth.RedirectUriReceiverActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.

Not sure what's really broken, but since VM is appearing in logs, this could help: > vm_service 14.2.4 (was 14.2.1) Looks like vm_service package gets automatically upgraded after building our apps for the first time with latest flutter version.

After downgrading Flutter version back to v3.22.3, everything works as expected. We were testing on various Android 14 devices and emulators and on Android 15 devices.

iOS apps are working fine.

konradrutkowski commented 3 months ago

It seems like with the update to Flutter v3.24.0, activity now requires a Theme.AppCompat theme or a descendant. To resolve this, you can add the android:theme="@style/Theme.AppCompat.NoActionBar" attribute to the RedirectUriReceiverActivity in your AndroidManifest.xml. This should solve the problem for now.

zigapovhe commented 3 months ago

It seems like with the update to Flutter v3.24.0, activity now requires a Theme.AppCompat theme or a descendant. To resolve this, you can add the android:theme="@style/Theme.AppCompat.NoActionBar" attribute to the RedirectUriReceiverActivity in your AndroidManifest.xml. This should solve the problem for now.

Thank you, it indeed works! I was not aware you could specify android theme directly in the manifest. It should eventually be fixed by library but it is nice workaround.

MaikuB commented 3 months ago

Thank you, it indeed works! I was not aware you could specify android theme directly in the manifest.

Yep it's possible and for future reference you can read this. The readme for this plugin specifies how the activity could be specified even though the AppAuth Android SDK does so itself. This is possible to due how manifests can be merged.

Note I've published 6.0.7 that includes a solution to this by having this plugin specify the theme itself

zigapovhe commented 3 months ago

@MaikuB I just updated app_auth library to 6.0.7, but the issue still persist with the same error: Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.

Adding android:theme="@style/Theme.AppCompat.NoActionBar" back to the manifest solves the issue.

MaikuB commented 3 months ago

@zigapovhe Please provide a link to a repo hosting a minimal app that can reproduce the issue. Note the fix only applies for apps that were not specifying the redirect activity in the manifest file for their own app. Anything provided specified by the app could end up taking precedence

Edit: based on what you said it sounded like you had specified the activity in your own as you mentioned adding back that specific attribute. If you specify the activity in your own app then you need to specify the theme yourself. Have a read of https://developer.android.com/build/manage-manifests that I shared earlier to understand more about the manifest merging capabilities