How to Solve Android X Migration Issues In Flutter?

· 3 min read
How to Solve Android X Migration Issues In Flutter
How to Solve Android X Migration Issues In Flutter

Sometimes when a user creates a new project or upgrades the existing plugins to the latest plugins user may get a Migration Issues with Android X. So in this article How to Solve Android X Migration Issues In Flutter?

How to Solve Android X Migration Issues In Flutter?

Kindly follow the below steps for the same.

  • updated Android Studio to 3.3
  • tried menu Refactor > Migrate to AndroidX
  • Got “No Usage Found
  • opened android/gradle.properties and added
    android.useAndroidX=true
    android.enableJetifier=true
  • Opened android/build.gradle and changed.

        1. com.android.tools.build:gradle to version 3.3.0

        2. com.google.gms:google-services to version 4.2.0

  • opened android/app/build.gradle and
  • changed compileSdkVersion to 28
  • replaced android.support.test.runner.AndroidJUnitRunner to androidx.test.runner.AndroidJUnitRunner
  • replaced com.android.support.test.espresso:espresso-core to androidx.test.espresso:espresso-core:3.1.0
  • replaced com.android.support.test:runner to androidx.test:runner:1.1.0
  • opened android/gradle/wrapper/gradle-wrapper.properties and changed distributionUrl to https\://services.gradle.org/distributions/gradle-4.10.2-all.zip.
  • Simply run a command
    Flutter Clean

User can also try the below things:

Add the below lines to 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

It may fix your problem with Android X.

For your SDK, I think you may change inside android/app/build.gradle

minSdkVersion 21
targetSdkVersion 28
multiDexEnabled true

Have you remember of Multidex Issue which is an Optional as of now.
Now simply run a Flutter Clean in your project.

flutter clean

You can also refer the medium article for the same.

Android Studio is not allowed me to open the android module (folder) from the project structure directly.

Android is not refactored the Gradle testRunner classpath androidTestImplementation it is prompting like is dependent So then manually replaced all the paths like.

  • replaced android.support.test.runner.AndroidJUnitRunner to androidx.test.runner.AndroidJUnitRunne
  • replaced com.android.support.test:runner to androidx.test:runner:1.1.0
  • replaced 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

Conclusion:

In this article, We have been through How to Solve Android X Migration Issues in Flutter?

Keep Learning !!! Keep Fluttering !!!

Still, need a Support for Flutter Development? Do let us know.

FlutterAgency.com is our portal Platform dedicated to Flutter Technology and Flutter Developers. The portal is full of cool resources from Flutter like Flutter Widget GuideFlutter ProjectsCode libs and etc.

FlutterAgency.com is one of the most popular online portal dedicated to Flutter Technology and daily thousands of unique visitors come to this portal to enhance their knowledge on Flutter.

Leave a Reply