I am learning flutter, and while playing around with flutter's Geolocator 3.0.0 package. I came across an issue that wouldn't let me compile the app as soon as I add the reference to this package in pubspec.yaml file. A quick google search showed me the right github issue. The fix mentioned in the github issue (migrating app to support AndroidX - by updating compileSdkVersion in build.gradle file to 28, and adding android.useAndroidX=true and android.enableJetifier=true in gradle.properties) does work.

Main question: I am not sure if this (migrating project to support AndroidX) will need to be done for all flutter projects explicitly or is there a way to ensure all new flutter projects support AndroidX.

PS:I come from C# background, and I know nearly nothing about android / iOS app development.


Solution 1: Ugurcan Yildirim

You need to explicitly migrate a Flutter app to Android X by using Migrate to AndroidX... button located under Refactor tab of Android Studio. Manual migration is not recommended. If a plugin requires Android X, you need to perform this migration.

For the related article on Flutter.io, see: https://flutter.io/docs/development/packages-and-plugins/androidx-compatibility


Solution 2: Sctajc

Re your main question:

' I am not sure if this (migrating project to support AndroidX) will need to be done for all flutter explicitly or is there a way to ensure all new flutter projects support AndroidX'

I have never found the 'Refactor/Migrate to AndroidX' to work. Not even on new projects. I'm not sure it does anything at all. I always had to do manually even after just creating a new project. I follow the manual instructions but also delete any old versions of gradle in c:/....gradle/wrapper/dists/gradle-???. The current one, and only one to have available is gradle-5.1.1-all.