AndroidX incompatibilities (Build failed with an exception)

Daniel Carneiro
3 min readMay 27, 2021

Example of issue

The built failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using Jetfier to solve the incompatibility.
Building plugin file_picker…
FAILURE: Build failed with an exception.What went wrong:
A problem occurred configuring root project ‘file_picker’.
SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.

When I was installing the flutter_file_picker and then was trying to build the app I started to get that error described above, so I will describe the process of how I fixed it.

Please note that this is a solution for this problem in specific, but some of the steps here might help you in case you have a similar problem

How I fixed “unexpected element <queries> found in <manifest>” error?

app\android\build.gradle

dependencies {classpath 'com.android.tools.build:gradle:3.6.3'}

app\android\app\build.gradle

compileSdkVersion 29

app\android\gradle\wrapper\gradle-wrapper.properties

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

app\android\gradle.properties

ensure you have this properties added

android.useAndroidX=trueandroid.enableJetifier=true

After doing that change I strongly advise you to have a look at the steps to migrate to Android X

How do I migrate my existing app, plugin or host-editable module project to AndroidX?

NOTE: following was taken from the flutter website, link on references.

You will need Android Studio 3.2 or higher. If you don’t have it installed, you can download the latest version from the Android Studio site.

  1. Open Android Studio.
  2. Select Open an existing Android Studio Project.
  3. Open the android directory within your app.
  4. Wait until the project has been synced successfully. (This happens automatically once you open the project, but if it doesn’t, select Sync Project with Gradle Files from the File menu).
  5. Select Migrate to AndroidX from the Refactor menu.
  6. If you are asked to backup the project before proceeding, check Backup project as Zip file, then click Migrate. Lastly, save the zip file in your location of preference.
  1. The refactoring preview shows the list of changes. Finally, click Do Refactor:

That is it! You successfully migrated your project to AndroidX

NOTE: This process might take a while, as sometimes it downloads a lot of graddle versions, but just wait until it is all downloaded and then press refactor. After that is done try again to build your apk and it should work as expected.

REFERENCES:

--

--