在Android工作室获取app:dexDebug错误

时间:2015-10-20 06:26:31

标签: android android-studio gradle

这是我在应用程序中使用的完整app.gradle文件

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "23.0.0 rc2"
    defaultConfig {
        applicationId "com.me.album"
        minSdkVersion 14
        targetSdkVersion 22
        versionCode 4
        versionName
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
    }

    lintOptions {
        checkReleaseBuilds false
    }

}
dependencies {
    compile 'com.android.support:appcompat-v7:22.2.0'
    compile 'com.google.code.gson:gson:2.3.1'
    compile 'com.nineoldandroids:library:2.4.0'
    compile project('libraries:library')
    compile project('libraries:animation_library')
    compile 'de.hdodenhof:circleimageview:1.3.0'
    compile 'com.android.support:recyclerview-v7:22.2.0'
    compile 'com.pnikosis:materialish-progress:1.5'
    compile files('libs/activation.jar')
    compile files('libs/additionnal.jar')
    compile files('libs/crittercism_v5_0_6_sdkonly.jar')
    compile files('libs/httpcore-4.3.3.jar')
    compile files('libs/httpmime-4.3.6.jar')
    compile files('libs/mail.jar')
    compile files('libs/mpandroidchartlibrary-2-1-5.jar')
    compile 'com.facebook.android:facebook-android-sdk:4.5.0'
    compile project(':app:libraries:ExpandableLibrary')
    compile project(':app:libraries:library_appintro')
    compile project(':app:libraries:library_circular_loading:library')
    compile 'com.google.android.gms:play-services-maps:6.5.87'
    compile project(path: ':Push Notification', configuration: 'android-endpoints')
}

并始终收到错误

Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/bin/java'' finished with non-zero exit value 2

2 个答案:

答案 0 :(得分:1)

在默认配置中添加:

defaultConfig{
                multiDexEnabled = true
            }

在同一个build.gradle中添加:

dexOptions {
    javaMaxHeapSize "4g"
}

在依赖项中添加:

 dependencies
{
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:multidex:1.0.0'
}

这可能会帮助你!

答案 1 :(得分:0)

最后我得到了解决方案, 它已在Android WEbLineindia的答案中描述,但需要一些附加组件。

defaultConfig {
        applicationId "com.me.album"
        minSdkVersion 14
        targetSdkVersion 22
        versionCode 5
        versionName "1.5"
        multiDexEnabled true
    }

和依赖

// highest version available
compile 'com.android.support:multidex:1.0.1'

并在您的应用程序类中

 @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }