':应用程序:dexDebug'。 gradle 失败 'C:\Program Files\Java\jdk1.7.0_51\bin\java.exe'' 以非零退出值 2 完成
':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'
}
如果我不使用 'com.google.android.gms:play- services:8.3.0',我可以编译和 运行,但这违背了我的应用程序的目的。尝试了 multidexenabled。尝试清理和重建。任何建议将不胜感激?
问题是您的方法数已超过 65K。
这是您问题的解决方案。
步骤:1 启用 multidex 支持
defaultConfig {
...
multiDexEnabled true
}
步骤:2 添加这两行
dependencies {
...
compile 'com.google.android.gms:play-services-location:8.3.0'
compile 'com.android.support:multidex:1.0.0'
}
步骤:3(a) 清单更改
<application
...
android:name="android.support.multidex.MultiDexApplication">
...
</application>
步骤:3(b) 如果您有自己的自定义应用程序 class 然后像这样初始化 MultiDex。
public class YouApplication extends Application {
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
请检查一下 android-sdk/extras/google/m2repository/com/google/android/gms/play-services/8.3.0
中是否有 8.3.0 版的播放服务。如果没有,下载它可能会解决问题。
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'
}
如果我不使用 'com.google.android.gms:play- services:8.3.0',我可以编译和 运行,但这违背了我的应用程序的目的。尝试了 multidexenabled。尝试清理和重建。任何建议将不胜感激?
问题是您的方法数已超过 65K。 这是您问题的解决方案。
步骤:1 启用 multidex 支持
defaultConfig {
...
multiDexEnabled true
}
步骤:2 添加这两行
dependencies {
...
compile 'com.google.android.gms:play-services-location:8.3.0'
compile 'com.android.support:multidex:1.0.0'
}
步骤:3(a) 清单更改
<application
...
android:name="android.support.multidex.MultiDexApplication">
...
</application>
步骤:3(b) 如果您有自己的自定义应用程序 class 然后像这样初始化 MultiDex。
public class YouApplication extends Application {
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
请检查一下 android-sdk/extras/google/m2repository/com/google/android/gms/play-services/8.3.0
中是否有 8.3.0 版的播放服务。如果没有,下载它可能会解决问题。