問題描述
錯(cuò)誤
錯(cuò)誤:任務(wù) ':app:transformClassesWithDexForDebug' 執(zhí)行失敗.com.android.build.transform.api.TransformException:com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException:進(jìn)程'命令'/usr/lib/jvm/java-8-oracle/bin/java'' 以非零退出值 1 結(jié)束
Error:Execution failed for task ':app:transformClassesWithDexForDebug'. com.android.build.transform.api.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-8-oracle/bin/java'' finished with non-zero exit value 1
我的應(yīng)用 gradle 文件:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId 'Hidden application ID'
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
disable 'InvalidPackage'
}
packagingOptions {
exclude 'META-INF/services/javax.annotation.processing.Processor'
}
productFlavors {
}
}
repositories {
mavenCentral()
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.mcxiaoke.volley:library-aar:1.0.0'
compile 'com.google.android.gms:play-services:8.1.0'
compile 'com.facebook.android:facebook-android-sdk:4.7.0'
compile 'com.googlecode.libphonenumber:libphonenumber:7.2.1'
compile 'com.getbase:floatingactionbutton:1.10.1'
compile 'com.android.support:preference-v7:23.1.1'
}
在調(diào)試時(shí),如果我將 minifyEnabled 設(shè)置為 true,那么它會(huì)編譯.但是,我無法調(diào)試我的應(yīng)用程序.
While debugging, if I set minifyEnabled to true, then it compiles. However, then I cannot debug my application.
我檢查了另一個(gè)問題:任務(wù)執(zhí)行失敗:app:transformClassesWithDexForDebug' 在為 Android 實(shí)施 Google 登錄時(shí),但只有一個(gè)答案,不幸的是,實(shí)施它并不能解決問題.
I checked this other question: Execution failed for task ':app:transformClassesWithDexForDebug' while implementing Google sign in for Android, but there is only one answer and implementing it does not resolve the issue unfortunately.
AFAIK,錯(cuò)誤是由于添加了太多 Gradle 依賴項(xiàng)引起的,但我可能錯(cuò)了(我真的希望是錯(cuò)的,因?yàn)樗羞@些包都非常重要!).
AFAIK, the error is caused due to addition of too many Gradle dependencies, but I may be wrong (I really hope to be wrong because all these packages are really important!).
請(qǐng)幫我解決這個(gè)錯(cuò)誤.非常感謝!
Please help me to resolve this error. Much thanks!
推薦答案
只需更正 Google play 服務(wù)依賴項(xiàng):
Just correct Google play services dependencies:
您的項(xiàng)目中包含所有播放服務(wù).只添加你想要的.
You are including all play services in your project. Only add those you want.
例如,如果您只使用地圖和 g+ 登錄,則更改
For example , if you are using only maps and g+ signin, than change
compile 'com.google.android.gms:play-services:8.1.0'
到
compile 'com.google.android.gms:play-services-maps:8.1.0'
compile 'com.google.android.gms:play-services-plus:8.1.0'
來自文檔:
在 6.5 之前的 Google Play 服務(wù)版本中,您必須編譯整個(gè) API 包到您的應(yīng)用程序中.在某些情況下,這樣做會(huì)使在您的應(yīng)用程序中保持方法的數(shù)量變得更加困難(包括65,536 下的框架 API、庫方法和您自己的代碼)限制.
In versions of Google Play services prior to 6.5, you had to compile the entire package of APIs into your app. In some cases, doing so made it more difficult to keep the number of methods in your app (including framework APIs, library methods, and your own code) under the 65,536 limit.
從 6.5 版開始,您可以選擇性地編譯 Google Play服務(wù) API 到您的應(yīng)用程序中.例如,僅包含 GoogleFit 和 Android Wear API,在您的build.gradle 文件:
使用這些行編譯 'com.google.android.gms:play-services:8.3.0'
:
From version 6.5, you can instead selectively compile Google Play
service APIs into your app. For example, to include only the Google
Fit and Android Wear APIs, replace the following line in your
build.gradle file:
compile 'com.google.android.gms:play-services:8.3.0'
with these lines:
編譯'com.google.android.gms:play-services-fitness:8.3.0'
編譯'com.google.android.gms:play-services-wearable:8.3.0'
compile 'com.google.android.gms:play-services-fitness:8.3.0'
compile 'com.google.android.gms:play-services-wearable:8.3.0'
可在此處找到完整列表.
這篇關(guān)于錯(cuò)誤:任務(wù)“:app:transformClassesWithDexForDebug"執(zhí)行失敗的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!