AndroidスタジオでAndroidアプリを開発しています。Androidスタジオグレードでは、重複したエントリ:com/google/android/gms/ads/AdActivity.class
私はGoogle Playサービスを使用していますが、Android搭載端末でアプリケーションを実行すると、次のエラーが発生します。
build.gradle
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "net.myApp"
minSdkVersion 14
targetSdkVersion 21
multiDexEnabled true
}
packagingOptions{
exclude 'com/google/android/gms/ads/AdActivity'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile project(':facebookSDK')
compile 'com.jpardogo.materialtabstrip:library:1.1.0'
compile 'com.android.support:support-v4:23.4.0'
compile 'joda-time:joda-time:2.1'
compile files('libs/google-play-services.jar')
compile files('libs/twitter4j-core-4.0.2.jar')
android {
useLibrary 'org.apache.http.legacy'
}
}
エラー
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':myApp:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/ads/AdActivity.class
* Try:
Run with --info or --debug option to get more log output.
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':myApp:transformClassesWithJarMergingForDebug'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.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:53)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:203)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:185)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:66)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:50)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
Caused by: java.lang.RuntimeException: com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/ads/AdActivity.class
at com.android.builder.profile.Recorder$Block.handleException(Recorder.java:54)
at com.android.builder.profile.ThreadRecorder$1.record(ThreadRecorder.java:57)
at com.android.builder.profile.ThreadRecorder$1.record(ThreadRecorder.java:47)
at com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:173)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.doExecute(AnnotationProcessingTaskFactory.java:244)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:220)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.execute(AnnotationProcessingTaskFactory.java:231)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:209)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
... 14 more
Caused by: com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/ads/AdActivity.class
at com.android.build.gradle.internal.transforms.JarMergingTransform.transform(JarMergingTransform.java:117)
at com.android.build.gradle.internal.pipeline.TransformTask$3.call(TransformTask.java:178)
at com.android.build.gradle.internal.pipeline.TransformTask$3.call(TransformTask.java:174)
at com.android.builder.profile.ThreadRecorder$1.record(ThreadRecorder.java:55)
... 23 more
Caused by: java.util.zip.ZipException: duplicate entry: com/google/android/gms/ads/AdActivity.class
at com.android.build.gradle.internal.transforms.JarMerger.addJar(JarMerger.java:161)
at com.android.build.gradle.internal.transforms.JarMerger.addJar(JarMerger.java:121)
at com.android.build.gradle.internal.transforms.JarMergingTransform.transform(JarMergingTransform.java:107)
... 26 more
enter code here
私は、COM//アンドロイド/ GMS /広告をグーグル/ AdActivity.classが重複している理由はわかりません。
この問題を解決する方法を教えてください。
通常、この種の問題は、プロジェクトで './gradlew clean'を実行するか、キャッシュを無効にしてAndroid Studioを再起動することで解決します。これが機能しない場合は、複製されたクラスを手動で削除することができます。また、これらのエラーが発生することがあるため、プロジェクトで使用するプレイサービスライブラリに同じバージョンが含まれていることを確認してください。詳細は、関連するSOの質問[33487780](http://stackoverflow.com/questions/33487780/jar-merging-for-debug-throwing-duplicate-entry-with-android)を参照してください。 – KENdi