flutter_appauth 在安装了 local_auth 后不起作用。

huangapple go评论83阅读模式
英文:

flutter_appauth not working when local_auth is installed

问题

这是我的已安装的依赖项:

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

当我尝试使用 flutter_appauth 登录而没有安装 local_auth 时,一切正常。但当我安装了 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_appauthlocal_auth

尝试更改 AndroidManifest.xml 中的 android:theme,但不起作用。

英文:

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.

答案1

得分: 1

这是一个已知问题。有不同的解决方法。以下是与下面链接的主题相关的信息。

您可以使用特定版本,如下所示:

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

英文:

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

huangapple
  • 本文由 发表于 2023年5月28日 13:53:56
  • 转载请务必保留本文链接:https://go.coder-hub.com/76350135.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定