6

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.

5
  • 2
    developer.android.com/guide/topics/manifest/uses-sdk-element Please read on this . android:minSdkVersion: ""An integer designating the minimum API Level required for the application to run"" The latest version of Android is Android Pie which uses SDK version 28. Commented Aug 22, 2019 at 2:30
  • try to add compile "com.android.tools:r8:1.4.93" to the build dependencies (not your app dependencies). Something like: classpath 'com.android.tools:r8:1.4.93' classpath 'com.android.tools.build:gradle:3.4.2' Commented Aug 22, 2019 at 5:51
  • This problem was resolved after updating Android Studio version 3.5 ! Thank you. Gabriele Mariotti, sunil sunny. Commented Aug 23, 2019 at 4:56
  • 3
    Clean & Rebuild, and/or Invalidate caches & restart solved my issue. Commented Mar 24, 2020 at 15:25
  • I am getting this error with Android Studio and gradle 3.6.2. Any solution other than downgrading? Commented Apr 7, 2020 at 20:31

2 Answers 2

14

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!

Sign up to request clarification or add additional context in comments.

1 Comment

Cleaning the build and then running 'Make Project' fixed it for me.
0

This is because of latest gradle version : classpath 'com.android.tools.build:gradle:3.5.3'

in Android 6.0 and lower android versions. In order to fix it you can downgrade the gradle version as follows :

classpath 'com.android.tools.build:gradle:3.5.1'

It will run on all android versions perfectly.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.