无法在我的项目中合并dex

时间:2018-03-25 08:46:21

标签: android android-studio gradle merge dex

突然没有对我的项目进行任何更改,我收到以下错误:

错误:任务执行失败':app:transformDexArchiveWithExternalLibsDexMergerForDebug'。

  

java.lang.RuntimeException:com.android.builder.dexing.DexArchiveMergerException:无法合并dex

我尝试过以下各个解决方案:

  1. Post 1
  2. Post 2
  3. 他们都没有奏效。 我还将项目的build.gradle中的所有“compile”命令更改为“implementation”。没有用。

    这是我的app.gradle:

    apply plugin: 'com.android.application'
    android
        {
            compileSdkVersion 27
            buildToolsVersion '27.0.3'
            defaultConfig
                    {
                        applicationId "com.parsdigit.helsa"
                        manifestPlaceholders = [onesignal_app_id               : "4af7b2c1-a1a8-4b4a-ade3-d65289b38267",
                                                // Project number pulled from dashboard, local value is ignored.
                                                onesignal_google_project_number: "REMOTE"]
                        minSdkVersion 21
                        targetSdkVersion 27
                        versionCode 1
                        versionName "1.0"
                        vectorDrawables.useSupportLibrary = true
                        multiDexEnabled true
                    }
            buildTypes
                    {
                        release
                                {
                                    minifyEnabled true
                                    shrinkResources true
                                    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
                                }
                    }
            packagingOptions
                    {
                        exclude 'META-INF/DEPENDENCIES'
                        exclude 'META-INF/LICENSE'
                        exclude 'META-INF/LICENSE.txt'
                        exclude 'META-INF/license.txt'
                        exclude 'META-INF/NOTICE'
                        exclude 'META-INF/NOTICE.txt'
                        exclude 'META-INF/notice.txt'
                        exclude 'META-INF/ASL2.0'
                    }
            lintOptions
                    {
                        checkReleaseBuilds false
                    }
            dexOptions
                    {
                        preDexLibraries = false
                        javaMaxHeapSize "4g"
                    }
        }
        dependencies
        {
            implementation 'com.android.support.constraint:constraint-layout:1.0.2'
            compile fileTree(dir: 'libs', include: ['*.jar'])
            compile('com.squareup.okhttp3:okhttp:3.+')
            compile 'com.android.support:multidex:1.0.2'
            compile 'com.android.support:design:27.1.0'
            compile 'com.android.support:appcompat-v7:27.1.0'
            compile 'com.android.support:recyclerview-v7:27.1.0'
            compile 'com.google.android.gms:play-services:11.8.0'
            compile 'com.google.android.gms:play-services-location:11.8.0'
            compile 'com.google.firebase:firebase-core:11.8.0'
            compile 'com.onesignal:OneSignal:[3.7.1, 3.99.99]'
            compile 'org.apache.httpcomponents:httpclient:4.5.4'
            compile 'com.google.maps.android:android-maps-utils:0.4.3'
            compile 'com.google.code.gson:gson:2.8.2'
            compile 'uk.co.chrisjenx:calligraphy:2.2.0'
            compile 'com.pixplicity.easyprefs:library:1.8.1@aar'
            compile 'gun0912.ted:tedpermission:1.0.3'
            compile 'com.kennyc:snackbar:2.5'
            compile 'me.itangqi.waveloadingview:library:0.3.5'
            compile 'com.daimajia.androidanimations:library:2.3@aar'
            compile 'com.fujiyuu75:sequent:0.2.1'
            compile 'com.akexorcist:RoundCornerProgressBar:2.0.3'
            compile 'pl.charmas.android:android-reactive-location:0.10@aar'
            compile 'io.reactivex:rxjava:1.2.0'
            compile 'me.zhanghai.android.materialratingbar:library:1.2.0'
            compile 'cn.lightsky.infiniteindicator:library:1.2.2'
            compile 'com.squareup.picasso:picasso:2.+'
            compile 'com.nineoldandroids:library:2.4.0'
            compile 'de.hdodenhof:circleimageview:2.2.0'
            compile 'com.github.wooplr:Spotlight:1.2.3'
            compile 'com.wang.avi:library:2.1.3'
            compile 'com.caverock:androidsvg:1.2.1'
            compile 'com.github.bumptech.glide:glide:3.8.0'
            compile project(':sidemenulibrary');
            compile('com.github.ozodrukh:CircularReveal:1.1.1@aar')
                    {
                        transitive = true;
                    }
            compile 'org.greenrobot:eventbus:3.0.0'
            compile 'com.nex3z:notification-badge:0.3.0'
            compile 'com.github.Shashank02051997:FancyGifDialog-Android:1.1'
            compile 'br.com.simplepass:loading-button-android:1.+'
            compile 'com.github.blennerSilva:AwesomeDialog:2.0.5'
            compile 'me.relex:circleindicator:1.2.2@aar'
            compile 'com.airbnb.android:lottie:2.2.5'
            compile 'net.yslibrary.keyboardvisibilityevent:keyboardvisibilityevent:2.1.0'
            compile 'com.github.RobertApikyan:SegmentedControl:release_1.0.1'
            compile 'com.github.skydoves:powermenu:2.0.1'
            compile 'com.otaliastudios:cameraview:1.4.1'
            compile 'com.mindorks:placeholderview:0.7.2'
            compile 'com.google.code.gson:gson:2.7'
            compile 'com.github.Mostafa-MA-Saleh:EditCredit:1.5.0'
            compile 'com.github.mreram:ShowCaseView:1.0.5'
            compile 'com.mohamadamin:persianmaterialdatetimepicker:1.2.1'
            compile 'com.alirezaafkar:sundatepicker:2.0.8'
        }
    

    申请插件:'com.google.gms.google-services'

    这是我项目中的库的gradle:

        apply plugin: 'com.android.library'
        group='com.yalantis:sidemenu'
    android {
    compileSdkVersion 27
    buildToolsVersion '27.0.2'
    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        vectorDrawables.useSupportLibrary = true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    }
    
                dependencies
                    compile 'com.android.support:appcompat-v7:27.0.2'
        task androidJavadocs(type: Javadoc) {
            source = android.sourceSets.main.java.sourceFiles
    }
    task androidJavadocsJar(type: Jar) {
        classifier = 'javadoc'
        //basename = artifact_id
        from androidJavadocs.destinationDir
    }
    task androidSourcesJar(type: Jar) {
        classifier = 'sources'
        //basename = artifact_id
        from android.sourceSets.main.java.sourceFiles
    }
    artifacts {
        //archives packageReleaseJar
        archives androidSourcesJar
        archives androidJavadocsJar
    }
    

    编辑: (因为我不能把它留作评论我必须在这里复制)。 在做了@lelloman在评论中提出的建议后,我收到了这个错误:

    FAILURE: Build failed with an exception.
    
    * Where:
    Build file 'C:\Helsa\android\app\build.gradle' line: 1
    
    * What went wrong:
    A problem occurred evaluating project ':app'.
    > java.lang.UnsupportedClassVersionError: com/android/build/gradle/AppPlugin : Unsupported major.minor version 52.0
    
    * Try:
    Run with --info or --debug option to get more log output.
    
    * Exception is:
    org.gradle.api.GradleScriptException: A problem occurred evaluating project ':app'.
            at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:92)
            at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl$2.run(DefaultScriptPluginFactory.java:187)
            at org.gradle.configuration.ProjectScriptTarget.addConfiguration(ProjectScriptTarget.java:77)
            at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:192)
            at org.gradle.configuration.BuildOperationScriptPlugin$1.run(BuildOperationScriptPlugin.java:61)
            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.configuration.BuildOperationScriptPlugin.apply(BuildOperationScriptPlugin.java:58)
            at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:39)
            at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:26)
            at org.gradle.configuration.project.ConfigureActionsProjectEvaluator.evaluate(ConfigureActionsProjectEvaluator.java:34)
            at org.gradle.configuration.project.LifecycleProjectEvaluator.doConfigure(LifecycleProjectEvaluator.java:63)
            at org.gradle.configuration.project.LifecycleProjectEvaluator.access$100(LifecycleProjectEvaluator.java:33)
            at org.gradle.configuration.project.LifecycleProjectEvaluator$ConfigureProject.run(LifecycleProjectEvaluator.java:103)
            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.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:49)
            at org.gradle.api.internal.project.DefaultProject.evaluate(DefaultProject.java:651)
            at org.gradle.api.internal.project.DefaultProject.evaluate(DefaultProject.java:133)
            at org.gradle.execution.TaskPathProjectEvaluator.configure(TaskPathProjectEvaluator.java:35)
            at org.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(TaskPathProjectEvaluator.java:62)
            at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:38)
            at org.gradle.initialization.DefaultGradleLauncher$ConfigureBuild.run(DefaultGradleLauncher.java:246)
            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.initialization.DefaultGradleLauncher.configureBuild(DefaultGradleLauncher.java:165)
            at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:124)
            at org.gradle.initialization.DefaultGradleLauncher.executeTasks(DefaultGradleLauncher.java:107)
            at org.gradle.internal.invocation.GradleBuildController$1.call(GradleBuildController.java:78)
            at org.gradle.internal.invocation.GradleBuildController$1.call(GradleBuildController.java:75)
            at org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:152)
            at org.gradle.internal.invocation.GradleBuildController.doBuild(GradleBuildController.java:100)
            at org.gradle.internal.invocation.GradleBuildController.run(GradleBuildController.java:75)
            at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28)
            at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
            at org.gradle.tooling.internal.provider.ValidatingBuildActionRunner.run(ValidatingBuildActionRunner.java:32)
            at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner$1.run(RunAsBuildOperationBuildActionRunner.java:43)
            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.launcher.exec.RunAsBuildOperationBuildActionRunner.run(RunAsBuildOperationBuildActionRunner.java:40)
            at org.gradle.tooling.internal.provider.SubscribableBuildActionRunner.run(SubscribableBuildActionRunner.java:51)        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:45)
            at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:29)
            at org.gradle.launcher.exec.BuildTreeScopeBuildActionExecuter.execute(BuildTreeScopeBuildActionExecuter.java:39)        at org.gradle.launcher.exec.BuildTreeScopeBuildActionExecuter.execute(BuildTreeScopeBuildActionExecuter.java:25)        at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:71)
            at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:45)
            at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:51)
            at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:32)
            at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:36)
            at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:25)
            at org.gradle.tooling.internal.provider.ParallelismConfigurationBuildActionExecuter.execute(ParallelismConfigurationBuildActionExecuter.java:43)
            at org.gradle.tooling.internal.provider.ParallelismConfigurationBuildActionExecuter.execute(ParallelismConfigurationBuildActionExecuter.java:29)
            at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:64)
            at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:29)
            at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:55)
            at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:42)
            at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:58)
            at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:33)
            at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:67)
            at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
            at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
            at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:37)
            at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
            at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26)
            at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
            at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34)
            at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
            at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74)
            at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72)
            at org.gradle.util.Swapper.swap(Swapper.java:38)
            at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72)
            at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
            at org.gradle.launcher.daemon.server.exec.LogAndCheckHealth.execute(LogAndCheckHealth.java:55)
            at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
            at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:62)
            at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
            at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
            at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:82)
            at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
            at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
            at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50)        at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:297)
            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: com.google.common.util.concurrent.ExecutionError: java.lang.UnsupportedClassVersionError: com/android/build/gradle/AppPlugin : Unsupported major.minor version 52.0
            at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2199)
            at com.google.common.cache.LocalCache.get(LocalCache.java:3934)
            at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3938)
            at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4821)
            at org.gradle.api.internal.plugins.DefaultPluginRegistry.uncheckedGet(DefaultPluginRegistry.java:149)
            at org.gradle.api.internal.plugins.DefaultPluginRegistry.lookup(DefaultPluginRegistry.java:144)
            at org.gradle.api.internal.plugins.DefaultPluginRegistry.lookup(DefaultPluginRegistry.java:127)
            at org.gradle.api.internal.plugins.DefaultPluginRegistry.lookup(DefaultPluginRegistry.java:121)
            at org.gradle.api.internal.plugins.DefaultPluginManager.apply(DefaultPluginManager.java:121)
            at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.applyType(DefaultObjectConfigurationAction.java:113)
            at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.access$200(DefaultObjectConfigurationAction.java:36)
            at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction$3.run(DefaultObjectConfigurationAction.java:80)
            at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.execute(DefaultObjectConfigurationAction.java:136)
            at org.gradle.api.internal.project.AbstractPluginAware.apply(AbstractPluginAware.java:46)
            at org.gradle.api.internal.project.ProjectScript.apply(ProjectScript.java:34)
            at org.gradle.api.Script$apply$0.callCurrent(Unknown Source)
            at build_7tk3isvg0ht17m1ll3oykzmdx.run(C:\Helsa\android\app\build.gradle:1)
            at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:90)
            ... 93 more
    Caused by: java.lang.UnsupportedClassVersionError: com/android/build/gradle/AppPlugin : Unsupported major.minor version 52.0
            at org.gradle.api.internal.plugins.DefaultPluginRegistry$1.load(DefaultPluginRegistry.java:71)
            at org.gradle.api.internal.plugins.DefaultPluginRegistry$1.load(DefaultPluginRegistry.java:51)
            at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3524)
            at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2317)
            at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2280)
            at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2195)
            ... 110 more
    

    在2分11秒内建立失败

2 个答案:

答案 0 :(得分:0)

请按以下步骤操作

  1. 清理项目(build-> clean project)
  2. 重建项目(构建 - >重建项目)

答案 1 :(得分:0)

我在编译gitHub存储库时遇到了同样的问题。因此,我没有将compile 'blablabla:1.2.3'添加到build.gradle,而是复制了library / JAVA Code并将其粘贴到我的项目中。然后它让我的项目再次运作!