2

I have got an error when I tried to run project in Studio 2.3

FAILURE: Build failed with an exception.

Execution failed for task ':app:transformClassesWithDexForDebug'. com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: Unable to pre-dex 'C:\Users\xxxxx.android\build-cache\398355577ef004d4acd9193504f7c3a1515a7b74\output\jars\classes.jar' to 'C:\Users\xxxxx\Desktop\yyyyyy\build\intermediates\transforms\dex\debug\folders\1000\10\classes_e69b3e5768928e64d7b1ee699d266a32be93412d'

I have tried below steps but still the same 1) Clean and Rebuild 2) Restart Android studio by selecting "Invalidate caches and restart" 3) Also restart laptop

Here is my app module build.gradle file

apply plugin: 'com.android.application'
android {
     compileSdkVersion 25
     buildToolsVersion '25.0.1'

dexOptions {
    preDexLibraries false
    javaMaxHeapSize "2g" // Use gig increments depending on needs
    incremental true
}

defaultConfig {
    applicationId "com.test.example"
    minSdkVersion 14
    targetSdkVersion 24
    multiDexEnabled true
    testInstrumentationRunner 
    'android.support.test.runner.AndroidJUnitRunner'
}

lintOptions {
    disable 'NamespaceTypo'
    enable 'MissingTranslation'
    abortOnError false
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 
       'proguard-rules.txt'
    }
}

sourceSets {
    main {
        manifest.srcFile 'AndroidManifest.xml'
        java.srcDirs = ['src']
        resources.srcDirs = ['src']
        aidl.srcDirs = ['src']
        renderscript.srcDirs = ['src']
        res.srcDirs = ['res']
        assets.srcDirs = ['assets']
        jniLibs.srcDirs = ['libs']
    }

    instrumentTest.setRoot('tests')
    debug.setRoot('build-types/debug')

}

packagingOptions {
    exclude 'META-INF/BCKEY.DSA'
    exclude 'META-INF/BCKEY.SF'
}

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_7
    targetCompatibility JavaVersion.VERSION_1_7
}

}

dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.android.support:support-v4:24.1.1'
compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.android.support:design:24.1.1'
compile 'com.android.support:preference-v7:24.1.1'
compile 'com.android.support:preference-v14:24.1.1'
compile 'com.google.http-client:google-http-client-android:1.20.0'
compile 'com.google.api-client:google-api-client-android:1.20.0'
compile 'com.google.api-client:google-api-client-gson:1.22.0'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.mcxiaoke.volley:library-aar:1.0.0'
compile 'com.makeramen:roundedimageview:2.2.0'
compile 'me.leolin:ShortcutBadger:1.1.4@aar'
compile 'org.whispersystems:axolotl-android:1.3.4'
compile 'org.bouncycastle:bcprov-jdk15on:1.52'
compile 'org.bouncycastle:bcmail-jdk15on:1.52'
compile 'org.jitsi:org.otr4j:0.22'
compile 'org.sufficientlysecure:openpgp-api:10.0'
compile 'com.soundcloud.android:android-crop:1.0.1@aar'
compile 'org.gnu.inet:libidn:1.15'
compile 'com.google.zxing:core:3.2.1'
compile 'com.google.zxing:android-integration:3.2.1'
compile 'de.measite.minidns:minidns:0.1.7'
compile 'de.timroes.android:EnhancedListView:0.3.4'
compile ('com.google.android.gms:play-services-gcm:9.0.1')
compile ('com.android.support:support-v13:23.2.1')
compile 'com.android.support:multidex:1.0.1'
}

apply plugin: 'com.google.gms.google-services'

And Here below is my main build.gradle file

buildscript {
repositories {
    jcenter()
    mavenCentral()
}
dependencies {
    classpath 'com.android.tools.build:gradle:2.3.0'
    classpath 'com.google.gms:google-services:3.0.0'
}
allprojects {
    repositories {
        jcenter()
        mavenCentral()
    }
}
}
Himadri
  • 187
  • 2
  • 3
  • 13

2 Answers2

1

I have resolved that problem. Due to memory size issue I was getting that error and Increasing ram had resolved my issue

Himadri
  • 187
  • 2
  • 3
  • 13
  • Hi @Himadri - can you share you ram config, before and after ? – Deep Jun 08 '18 at 14:23
  • @deep, Earlier ram configuration was 4gb and currently it is 8gb – Himadri Jun 12 '18 at 09:47
  • 4
    This has nothing to with RAM. I am using 16GB RAM system. Don't post just anything. – Veer Shrivastav Sep 10 '18 at 11:14
  • actually what @Himadri claimed seemed to be the issue for me as well. my CPU usage was at a 100% while building the project. i ended up killing all processes except for android studio and tried building the project about 2-3 more times and finally the build was successful. strange... – mouserat May 06 '19 at 10:26
  • I experienced similar issue. Closing all other programs and building again worked for me. btw, I'm having 12 GB Ram – Akhil Sekharan Oct 17 '19 at 18:49
0

i already solved it it happen because you didnt setting the default java in android studio 2.3.3 or android studio 3.0 beta 6

  1. go to file > project structure > SDK location
  2. change the JDK Location to C:\Program Files\Java\jdk1.8.0_131 enter image description here
reza rahmad
  • 1,009
  • 10
  • 16