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.

Answer
      • 2
    • @GünterZöchbauer Thanks for very quick response, and would you know if it is always going to be the case? Btw, I have seen your answers on many flutter questions and found them helpful too.

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

  • 1
Reply Report
      • 1
    • I read this exact article and sort of understood the migration bit, but would you know if this manual migration is interim solution or is that how that is always going to be?
      • 1
    • I don't think you should worry about if this is an interim or not. Just migrate to Android X if you need, and you are good to go.

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.

  • 0
Reply Report

Warm tip !!!

This article is reproduced from Stack Exchange / Stack Overflow, please click

Trending Tags

Related Questions