将Android Studio更新为3.0版后,我遇到了麻烦。首先Gradle显示以下错误:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
我做了以下行动:
1)构建 - >清洁项目
2)构建 - >重建项目
3)从我的项目中删除.gradle文件夹
4)文件 - >使高速缓存无效/重新启动...
以下所有行动对我都没有帮助。
我做的下一步行动:
4)将"multiDexEnabled true"
和"compile 'com.android.support:multidex:1.0.0'"
添加到build.gradle文件。
5)将"android:name="android.support.multidex.MultiDexApplication" "
添加到清单文件。
目前我可以看到以下错误:
Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
> java.io.IOException: Can't write [D:\KamitoSoft\MEforYOU\Program Kod\039MEforYOU\app\build\intermediates\multi-dex\debug\componentClasses.jar] (Can't read [C:\Users\Krzysztof Kamiński\.gradle\caches\modules-2\files-2.1\com.google.guava\guava-jdk5\17.0\463f8378feba44df7ba7cd9272d01837dad62b36\guava-jdk5-17.0.jar(;;;;;;**.class)] (Duplicate zip entry [guava-jdk5-17.0.jar:com/google/common/annotations/Beta.class]))
* Try:
Run with --info or --debug option to get more log output.
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:63)
at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88)
at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:124)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:80)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:105)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:99)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:625)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:580)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:99)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
Caused by: java.lang.RuntimeException: java.io.IOException: Can't write [D:\KamitoSoft\MEforYOU\Program Kod\039MEforYOU\app\build\intermediates\multi-dex\debug\componentClasses.jar] (Can't read [C:\Users\Krzysztof Kamiński\.gradle\caches\modules-2\files-2.1\com.google.guava\guava-jdk5\17.0\463f8378feba44df7ba7cd9272d01837dad62b36\guava-jdk5-17.0.jar(;;;;;;**.class)] (Duplicate zip entry [guava-jdk5-17.0.jar:com/google/common/annotations/Beta.class]))
at com.android.builder.profile.Recorder$Block.handleException(Recorder.java:55)
at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:104)
at com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:213)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$IncrementalTaskAction.doExecute(DefaultTaskClassInfoStore.java:173)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:121)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:122)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:111)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
... 27 more
Caused by: java.io.IOException: Can't write [D:\KamitoSoft\MEforYOU\Program Kod\039MEforYOU\app\build\intermediates\multi-dex\debug\componentClasses.jar] (Can't read [C:\Users\Krzysztof Kamiński\.gradle\caches\modules-2\files-2.1\com.google.guava\guava-jdk5\17.0\463f8378feba44df7ba7cd9272d01837dad62b36\guava-jdk5-17.0.jar(;;;;;;**.class)] (Duplicate zip entry [guava-jdk5-17.0.jar:com/google/common/annotations/Beta.class]))
at proguard.OutputWriter.writeOutput(OutputWriter.java:187)
at proguard.OutputWriter.execute(OutputWriter.java:79)
at proguard.ProGuard.writeOutput(ProGuard.java:427)
at proguard.ProGuard.execute(ProGuard.java:175)
at com.android.build.gradle.internal.transforms.BaseProguardAction.runProguard(BaseProguardAction.java:61)
at com.android.build.gradle.internal.transforms.MainDexListTransform.shrinkWithProguard(MainDexListTransform.java:232)
at com.android.build.gradle.internal.transforms.MainDexListTransform.transform(MainDexListTransform.java:184)
at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:222)
at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:218)
at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:102)
... 39 more
Caused by: java.io.IOException: Can't read [C:\Users\Krzysztof Kamiński\.gradle\caches\modules-2\files-2.1\com.google.guava\guava-jdk5\17.0\463f8378feba44df7ba7cd9272d01837dad62b36\guava-jdk5-17.0.jar(;;;;;;**.class)] (Duplicate zip entry [guava-jdk5-17.0.jar:com/google/common/annotations/Beta.class])
at proguard.InputReader.readInput(InputReader.java:188)
at proguard.InputReader.readInput(InputReader.java:158)
at proguard.OutputWriter.writeOutput(OutputWriter.java:176)
... 48 more
Caused by: java.io.IOException: Duplicate zip entry [guava-jdk5-17.0.jar:com/google/common/annotations/Beta.class]
at proguard.io.JarWriter.getOutputStream(JarWriter.java:138)
at proguard.io.FilteredDataEntryWriter.getOutputStream(FilteredDataEntryWriter.java:106)
at proguard.io.FilteredDataEntryWriter.getOutputStream(FilteredDataEntryWriter.java:106)
at proguard.io.FilteredDataEntryWriter.getOutputStream(FilteredDataEntryWriter.java:92)
at proguard.io.ClassRewriter.read(ClassRewriter.java:68)
at proguard.io.FilteredDataEntryReader.read(FilteredDataEntryReader.java:87)
at proguard.io.FilteredDataEntryReader.read(FilteredDataEntryReader.java:87)
at proguard.io.FilteredDataEntryReader.read(FilteredDataEntryReader.java:87)
at proguard.io.JarReader.read(JarReader.java:65)
at proguard.io.DirectoryPump.readFiles(DirectoryPump.java:65)
at proguard.io.DirectoryPump.pumpDataEntries(DirectoryPump.java:53)
at proguard.InputReader.readInput(InputReader.java:184)
... 50 more
我在build.gradle文件中找不到guava实现。 我的build.gradle文件看起来像这样:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
//buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.kamitosoft.meforyou"
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
// Enabling multidex support.
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
//implementation ('me.dlkanth:stetho-volley:1.0') {
//exclude group: 'org.apache.httpcomponents'
//}
compile 'com.android.support:multidex:1.0.0'
compile fileTree(include: ['*.jar'], dir: 'libs')
/*androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})*/
compile files('libs/mariadb-java-client-1.5.7.jar')
//compile 'com.android.support:appcompat-v7:25.1.0'
//compile 'com.google.android.gms:play-services-auth:9.2.1'
//testCompile 'junit:junit:4.12'
compile('com.google.api-client:google-api-client-android:1.22.0') {
exclude group: 'org.apache.httpcomponents'
}
/*
compile('com.google.apis:google-api-services-gmail:v1-rev62-1.22.0') {
exclude group: 'org.apache.httpcomponents'
}
*/
compile files('libs/YouTubeAndroidPlayerApi.jar')
compile files('libs/cwac-merge-1.1.2.jar')
compile 'org.apmem.tools:layouts:1.10@aar'
compile 'com.android.support:design:25.4.0'
//compile 'com.google.firebase:firebase-appindexing:11.4.2'
compile 'com.google.android.gms:play-services-appindexing:9.2.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:appcompat-v7:25.4.0'
compile 'com.google.android.gms:play-services-auth:9.2.1'
compile 'pub.devrel:easypermissions:0.2.1'
compile 'com.google.apis:google-api-services-youtube:v3-rev182-1.22.0'
compile 'com.google.gdata:core:1.47.1'
}
apply plugin: 'com.google.gms.google-services'
您可以在我的帖子中找到的当前错误如下:
Duplicate zip entry [guava-jdk5-17.0.jar:com/google/common/annotations/Beta.class])
错误是由Beta.class
生成的,我应该通过排除guava
文件中build.gradle
的所有出现来解决它。
例如:
compile ('...........................') {
exclude group: 'com.google.guava'
}
我通过使用" Control + N"找到Beta.class
android studio中的键盘快捷键(查找类)。使用此选项后,我可以看到:
我在build.gradle文件中找不到com.google.common.annotations
。我应该在哪里使用番石榴排除选项?
谢谢
答案 0 :(得分:1)
我可以通过在guava
中用api
声明build.gradle
来解决此问题:
dependencies {
api 'com.google.guava:guava:27.0.1-android'
}
使用compile
或implementation
时失败,并显示上述错误。
答案 1 :(得分:0)
我通过com.google.gdata排除了guana解决了问题:核心:1.47.1。 如果你不知道应该在哪里使用guana排除功能,你应该逐个尝试。
compile ('com.google.gdata:core:1.47.1')
{
exclude group: 'com.google.guava'
}