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

App crashes on Android with Flutter v3.24.0 #515

Closed
zigapovhe opened this issue Aug 7, 2024 · 5 comments · Fixed by #522
Closed

App crashes on Android with Flutter v3.24.0 #515

zigapovhe opened this issue Aug 7, 2024 · 5 comments · Fixed by #522

Comments

@zigapovhe
Copy link

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
Copy link

konradrutkowski commented Aug 8, 2024

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
Copy link
Author

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
Copy link
Owner

MaikuB commented Aug 10, 2024

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
Copy link
Author

@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
Copy link
Owner

MaikuB commented Aug 12, 2024

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants