How to migrate your Flutter app to AndroidX

Gabriel Rodríguez
1 min readFeb 27, 2019

--

If you’re getting build (Gradle) errors when adding recent versions of plugins, and if you’re having trouble following the instructions on the Android site, follow these instructions.

Under android/app/build.gradle, do the following changes:

Replace compileSdkVersion 27 with compileSdkVersion 28.

Under defaultConfig {:

Replace targetSdkVersion 27 with targetSdkVersion 28.

Replace android.support.test.runner.AndroidJUnitRunner with androidx.test.runner.AndroidJUnitRunner.

Under dependencies {:

Replace com.android.support.test.runner:1.0.2 with androidx.test.runner:1.1.1 and com.android.support.test.espresso:espresso-core:3.0.2 with androidx.test.espresso:espresso-core:3.1.1. (Version numbers may vary)

In android/gradle/wrapper/gradle-wrapper.properties

Change the line starting with distributionUrl like this:

distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip

In android/build.gradle

Under dependencies {, change classpath 'com.android.tools.build:gradle:3.2.1' to classpath 'com.android.tools.build:gradle:3.3.0' .

In android/gradle.properties

Append the following:

android.enableJetifier=true
android.useAndroidX=true

--

--