Flutter Projects & Android X Migration Issues
As you are creating a new project, just follow @harsh 's answer and you're done.
However, as I recently upgraded my existing app to use new plugins, I had to migrate to AndroidX as well... and the default procedure in the official instructions didn't work, which is using Android Studio to migrate the project - it said "No usages found!".
So what I did was:
- updated Android Studio to 3.3
- tried menu Refactor > Migrate to AndroidX
- got "No usages found" (if you manage to do it here instead, stop! you're done! ... actually, you can give this answer a try before continuing)
- opened
android/gradle.properties
and added
android.useAndroidX=true
android.enableJetifier=true
opened
android/build.gradle
and changedcom.android.tools.build:gradle
to version3.3.0
com.google.gms:google-services
to version4.2.0
opened
android/app/build.gradle
and- changed
compileSdkVersion
to28
- replaced
android.support.test.runner.AndroidJUnitRunner
toandroidx.test.runner.AndroidJUnitRunner
- replaced
com.android.support.test:runner
toandroidx.test:runner:1.1.0
- replaced
com.android.support.test.espresso:espresso-core
toandroidx.test.espresso:espresso-core:3.1.0
- in my case that was it, but here's the complete list of required replacements
- changed
opened
android/gradle/wrapper/gradle-wrapper.properties
and changeddistributionUrl
tohttps\://services.gradle.org/distributions/gradle-4.10.2-all.zip
(you might have to use 5.4.1, please see update below)executed
flutter clean
And contrary to what I expected, IT WORKED! :)
UPDATE (2019 October 27th)
When updating my app to flutter v1.9.1+hotfix.5
, as I use app signing, I was stuck with the error SigningConfig "release" is missing required property "storePassword"
and in the end it was the gradle version from step 7 above. So now I'm using 5.4.1 as suggested in this wiki.
[android/gradle/wrapper/gradle-wrapper.properties]
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
How to fix flutter AndroidX incompatibility?
Thanks for your suggestion,
I've fixed it by doing these steps :
1. Try adding this line In your Project folder > android > app > build.gradle, add the following Line in
multiDexEnabled true
Unable to migrate Flutter project to AndroidX
I was able to resolve my issue:
- Open the Flutter project into Android Studio
- Right click on the android directory, click on Flutter -> Open Android module in Android Studio. It asked me to upgrade my gradle plugin.
- Then I installed Google Play Services. Tools -> SDK Manager -> SDK Tools and check the Google Play Services.
After the Google Play Services Installed, I did Refactor -> Migrate to AndroidX.
It started working.
Note: Do the refactor from the project window you opened in the step 2.
Your app isn't using AndroidX - Flutter doesn't allow me to generate apk
this because your project is missing gradle.prperties file >> open terminal in android studio or vs code and write "flutter create ." it will create missing file one of them is gradle.properties.
Migrate Flutter project to AndroidX
Solution: https://flutter.dev/docs/development/androidx-migration
So I went to the given link and tried to implement it by the help of Android Studio, but it always leads to No usage found.
So I went back to the link and tried the other approach of editing the gradle.properties
in android
level (android/gradle
) and add these properties:
android.useAndroidX=true
android.enableJetifier=true
How to migrate flutter project to androidx
You would require to migrate to Android X if you intend to use features that have breaking changes for the latest library. I personally faced this problem cloud_firestore 0.9.0 as the change log says, it required a migration to Android X.
Your Android app is in the android
directory of the project. First open the android
directory with Android Studio 3.2+
. Then Refactor > Migrate to AndroidX. After that also add these to the gradle.properties
file in the android
directory
android.useAndroidX=true
android.enableJetifier=true
Related Topics
How to Make an Http Request Using Cookies on Flutter
How to Attach Multiple Files to Email Client in Android
How to Copy Text to Clip Board in Android
How to Receive Serial Data Using Android Bluetooth
Controlling the Camera to Take Pictures in Portrait Doesn't Rotate the Final Images
Write Android Logcat Data to a File
Android - How to Make a Button Flash
Android - Keep Listview's Item Highlighted Once One Has Been Clicked
Android: How to Change Checkbox Size
Android Mediaplayer Throwing "Prepare Failed.: Status=0X1" on 2.1, Works on 2.2
Android Device Manager Fails to Launch After Updating to MACos Big Sur 11.3
How to Securely Store Access Token and Secret in Android
How to Check Edittext's Text Is Email Address or Not
How to Show Android Checkbox at Right Side
How to Draw Rounded Rectangle in Android Ui