Gradle Build失败并出现exception:java.exe’以非零退出值2结束
build.gradle文件:
android { compileSdkVersion 22 buildToolsVersion "22.0.1" defaultConfig { applicationId "xxxxx.com.myapp" minSdkVersion 9 targetSdkVersion 22 versionCode 3 versionName "1.2" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:22.1.1' compile 'com.google.android.gms:play-services-ads:7.3.0' compile files('libs/libGoogleAnalyticsServices.jar') }
错误日志:
FAILURE:构建因exception而失败。
- 出了什么问题:任务’:app:dexDebug’执行失败。
com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException:进程’命令’C:\ Program Files \ Java \ jdk1.7.0_51 \ bin \ java.exe”以非完成零退出值2
尝试从依赖项中删除以下内容:
compile fileTree(dir: 'libs', include: ['*.jar']) compile files('libs/libGoogleAnalyticsServices.jar')
如果您查看此处 ,Google Analytics竞争服务已经内置了Google Analytics,因此两者存在冲突。
有时,由于multidex问题,此构建失败错误。 根据您的构建脚本,您似乎不需要使用multidex启用。 但是你仍然可以尝试这个,因为我不能多说只看到你的gradle构建脚本。使用
defaultConfig { applicationId "xxxxx.com.myapp" minSdkVersion 9 targetSdkVersion 22 versionCode 3 versionName "1.2" // enable Mutidex. multiDexEnabled true }
您将包括两次libGoogleAnalyticsServices.jar
。 基于路径,它将包含以下行(包括libs
目录中的所有jar) –
compile fileTree(dir: 'libs', include: ['*.jar'])
删除此行以避免包含两次lib –
compile files('libs/libGoogleAnalyticsServices.jar')