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 diff
it was still not working after I migrated to androidx
I simply install google play service on my sdk and it worked
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
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
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.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.
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.