Android Studio——Error:non-zero exit value 1

  在Android Studio上运行代码遇到错误Error:Execution failed for task ':app:transformClassesWithDexForDebug'.> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'D:\Program Files (x86)\Java\jdk1.7.0_67\bin\java.exe'' finished with non-zero exit value 1


  解决方法:在build.Gradle中加入如下代码:

  

  dexOptions {
      javaMaxHeapSize "4g"
      preDexLibraries = false
  }




例如我的build.Gradle内容如下:
  
apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "com.example.yk.myapplication"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

        dexOptions {
            javaMaxHeapSize "4g"
            preDexLibraries = false
        }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
}



你可能感兴趣的:(移动开发)