Search code examples
android-studioflutterandroidx

Unable to migrate Flutter project to AndroidX


I have a Flutter project in Android Studio. I am planning to migrate to AndroidX. Whenever I do Refactor -> Migrate to AndroidX, Android Studio shows error message:

You need to have compileSdk set to at least 28 in your module build.gradle to migrate to AndroidX.

However I have already set the compileSdkVersion 28 in my app/gradle.build file.

enter image description here

Is there anything else I need to do?


Solution

  • I was able to resolve my issue:

    1. Open the Flutter project into Android Studio
    2. Right click on the android directory, click on 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 check the Google Play Services.

    After the Google Play Services Installed, I did Refactor -> Migrate to AndroidX. It started working.

    Note: Do the refactor from the project window you opened in the step 2.