Flutter开发:迁移Flutter应用到AndroidX
首先上官方文档:https://flutter.dev/docs/development/packages-and-plugins/androidx-compatibility 有两种方式,一种由Android studio自动完成,一种手动修改依赖配置。 官方推荐第一种,不过在我这不好使,于是我用了第二种,也成功跑起来了~ 自动方式 Use Android Studio to migrate y
目录6 个章节
首先上官方文档:https://flutter.dev/docs/development/packages-and-plugins/androidx-compatibility
有两种方式,一种由Android studio自动完成,一种手动修改依赖配置。 官方推荐第一种,不过在我这不好使,于是我用了第二种,也成功跑起来了~
自动方式
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.
手动方式
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'
欢迎交流
交流问题请在微信公众号后台留言,每一条信息我都会回复哈~
_EOF_
Flutter开发:迁移Flutter应用到AndroidX
- 本文作者:
- 程序设计实验室
- 版权声明:
- 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
相关文章
初见Flutter!框架简单介绍以及构建可发布的签名Apk包
哈喽!好久不见,算起来我已经一个多月没更新博客了,近期刚刚完成了一个项目,正好抽出时间整理一下学到的东西并且写写博客。 关于flutter 开始使用flutter还是春节后的事情,其实之前很早就想学一下flutter了,毕竟谷歌出的技术总是不会太差的,无奈一直没有时间和做app的需求,这次接触了flutter之后仿佛发现了新大陆,原来开发app还能这么方便,真的颠覆了我原来的认知啊,热更新也太好用
2021-12-18 · Flutter · 约 1 分钟
使用Flutter设计一个好看的_我_页面
近期遇到一些很烦的琐事,状态比较down,很多原本计划好的事情都耽搁了,实在是难顶…… 看到后台一直有朋友问怎么博客和公众号没有更新,所以我忙完得闲就来更了! 前言 起因是最近重拾以前的旧项目(业余做的,打算有机会自己运营起来)继续完善,然后发现有些界面设计太粗糙了,实在不满意~~(虽然是因为本来功能就不多)~~,然后就着手开始优化~ 应该会写成一系列文章,今天就从App的"我"页面开始吧~ 效果
2021-12-18 · Flutter · 约 1 分钟
Flutter播放音乐简单解决方案-AudioPlayers-与填坑
目前flutter播放音乐好像只搜到AudioPlayers这个解决方案,我照着他的文档来,确实是可以播放音乐的。 项目主页:https://pub.flutter-io.cn/packages/audioplayers AudioCache介绍:https://github.com/luanpotter/audioplayers/blob/master/doc/audio_cache.md An
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 分钟
讨论
共 0 条加载评论中…