Urja Pawar
Urja Pawar

Reputation: 1085

Build fails due to missing dx.jar

Whenever I try to build the project, it shows the following error,

Error:Execution failed for task ':app:transformClassesWithDexForDebug'>  com.android.build.api.transform.TransformException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: java.lang.IllegalStateException: dx.jar is missing

I have recently updated my sdk and after that uninstalled android studio unchecking the sdk and downloaded the IDE(just because I wanted to update studio) without sdk and made it to use the present sdk.

Please help! I am not finding any solution working yet.

Upvotes: 4

Views: 7125

Answers (5)

Nguyễn Anh Tuấn
Nguyễn Anh Tuấn

Reputation: 1350

I have to copy dx.jar from /build-tools/33.0.0/lib/dx.jar to /build-tools/34.0.0/lib/dx.jar when I set buildToolsVersion to version 34.

Upvotes: 2

Mohsen Zahraee
Mohsen Zahraee

Reputation: 3483

It's related to your buildToolsVersion config in build.gradle

Go to your SDK path and find the build-tools directory and search for dx.jar file. Each folder that has dx.jar file could be your buildToolsVersion.

If not exist any dx.jar use SdkManager to download one build-tools

Upvotes: 0

SandTh
SandTh

Reputation: 2399

Did you update your build.gradle as well?

sample:

android {
    compileSdkVersion 24 // this is important
    buildToolsVersion "24" // this also

    defaultConfig {
        applicationId "org.bamboomy.yarne"
        minSdkVersion 15
        targetSdkVersion 24 // recommended
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:24.0.0' // and don't forget this
    compile 'com.android.support:design:24.0.0' // and this
}

I'm not an expert but it seems that in the

C:\Users\myusername\AppData\Local\Android\sdk\build-tools\23.0.2

dir there is no dx.jar (only a dx.bat)

and beginning from 23.0.3 there seems to be a

C:\Users\myusername\AppData\Local\Android\sdk\build-tools\23.0.3\lib

folder with a dx.jar present

Upvotes: 3

Urja Pawar
Urja Pawar

Reputation: 1085

Deleting sdk platform tools and build tools and reinstalling them worked for me.

Upvotes: 1

Amit Vaghela
Amit Vaghela

Reputation: 22965

add this to your build.gradle

android {
...
defaultConfig {
    ...
    multiDexEnabled true
    }
}

check this asnwer too

Upvotes: -1

Related Questions