运行时异常:无法找到 pre-dex

Runtime Exeception :Unable to find pre-dex

我在 Studio 2.3运行 中尝试 运行 项目时出现错误

失败:构建失败,出现异常。

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-cache8355577ef004d4acd9193504f7c3a1515a7b74\output\jars\classes.jar' to 'C:\Users\xxxxx\Desktop\yyyyyy\build\intermediates\transforms\dex\debug\folders00\classes_e69b3e5768928e64d7b1ee699d266a32be93412d'

我已经尝试了以下步骤,但还是一样 1)清理和重建 2) 选择 "Invalidate caches and restart" 重新启动 Android 工作室 3) 同时重启笔记本电脑

这是我的应用模块build.gradle文件

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'

下面是我的主要 build.gradle 文件

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()
    }
}
}

我已经解决了这个问题。 由于内存大小问题,我收到了该错误,增加 ram 解决了我的问题

我已经解决了,因为你没有在 android studio 2.3.3 或 android studio 3.0 beta 6

中设置默认 java
  1. 转到文件 > 项目结构 > SDK 位置
  2. 将 JDK 位置更改为 C:\Program Files\Java\jdk1.8.0_131