我想在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 不存在
导入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)静态生命周期 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
'''
最佳答案
在 build.grable 插件文件夹中添加实现 'androidx.lifecycle:lifecycle-extensions:2.2.0' 将解决该问题。
引用 https://github.com/flutter/flutter/issues/60883更多细节。
关于android - 错误: package androidx.生命周期在flutter中不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61648177/