Dev /docs/develo…
There are two ways to do this, either automatically by Android Studio or manually by changing the dependency configuration. The first one was officially recommended, but it didn’t work for me, so I used the second one and it worked
Automatic way
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
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.properties
change the line starting withdistributionUrl
like 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'
}
Copy the code
by
dependencies {
classpath 'com. Android. Tools. Build: gradle: 3.3.0'
}
Copy the code
- In
android/gradle.properties
, append
android.enableJetifier=true
android.useAndroidX=true
Copy the code
-
In
android/app/build.gradle
: Underandroid {
, make surecompileSdkVersion
andtargetSdkVersion
are at least 28. -
Replace all deprecated libraries with the AndroidX equivalents. For instance, if you’re using the default
.gradle
files make the following changes: Inandroid/app/build.gradle
testInstrumentationRunner "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'
Copy the code
by
androidTestImplementation 'androidx. Test. Runner: 1.1.1'
androidTestImplementation 'androidx. Test. Espresso: espresso - core: 3.1.1'
Copy the code
Welcome to communicate
Please leave a message in the background of wechat public account. I will reply to every message
- Wechat official number: star painting master
- Play code studio: live.bilibili.com/11883038
- Zhihu: www.zhihu.com/people/deal…
- Jane: www.jianshu.com/u/965b95853…