解决flutter 错误: 程序包androidx.lifecycle不存在问题
发生于编译时:错误: 程序包androidx.lifecycle不存在
先贴一段报错log,让你更加准确的匹配问题所在,对症下药,药,切克闹。
d:\study\flutter\flutter\.pub-cache\hosted\pub.flutter-io.cn\flutter_plugin_android_lifecycle-1.0.8\android\src\main\java\io\flutter\embedding\engine\plugins\lifecycle\flutterlifecycleadapter.java:8: 错误: 程序包androidx.lifecycle不存在
import androidx.lifecycle.lifecycle;
^
d:\study\flutter\flutter\.pub-cache\hosted\pub.flutter-io.cn\flutter_plugin_android_lifecycle-1.0.8\android\src\main\java\io\flutter\embedding\engine\plugins\lifecycle\flutterlifecycleadapter.java:22: 错误: 找不到符
号
public static lifecycle getactivitylifecycle(
符号: 类 lifecycle
位置: 类 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
build failed in 1s
exception: the plugin flutter_plugin_android_lifecycle could not be built due to the issue above.
既然问题已经匹配上了,那就说下我下面的解决实践吧。
上面的问题其实就是androidx引用库兼容问题,当某些插件升级到一定版本时就会出现这个问题。
首先升级下sdk
实际上到这里就已经解决了,但是可能有些包被墙了,下载不了,导致还是没解决,则需要使用阿里云的代理了
到这里应该是完全解决了,但是不排除个别钉子户,根据github issure给出的解决方案就是需要升级一下
gradle的版本了
方便复制:
以上就是我实践出来的解决方法,如果能帮到你,那真的是太好了。
总结
到此这篇关于解决flutter 错误: 程序包androidx.lifecycle不存在问题的文章就介绍到这了,更多相关程序包androidx.lifecycle不存在内容请搜索以前的文章或继续浏览下面的相关文章希望大家以后多多支持!