flutter_升级androidx心得记录

本人也是个新手记录一些自己所遇到的问题。

Launching lib\main.dart on Nokia X6 in debug mode...

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:preDebugBuild'.
> Android dependency 'androidx.appcompat:appcompat' has different version for the compile (1.0.0-beta01) and runtime (1.1.0-alpha02) classpath. You should manually set the same version via DependencyResolution

* 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 15s
*******************************************************************************************
The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app.
See https://goo.gl/CP92wY for more information on the problem and how to fix it.
*******************************************************************************************
Gradle task assembleDebug failed with exit code 1
Exited (sigterm)

大概意思是说,安卓依赖在编译时和运行时出现了不同的版本,因为有了AndroidX的出现。

可能在你使用的依赖package的时候,你会注意到他们的更新日志,其中会有Migrate to AndroidX。

 

原因:

由于之前的Android.support包管理过于混乱,所以Google推出了AndroidX。如果各位开发者有时间的话,还是要尽量升级一下项目到AndroidX,毕竟这个是未来,谷歌的新标准。

 

怎么升级,错误信息已经给出了提示,进入 https://goo.gl/CP92wY  

 

①使用Android Studio自动升级

确保Android Studio版本是最新版,或者至少3.2以上。

打开你的项目,选中android文件夹,右键选择,Flutter,Open Android Module in Android Studio。

flutter_升级androidx心得记录_第1张图片

这个时候会打开一个新窗口,等它分析完成之后,选择Refactor——Migrate to AndroidX。

flutter_升级androidx心得记录_第2张图片

 

flutter_升级androidx心得记录_第3张图片

 

 

 检测完成后,下方出现提示,提示需要升级的地方,确认后点击“Do Refector”

flutter_升级androidx心得记录_第4张图片

 

 

升级完成后,关闭窗口即可。

这个时候你再编译Flutter,就没问题啦~~~~~~~~~~~~

 

这样基本上不会有问题。如果还有问题,那么就要看看你创建项目的时候有没有选着这两个。

flutter_升级androidx心得记录_第5张图片

如果打钩了那么会生成对应的代码,也就是在转androidx的时候有些东西还是会存在问题。

如果没有打钩那么按照上面的方法就可以升级到androidx。

你可能感兴趣的:(flutter)