我想在flutter中使用local_auth插件,它需要Android生命周期,因此我安装了flutter_plugin_android_lifecycle,但是如果我尝试发布apk,则会收到此错误消息:error: 包androidx.lifecycle不存在。我尝试了很多事情,但无法正常工作。
''' C:\ flutter.pub-cache \ hosted \ pub.dartlang.org \ flutter_plugin_android_lifecycle-1.0.7 \ android \ src \ main \ java \ io \ flutter \ embeddding \ 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 \ embeddding \ engine \ plugins \ lifecycle \ FlutterLifecycleAdapter.java:22:错误: 找不到标志 公共静态生命周期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
'''
答案 0 :(得分:2)
在build.grable插件文件夹中添加实现'androidx.lifecycle:lifecycle-extensions:2.2.0'将解决此问题。
有关更多详细信息,请参见https://github.com/flutter/flutter/issues/60883。
答案 1 :(得分:0)
在您扑朔迷离的Yaml依赖项中添加它
flutter_plugin_android_lifecycle: ^1.0.11
有关更多信息,请访问:https://pub.dev/packages/flutter_plugin_android_lifecycle/install
答案 2 :(得分:0)
这也可能是由于版本问题引起的,因此请尝试在/android/build.gradle中使用这些兼容版本
classpath'com.android.tools.build:gradle:3.5.4'
您也可以尝试:
3.3.3
3.4.3
3.5.4
3.6.4
4.0.1
使用flutter插件file_picker时出现此错误。 我希望这项工作。