Flutter Development: Migrating a Flutter App to AndroidX
First, the official documentation: https://flutter.dev/docs/development/packages-and-plugins/androidx-compatibility There are two approaches: one completed automatically by Android Studio, and one that manually modifies the dependency configuration. The official docs recommend the first, but it didn’t work for me, so I used the second and got it running successfully~ Automatic method Use Android Studio to migrate y
目录6 个章节
First, the official documentation: https://flutter.dev/docs/development/packages-and-plugins/androidx-compatibility
There are two approaches: one completed automatically by Android Studio, and one that manually modifies the dependency configuration. The official docs recommend the first, but it didn’t work for me, so I used the second and got it running successfully~
Automatic Method
Use Android Studio to migrate your app
This requires the latest version of Android Studio. Use the following instructions:
- Import your Flutter app into Android Studio so that the IDE can parse the Android code following the steps in Editing Android code in Android Studio with full IDE support.
- Follow the instructions for Migrating to AndroidX.
Manual Method
Manually migrate your app
See Migrating to AndroidX for more detailed instructions on how to do this. Below are some steps that you’ll likely need to go through as part of this process, listed here for reference. However the specific things you need to do will depend on your build configuration and could differ from the example changes suggested here.
-
In
android/gradle/wrapper/gradle-wrapper.propertieschange the line starting withdistributionUrllike this:distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip -
In
android/build.gradle, replace: content_copy
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
}
by
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
}
- In
android/gradle.properties, append
android.enableJetifier=true
android.useAndroidX=true
-
In
android/app/build.gradle: Underandroid {, make surecompileSdkVersionandtargetSdkVersionare at least 28. -
Replace all deprecated libraries with the AndroidX equivalents. For instance, if you’re using the default
.gradlefiles make the following changes: Inandroid/app/build.gradletestInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"bytestInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Finally, under dependencies {, replace
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
by
androidTestImplementation 'androidx.test.runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
Feel Free to Chat
For questions, please leave a message on the WeChat official account backend. I’ll reply to every message~
- WeChat official account: 画星星高手
- Coding livestream: https://live.bilibili.com/11883038
- Zhihu: https://www.zhihu.com/people/dealiaxy
- Jianshu: https://www.jianshu.com/u/965b95853b9f
_EOF_
Flutter Development: Migrating a Flutter App to AndroidX
- 本文作者:
- 程序设计实验室
- 版权声明:
- 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
相关文章
极简诗词app开发背后:Flutter移动应用快速构建实践——状态管理、国际化、数据持久化、性能优化(一)
前言 在开始之前的提示:虽然Flutter背靠Google这棵大树,但是毕竟还是一个年轻的技术,项目还处于初期阶段,更新非常快,问题也不是一般的多,使用Flutter的话就意味着必须忍受各种奇怪的bug和没有丰富中文资料的头疼,本文不是安利同学们入坑,只是对“极简诗词”app的开发过程进行记录。 另外app已经上架,有兴趣的同学可以下载试试:https://www.coolapk.com/apk/
2022-03-23 · Flutter · 约 1 分钟
Flutter编译失败:java-nio-file-NoSuchFileException--build-app-intermediates
FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:mergeExtDexDebug'. A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$Acti
2021-12-18 · Flutter · 约 1 分钟
从细节入手改善用户体验,Flutter跨平台App开发中设置Android和iOS的启动页
前言 flutter开发App方便快捷,就是冷启动的时候要加载dart引擎有短暂的白屏,严重影响用户体验,这个时候我们就需要设置一个启动图片,像国内大部分App那样(例如微信那个地球),启动App的时候显示这个图片,加载完再进入App,不至于影响用户体验。 Android启动页 首先要准备好启动图,本文命名为splash.png,按照不同的分辨率添加到对应的mipmap-hdpi / mipmap
2021-12-18 · Flutter · 约 1 分钟
有模有样解决Flutter里Webview无法访问HTTP页面的问题
探索过程 Android9(好像是吧)开始谷歌就默认不让开发者访问不安全HTTP内容了,如果非要用HTTP,那必须在networkSecurityConfig里配置cleartextTrafficPermitted才行。谷歌这个设计的出发点本是好的,HTTPS固然更安全咱都懂,但有时候这个后端接口你选择不了要HTTP还是HTTPS,比如要使用没有提供HTTPS的第三方服务,或者是本文的这种情况:在
2021-12-18 · Flutter · 约 1 分钟
讨论
共 0 条加载评论中…