运行时执行:无法找到pre-dex

时间:2017-05-14 12:48:26

标签: android android-studio android-studio-2.3

我尝试在Studio 2.3中运行项目时遇到错误

失败:构建因异常而失败。

  

任务':app:transformClassesWithDexForDebug'执行失败。   com.android.build.api.transform.TransformException:java.lang.RuntimeException:java.lang.RuntimeException:无法预先解释' C:\ Users \ xxxxx.android \ build-cache \ 398355577ef004d4acd9193504f7c3a1515a7b74 \ output \罐子\ classes.jar'到' C:\ Users \ xxxxx \ Desktop \ yyyyyy \ build \ intermediates \ transforms \ dex \ debug \ folders \ 1000 \ 10 \ classes_e69b3e5768928e64d7b1ee699d266a32be93412d'

我尝试过以下步骤但仍然相同 1)清洁和重建 2)通过选择"使高速缓存无效并重新启动"重新启动Android工作室 3)还重启笔记本电脑

这是我的app模块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()
    }
}
}

2 个答案:

答案 0 :(得分:0)

我已经解决了这个问题。 由于内存大小问题我得到了这个错误,而且ram已经解决了我的问题

答案 1 :(得分:0)

我已经解决了它,因为你没有在android studio 2.3.3或android studio 3.0 beta 6中设置默认java

  1. 转到文件>项目结构> SDK位置
  2. 将JDK位置更改为C:\ Program Files \ Java \ jdk1.8.0_131 enter image description here