Fixing AndroidX error in Flutter

CarlosMillan
2 min readMar 8, 2019

Hello Flutterverse, today I came to discuss a problem that it has been occurring when we are building our Flutter app, appears a message that this app is incompatible with AndroidX.

This happens when a package or dependency that uses the app has migrated to AndroidX or when the libraries of android.support (that are in disuse) are incompatible with AndroidX (which comes to replace it).

Most of the times you can fix it by downgrading the version of the package with the problem, but if it still does not work (happened to me), then we do the following steps.

How to solve this issue

  1. Open the flutter project with Android Studio. Yes, I know it’s heavy and you do not use it, but you need to fix the problem.

2. On the left, at the file tree, we look for the android folder and right click on it, click on the Flutter option and then Open Android module in Android Studio. If a window Open Project is open, click on the This Window button.

3. Then a window appears informing you that it is advisable to update the Gradle plugin. In this window we click on the Update button.

4. In Android Studio we click on the Tools -> SDK Manager -> SDK Tools menu and verify that we have selected the Google Play Services option. In case the box is empty, they click on it and then install it.

5. After Google Play Service has been installed, on the left panel tree we look for the android -> app folder and open the gradle.build file, search for the property compileSdkVersion and change the value to 28.

6. Open the gradle.properties file and add the following lines:

- android.useAndroidX=true

- android.enableJetifier=true

7. Then in the file tree on the left panel, at the top change the Android mode by Project, right click on the android folder and select the Migrate to AndroidX option. A window appears to inform us that it will make a backup if we want, then click the Migrate button. We select where we want to save the copy, if so we decided in the previous window and then click OK.

8. Start to perform the processes and then will inform us if everything went well.

9. After this, it’s a good idea execute the flutter clean command to delete the build folder and run the app, the error won’t appear.

I hope you find this guide helpful, I apologize for the lack of images, I made this post after I solve it and didn’t take the screenshoots from my process, but all the steps needed are written one by one!

My Twitter: @unAndroidMas

--

--