android - 错误: package androidx.生命周期在flutter中不存在

标签 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 不存在
导入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/

相关文章:

dart - 如何从抽屉导航 flutter 中重置任何类的状态?

android - 在后台通过 setContentView 加载布局时显示对话框

java - 用 Java 或 Android 编写小数

flutter - 从主题更改 RaisedButton 的颜色不起作用

firebase - 'streamChatState!= null' : You must have a StreamChat widget at the top of your widget tree

android - 设备不适用于 "main.dart"配置,

android - 在 activity_main.xml 文件中导入 "android.support.v4.view.ViewPager"

android - 如何将 .aar 依赖项包含到 Android 库 .aar 文件中

android - setClipBounds 可以在 View 绘制之前调用吗?

flutter - 像 SliverAppBar 一样隐藏 TabBar