简体   繁体   中英

':app:dexDebug'. gradle failed 'C:\Program Files\Java\jdk1.7.0_51\bin\java.exe'' finished with non-zero exit value 2

Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException:         org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_51\bin\java.exe'' finished with non-zero exit value 2


    apply plugin: 'com.android.application'

    android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.example.zumoappname"
        minSdkVersion 10
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        //multiDexEnabled true
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }


    repositories {
        flatDir {
            dirs 'aars'
        }   
     }
  }

  dependencies { 
           compile fileTree(dir: 'libs', include: ['*.jar']) 
           compile 'com.microsoft.azure:azure-notifications-handler:1.0.1@jar' 
           compile 'com.google.code.gson:gson:2.3' 
           compile 'com.google.guava:guava:18.0' 
           compile 'com.microsoft.azure:azure-mobile-services-android-sdk:2.0.3' 
           compile 'com.google.android.gms:play-services:8.3.0'
           compile 'com.android.support:appcompat-v7:23.1.1' 
  }

I can compile and run if I don't use 'com.google.android.gms:play- services:8.3.0', but that defeats the purpose of my app. Tried multidexenabled. Tried clean and rebuild. Any advice would be appreciated?

The problem is your method count has exceed from 65K. Here is the solution of your problem.

Step:1 enable multidex support

defaultConfig {
        ...
        multiDexEnabled true
    }

Step:2 Add These 2 lines

 dependencies {
        ...
        compile 'com.google.android.gms:play-services-location:8.3.0'
        compile 'com.android.support:multidex:1.0.0'
    }

Step:3(a) Change in manifest

 <application
        ...
        android:name="android.support.multidex.MultiDexApplication">
        ...
    </application>

Step:3(b) If you have your own custom Application class then initialize MultiDex like this.

public class YouApplication extends Application {

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

Could you please check if you have play-services version 8.3.0 in android-sdk/extras/google/m2repository/com/google/android/gms/play-services/8.3.0 . If not, downloading it might fix the issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM