程序类型已经存在:android.support.v4.media.MediaMetadataCompat $ Builder

时间:2019-03-03 15:27:55

标签: android android-gradle android-build android-gradle-3.0

长时间打开android studio项目后,它开始出现以下错误:

Program type already present: android.support.v4.media.MediaMetadataCompat$Builder

我不知道该怎么办。同时,我已经将Android Studio从2.2升级到了3.3.1。

我在StackOverflow上看到了许多相关问题,但这些问题都没有帮助我。

项目级别build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath 'org.greenrobot:greendao-gradle-plugin:3.2.2' // add plugin

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url 'https://jitpack.io' }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

应用程序级别build.gradle

apply plugin: 'com.android.application'
apply plugin: 'org.greenrobot.greendao' // apply plugin

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.something"
        minSdkVersion 19
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.weiwangcn.betterspinner:library-material:1.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.github.thomper:sweet-alert-dialog:v1.4.0'
    implementation 'com.scwang.wave:MultiWaveHeader:1.0.0-alpha-1'
    implementation 'com.github.tylersuehr7:android-object-mapper:1.4'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'org.greenrobot:greendao:3.2.2'
}

完整日志

org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:103)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:73)
    at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:59)
    at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:59)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:101)
    at org.gradle.api.internal.tasks.execution.FinalizeInputFilePropertiesTaskExecuter.execute(FinalizeInputFilePropertiesTaskExecuter.java:44)
    at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:91)
    at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:62)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:59)
    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:256)
    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:199)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:249)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:238)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:663)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:597)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
    at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\0.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\1.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\2.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\3.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\4.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\5.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\6.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\7.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\8.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\9.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\10.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\11.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\12.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\13.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\14.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\15.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\16.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\17.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\18.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\19.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\20.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\21.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\22.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\23.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\24.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\25.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\26.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\27.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\28.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\29.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\30.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\31.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\32.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\33.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\34.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\35.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\36.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\37.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\38.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\39.jar
Program type already present: android.support.v4.media.MediaMetadataCompat$Builder
Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
    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:230)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
    at org.gradle.api.internal.project.taskfactory.IncrementalTaskAction.doExecute(IncrementalTaskAction.java:50)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:124)
    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:199)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:113)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:95)
    ... 33 more
Caused by: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\0.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\1.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\2.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\3.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\4.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\5.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\6.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\7.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\8.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\9.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\10.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\11.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\12.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\13.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\14.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\15.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\16.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\17.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\18.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\19.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\20.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\21.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\22.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\23.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\24.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\25.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\26.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\27.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\28.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\29.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\30.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\31.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\32.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\33.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\34.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\35.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\36.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\37.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\38.jar, D:\git\Pomodoro\android\app\build\intermediates\transforms\dexBuilder\debug\39.jar
Program type already present: android.support.v4.media.MediaMetadataCompat$Builder
Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
    at com.android.builder.dexing.D8DexArchiveMerger.getExceptionToRethrow(D8DexArchiveMerger.java:132)
    at com.android.builder.dexing.D8DexArchiveMerger.mergeDexArchives(D8DexArchiveMerger.java:117)
    at com.android.build.gradle.internal.transforms.DexMergerTransformCallable.call(DexMergerTransformCallable.java:101)
    at com.android.build.gradle.internal.transforms.ExternalLibsMergerTransform.transform(ExternalLibsMergerTransform.kt:122)
    at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:239)
    at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:235)
    at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:102)
    ... 49 more
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete
    at com.android.tools.r8.utils.ExceptionUtils.withCompilationHandler(ExceptionUtils.java:65)
    at com.android.tools.r8.utils.ExceptionUtils.withD8CompilationHandler(ExceptionUtils.java:43)
    at com.android.tools.r8.D8.run(D8.java:90)
    at com.android.builder.dexing.D8DexArchiveMerger.mergeDexArchives(D8DexArchiveMerger.java:115)
    ... 54 more
Caused by: com.android.tools.r8.utils.AbortException: Error: Program type already present: android.support.v4.media.MediaMetadataCompat$Builder
    at com.android.tools.r8.utils.Reporter.failIfPendingErrors(Reporter.java:116)
    at com.android.tools.r8.utils.Reporter.fatalError(Reporter.java:74)
    at com.android.tools.r8.utils.ExceptionUtils.withCompilationHandler(ExceptionUtils.java:59)
    ... 57 more

希望我会得到一些帮助。

0 个答案:

没有答案