androidflutterflutter-dependenciesappauth

flutter_appauth not working when local_auth is installed


This is my installed dependencies:

cupertino_icons: ^1.0.2
http: ^0.13.6
local_auth: ^2.1.6
rxdart: ^0.27.7
bloc: ^8.1.2
google_fonts: ^4.0.4
flutter_secure_storage: ^8.0.0
flutter_appauth: ^6.0.0
flutter_bloc: ^8.1.3
flutter_spinkit: ^5.2.0
cached_network_image: ^3.2.3
just_audio: ^0.9.33
just_audio_background: ^0.0.1-beta.10
audio_video_progress_bar: ^1.0.1
sliding_up_panel: ^2.0.0+1

When I'm trying to login using flutter_appauth without local_auth installed, everything is fine. But when I login again with local_auth installed, it shows these errors:

...
D/AndroidRuntime( 8319): Shutting down VM
E/AndroidRuntime( 8319): FATAL EXCEPTION: main
E/AndroidRuntime( 8319): Process: my.minda.mobile.player, PID: 8319
E/AndroidRuntime( 8319): java.lang.RuntimeException: Unable to start activity ComponentInfo{my.minda.mobile.player/net.openid.appauth.RedirectUriReceiverActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
E/AndroidRuntime( 8319):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3645)
E/AndroidRuntime( 8319):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3782)
E/AndroidRuntime( 8319):    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101)
E/AndroidRuntime( 8319):    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
E/AndroidRuntime( 8319):    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
E/AndroidRuntime( 8319):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2307)
E/AndroidRuntime( 8319):    at android.os.Handler.dispatchMessage(Handler.java:106)
E/AndroidRuntime( 8319):    at android.os.Looper.loopOnce(Looper.java:201)
E/AndroidRuntime( 8319):    at android.os.Looper.loop(Looper.java:288)
E/AndroidRuntime( 8319):    at android.app.ActivityThread.main(ActivityThread.java:7872)
E/AndroidRuntime( 8319):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 8319):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
E/AndroidRuntime( 8319):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
E/AndroidRuntime( 8319): Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
E/AndroidRuntime( 8319):    at androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor(AppCompatDelegateImpl.java:846)
E/AndroidRuntime( 8319):    at androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor(AppCompatDelegateImpl.java:809)
E/AndroidRuntime( 8319):    at androidx.appcompat.app.AppCompatDelegateImpl.initWindowDecorActionBar(AppCompatDelegateImpl.java:550)
E/AndroidRuntime( 8319):    at androidx.appcompat.app.AppCompatDelegateImpl.getSupportActionBar(AppCompatDelegateImpl.java:537)
E/AndroidRuntime( 8319):    at androidx.appcompat.app.AppCompatDelegateImpl.invalidateOptionsMenu(AppCompatDelegateImpl.java:1220)
E/AndroidRuntime( 8319):    at androidx.appcompat.app.AppCompatActivity.invalidateOptionsMenu(AppCompatActivity.java:314)
E/AndroidRuntime( 8319):    at androidx.activity.ComponentActivity.invalidateMenu(ComponentActivity.java:553)
E/AndroidRuntime( 8319):    at androidx.activity.ComponentActivity$$ExternalSyntheticLambda0.run(Unknown Source:2)
E/AndroidRuntime( 8319):    at androidx.core.view.MenuHostHelper.addMenuProvider(MenuHostHelper.java:133)
E/AndroidRuntime( 8319):    at androidx.activity.ComponentActivity.addMenuProvider(ComponentActivity.java:531)
E/AndroidRuntime( 8319):    at androidx.fragment.app.FragmentActivity$HostCallbacks.addMenuProvider(FragmentActivity.java:736)
E/AndroidRuntime( 8319):    at androidx.fragment.app.FragmentManager.attachController(FragmentManager.java:2793)
E/AndroidRuntime( 8319):    at androidx.fragment.app.FragmentController.attachHost(FragmentController.java:117)
E/AndroidRuntime( 8319):    at androidx.fragment.app.FragmentActivity.lambda$init$3$androidx-fragment-app-FragmentActivity(FragmentActivity.java:140)
E/AndroidRuntime( 8319):    at androidx.fragment.app.FragmentActivity$$ExternalSyntheticLambda3.onContextAvailable(Unknown Source:2)
E/AndroidRuntime( 8319):    at androidx.activity.contextaware.ContextAwareHelper.dispatchOnContextAvailable(ContextAwareHelper.java:99)
E/AndroidRuntime( 8319):    at androidx.activity.ComponentActivity.onCreate(ComponentActivity.java:352)
E/AndroidRuntime( 8319):    at androidx.fragment.app.FragmentActivity.onCreate(FragmentActivity.java:217)
E/AndroidRuntime( 8319):    at net.openid.appauth.RedirectUriReceiverActivity.onCreate(RedirectUriReceiverActivity.java:49)
E/AndroidRuntime( 8319):    at android.app.Activity.performCreate(Activity.java:8305)
E/AndroidRuntime( 8319):    at android.app.Activity.performCreate(Activity.java:8284)
E/AndroidRuntime( 8319):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1417)
E/AndroidRuntime( 8319):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3626)
E/AndroidRuntime( 8319):    ... 12 more
I/Process ( 8319): Sending signal. PID: 8319 SIG: 9
Lost connection to device.
Exited (sigterm)

How to use flutter_appauth and local_auth at the same time?

Tried to change android:theme in AndroidManifest.xml, but not working.


Solution

  • This is a known issue. There are different work arounds. The following info from the thread linked below.

    You could use specific versions as such:

    flutter_appauth: ^4.2.1
    local_auth: ^2.1.3
    local_auth_android: 1.0.8
    

    local_auth_android seems to be incompatible since they've upgraded androidx.fragment to 1.5.1

    You could also add xmlns:tools="http://schemas.android.com/tools" in the <manifest> clause in AndroidManifest.xml and then overwrite the theme.

    That looks as follows:

    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        package="XXXX">
    ...
    <application (...)
    tools:replace="android:theme"
    android:theme="@style/AppTheme">
    ....
    

    https://github.com/MaikuB/flutter_appauth/issues/362