Reputation: 1280
I just created a new flutter project, added a few plugins and I'm getting the plugin switched to android x therefore i need to switch to android x. I've tried all the different ways of moving to android x and none has worked for me so far. Right now i don't even know what to do anymore, its so frustrating, why wouldn't flutter handle that when creating new projects automatically. Might be using ionic for the project.
Upvotes: 32
Views: 49070
Reputation: 43
Faced with the same issue.
In my build.gradle compileSdkVersion and targetSdkVersion were already set to 28. minSdkVersion was set to 23.
Had already added android.useAndroidX=true android.enableJetifier=true to my android/graddle.properties.
After adding all these still migrating to AndroidX was not possible. When doing so a message pop up saying "No usage found in this project"
Adding the following code to my app/build.gradle solved the issue.
android {
defaultConfig {
...
minSdkVersion 23
targetSdkVersion 28
multiDexEnabled true
}
}
dependencies {
implementation 'com.android.support:multidex:1.0.3'
}
Upvotes: 0
Reputation: 51
Add this to the end of your pubspec.yaml
file, without any parent:
module:
androidX: true
Then, at android/graddle.properties add:
android.useAndroidX=true
android.enableJetifier=true
Run at your CLI:
flutter clean
and rerun your code
flutter run
This may adjust your problem with AndroidX
.
For your SDK, i think you may change inside android/app/build.gradle
minSdkVersion 21
targetSdkVersion 28
multiDexEnabled true
the multiDexEnabled
is optional (in case of some error related to it).
I think this may solve your problem, please give me a feedback about it.
Upvotes: 5
Reputation: 2981
I faced the similar problem.
This Medium article helped me to find 75% solution for my problem
I followed the steps mentioned in this article. and I'm stuck in the end
Android studio is not allowed me to open android module (folder) from the project structure directly. So I opend manually in the new window of android studio.
Android is not refactored the gradle testRunner
classpath
androidTestImplementation
it is prompting like is dependent So then I manually replaced all the paths like.
android.support.test.runner.AndroidJUnitRunner
to androidx.test.runner.AndroidJUnitRunner
com.android.support.test:runner
to androidx.test:runner:1.1.0
com.android.support.test.espresso:espresso-core
to androidx.test.espresso:espresso-core:3.1.0
and at the end I added to android/gradle.properties
android.useAndroidX=true
android.enableJetifier=true
Then ran the application. ;) after that androidX warning disappeared.
Upvotes: 1
Reputation: 2092
After a lot of tries, I've just created a new Flutter project and just copy past the pubspec.yaml, lib and assets folder from the old project to the new one, and the problem solved
Upvotes: 4
Reputation: 5780
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:
android/gradle.properties
and addedandroid.useAndroidX=true
android.enableJetifier=true
opened android/build.gradle
and changed
com.android.tools.build:gradle
to version 3.3.0
com.google.gms:google-services
to version 4.2.0
opened android/app/build.gradle
and
compileSdkVersion
to 28
android.support.test.runner.AndroidJUnitRunner
to androidx.test.runner.AndroidJUnitRunner
com.android.support.test:runner
to androidx.test:runner:1.1.0
com.android.support.test.espresso:espresso-core
to androidx.test.espresso:espresso-core:3.1.0
opened android/gradle/wrapper/gradle-wrapper.properties
and changed distributionUrl
to https\://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! :)
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
Upvotes: 81
Reputation: 113
it was still not working after I migrated to androidx
I simply install google play service on my sdk and it worked
Upvotes: 0
Reputation: 135
I Faced this problem recently. After looking for many hours I came across this medium page https://medium.com/@swhussain110/how-to-migrate-your-flutter-app-to-androidx-9a78eaaa924b
Follow these steps
com.android.tools.build:gradle:3.3.1
.compileSdkVersion
and targetSdkVersion
to 28.Upvotes: 3
Reputation: 61
I've made the migration successfully by using Sam's answer!
1. Open the Flutter project into Android Studio
2. Right click on the android directory and Flutter -> Open Android module in Android Studio. It asked me to upgrade my gradle plugin.
3. Then I installed Google Play Services. Tools -> SDK Manager -> SDK Tools and chek the Goolge Play Services.
Upvotes: 6
Reputation: 337
When you update your Android Studio version from 3.2 to 3.3. Android Studio version 3.3 onwards you can either use either android libraries or androidx libraries but
In flutter platform, flutter will always take the newest configuration of android studio.
This is the main reason why users get an error to use dependency according to androidx.
To migrate the flutter project to AndroidX, check this link: https://flutter.dev/docs/development/packages-and-plugins/androidx-compatibility
Upvotes: 1