曦远 (DealiAxy)一份私人的文字刊物

StarBlog
返回文章列表折页手记阅读全文
Flutter

Flutter开发:迁移Flutter应用到AndroidX

首先上官方文档:https://flutter.dev/docs/development/packages-and-plugins/androidx-compatibility 有两种方式,一种由Android studio自动完成,一种手动修改依赖配置。 官方推荐第一种,不过在我这不好使,于是我用了第二种,也成功跑起来了~ 自动方式 Use Android Studio to migrate y

曦远 (DealiAxy)约 8 分钟
目录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:

  1. 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.
  2. 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.

  1. In android/gradle/wrapper/gradle-wrapper.properties change the line starting with distributionUrl like this: distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip

  2. 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'
}
  1. In android/gradle.properties, append
android.enableJetifier=true
android.useAndroidX=true
  1. In android/app/build.gradle: Under android {, make sure compileSdkVersion and targetSdkVersion are at least 28.

  2. Replace all deprecated libraries with the AndroidX equivalents. For instance, if you’re using the default .gradle files make the following changes: In android/app/build.gradle testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" by testInstrumentationRunner "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跨平台App开发中设置Android和iOS的启动页

前言 flutter开发App方便快捷,就是冷启动的时候要加载dart引擎有短暂的白屏,严重影响用户体验,这个时候我们就需要设置一个启动图片,像国内大部分App那样(例如微信那个地球),启动App的时候显示这个图片,加载完再进入App,不至于影响用户体验。 Android启动页 首先要准备好启动图,本文命名为splash.png,按照不同的分辨率添加到对应的mipmap-hdpi / mipmap

2021-12-18 · Flutter · 约 1 分钟

把爬虫放到手机上跑!Flutter爬虫框架初探~

最近做毕设需要大量数据训练模型,很多网站又要反爬机制,得爬一会停一会,所以特别慢,要是我用电脑24小时爬虫太费电了,于是想到利用手机~ 然后就想到flutter,安卓苹果旧手机都能利用起来做数据采集。 ok,然后就开始做,折腾了一天做了一个大概的框架。总算可以方便的添加爬虫任务了,集成了配置、日志、数据持久化这些基本的功能,然后封装网络请求、网页解析的功能,用起来还行。 只不过众所周知的,dart

2021-12-18 · Flutter · 约 1 分钟

讨论

共 0 条

良言一句三冬暖,恶语伤人六月寒。

加载评论中…