安装local_auth时flutter_appauth不工作

jvlzgdj9  于 2023-05-29  发布在  Flutter
关注(0)|答案(1)|浏览(162)

这是我安装的依赖项:

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

当我尝试在没有安装local_auth的情况下使用flutter_appauth登录时,一切正常。但是当我安装local_auth再次登录时,它显示以下错误:

...
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)

如何同时使用flutter_appauth和local_auth?
尝试在AndroidManifest.xml中更改android:主题,但不起作用。

mm5n2pyu

mm5n2pyu1#

这是一个已知问题。有不同的工作区。以下信息来自下面链接的线程。
您可以使用特定的版本,如下所示:

flutter_appauth: ^4.2.1
local_auth: ^2.1.3
local_auth_android: 1.0.8

local_auth_android似乎不兼容,因为他们已经升级androidx.fragment到1.5.1
您还可以在AndroidManifest.xml<manifest>子句中添加xmlns:tools="http://schemas.android.com/tools",然后覆盖主题。
如下所示:

<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

相关问题