問題描述
錯誤
錯誤:任務 ':app:transformClassesWithDexForDebug' 執行失敗.com.android.build.transform.api.TransformException:com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException:進程'命令'/usr/lib/jvm/java-8-oracle/bin/java'' 以非零退出值 1 結束
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
我的應用 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'
}
在調試時,如果我將 minifyEnabled 設置為 true,那么它會編譯.但是,我無法調試我的應用程序.
While debugging, if I set minifyEnabled to true, then it compiles. However, then I cannot debug my application.
我檢查了另一個問題:任務執行失敗:app:transformClassesWithDexForDebug' 在為 Android 實施 Google 登錄時,但只有一個答案,不幸的是,實施它并不能解決問題.
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,錯誤是由于添加了太多 Gradle 依賴項引起的,但我可能錯了(我真的希望是錯的,因為所有這些包都非常重要!).
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!).
請幫我解決這個錯誤.非常感謝!
Please help me to resolve this error. Much thanks!
推薦答案
只需更正 Google play 服務依賴項:
Just correct Google play services dependencies:
您的項目中包含所有播放服務.只添加你想要的.
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 服務版本中,您必須編譯整個 API 包到您的應用程序中.在某些情況下,這樣做會使在您的應用程序中保持方法的數量變得更加困難(包括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服務 API 到您的應用程序中.例如,僅包含 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'
可在此處找到完整列表.
這篇關于錯誤:任務“:app:transformClassesWithDexForDebug"執行失敗的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!