Android Studio build fail with minSDK=29

teranian picture teranian · Aug 22, 2019 · Viewed 7k times · Source

I have Android Studio build problem.

Build fails only when changing the minSdk=29 with follwing error.
( It's OK with minSdk=28 )

android {
    compileSdkVersion 29
    defaultConfig {
        applicationId "com.example.aaa"
        minSdkVersion 29  // build fails with 29, it's OK with 28
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

Fail messages on Android Studio build console

    - Build: build failed

       - Run build :

         ...

         Caused by: com.android.tools.r8.utils.AbortException


       - Andriod issues: (1 error)

         Dex file with version '38' cannot be used with min sdk level '29'. 

If anyone resolved this problem, please share your know-hows.

Thank you.

Answer

Michael Marsella picture Michael Marsella · Apr 29, 2020

I came across this recently when updating a project for Android studio 3.5.3 to 3.6.3, however I manually changed gradle-wrapper.properties and the project's build.gradle before even opening the project.

In my case I was able to clean the build, delete the .gradle and .idea folders and rebuild without issue.

Edit: As stated in the comments, it is worthwhile to try a clean-rebuild first, rather than the "Scorched Earth" approach of deleting .gradle and .idea folders. Deleting them will take longer to recover from and blow away all your nice IDE settings!