错误:flutter 中不存在包 androidx.lifecycle

Mil*_*czi 7 android flutter

我想在flutter中使用local_auth插件,它需要Android生命周期,所以我安装了flutter_plugin_android_lifecycle,但是如果我尝试发布apk,我会收到这个错误:错误:包androidx.lifecycle不存在。我尝试了很多东西,但我就是无法让它工作。

''' C:\flutter.pub-cache\hosted\pub.dartlang.org\flutter_plugin_android_lifecycle-1.0.7\android\src\main\java\io\flutter\embedding\engine\plugins\lifecycle\FlutterLifecycleAdapter.java: 8: 错误:包 androidx.lifecycle 不存在 import androidx.lifecycle.Lifecycle; ^ C:\flutter.pub-cache\hosted\pub.dartlang.org\flutter_plugin_android_lifecycle-1.0.7\android\src\main\java\io\flutter\embedding\engine\plugins\lifecycle\FlutterLifecycleAdapter.java:22:错误:找不到符号 public static Lifecycle getActivityLifecycle( ^ 符号:类生命周期位置:类 FlutterLifecycleAdapter 2 错误

       FAILURE: Build failed with an exception.

       * What went wrong:
       Execution failed for task ':compileReleaseJavaWithJavac'.
       > Compilation failed; see the compiler error output for details.

       * Try:
       Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

       * Get more help at https://help.gradle.org

       BUILD FAILED in 1s
Run Code Online (Sandbox Code Playgroud)

'''

aru*_*n-r 3

在 build.grable 插件文件夹中添加实现“androidx.lifecycle:lifecycle-extensions:2.2.0”将解决该问题。

有关更多详细信息,请参阅https://github.com/flutter/flutter/issues/60883