org.gradle.api.tasks.TaskExecutionException:任务执行失败':transformDexArchiveWithExternalLibsDexMergerForDebug'

时间:2018-04-20 09:27:52

标签: android firebase unity3d gradle google-play-services

我已将Unity项目导出到Android Studio项目。我想通过Studio将Firebase Messaging添加到我的项目中,因为Firebase Messaging在Unity中实现不起作用。

所以我将以下代码添加到我的app/build.gradle,这导致了我所有这些问题。

dependencies {
.
.
.
compile('com.google.firebase:firebase-messaging:11.8.0') {
    exclude module: 'support-v4'
  }
}

buildscript {
.
.
.
dependencies {
   .
   .
   .
   classpath 'com.google.gms:google-services:3.1.1'
}

apply plugin: 'com.google.gms.google-services'

我已将google-services.json个文件添加到app目录。

如果我评论来自build.gradle的大多数aar依赖项,该应用程序将成功构建而不会出现任何错误。但我在我的项目中使用的Firebase分析无法正常工作。

在构建应用程序时,我遇到了以下错误。

org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':transformDexArchiveWithExternalLibsDexMergerForDebug'.
    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.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
    at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
and
.
.
.
Caused by: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/0.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/1.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/2.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/3.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/4.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/5.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/6.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/7.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/8.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/9.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/10.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/11.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/12.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/13.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/14.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/15.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/16.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/17.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/19.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/21.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/23.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/24.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/29.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/32.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/34.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/35.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/36.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/37.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/38.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/39.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/40.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/41.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/42.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/43.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/44.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/45.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/46.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/47.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/66.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/68.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/69.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/70.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/71.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/72.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/73.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/80.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/82.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/83.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/84.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/85.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/86.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/87.jar
    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:212)
    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:46)
    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:121)
    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:110)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
    ... 107 more
Caused by: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/0.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/1.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/2.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/3.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/4.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/5.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/6.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/7.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/8.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/9.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/10.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/11.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/12.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/13.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/14.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/15.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/16.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/17.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/19.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/21.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/23.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/24.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/29.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/32.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/34.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/35.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/36.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/37.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/38.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/39.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/40.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/41.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/42.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/43.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/44.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/45.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/46.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/47.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/66.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/68.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/69.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/70.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/71.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/72.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/73.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/80.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/82.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/83.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/84.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/85.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/86.jar, /Users/nabeelkottol/Downloads/VR DEVOTEE 2/build/intermediates/transforms/dexBuilder/debug/87.jar
    at com.android.builder.dexing.D8DexArchiveMerger.getExceptionToRethrow(D8DexArchiveMerger.java:124)
    at com.android.builder.dexing.D8DexArchiveMerger.mergeDexArchives(D8DexArchiveMerger.java:109)
    at com.android.build.gradle.internal.transforms.DexMergerTransformCallable.call(DexMergerTransformCallable.java:101)
    at com.android.build.gradle.internal.transforms.ExternalLibsMergerTransform.transform(ExternalLibsMergerTransform.kt:123)
    at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:221)
    at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:217)
    at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:102)
    ... 123 more
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete
    at com.android.tools.r8.utils.ExceptionUtils.withCompilationHandler(ExceptionUtils.java:76)
    at com.android.tools.r8.utils.ExceptionUtils.withD8CompilationHandler(ExceptionUtils.java:45)
    at com.android.tools.r8.D8.run(D8.java:88)
    at com.android.builder.dexing.D8DexArchiveMerger.mergeDexArchives(D8DexArchiveMerger.java:107)
    ... 128 more
Caused by: com.android.tools.r8.utils.AbortException
    at com.android.tools.r8.utils.Reporter.failIfPendingErrors(Reporter.java:77)
    at com.android.tools.r8.utils.Reporter.fatalError(Reporter.java:58)
    at com.android.tools.r8.utils.ExceptionUtils.withCompilationHandler(ExceptionUtils.java:67)
    ... 131 more

Program type already present: com.google.android.gms.measurement.AppMeasurementInstallReferrerReceiver
Message{kind=ERROR, text=Program type already present: com.google.android.gms.measurement.AppMeasurementContentProvider, sources=[Unknown source file], tool name=Optional.of(D8)}

我认为这是由于重复的依赖关系而发生的。我对gradle没有足够的知识来找出特定的包装并从建筑物中排除。任何帮助是极大的赞赏。谢谢。

我的build.gradle如下:

// GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN
buildscript {
  repositories {
    jcenter()
    google()
  }

  dependencies {
    classpath 'com.android.tools.build:gradle:3.1.1'
    classpath 'com.google.gms:google-services:3.1.1'
  }
}

allprojects {
  repositories {
    flatDir {
      dirs 'libs'
    }
    google()
  }
}

apply plugin: 'com.android.application'

dependencies {
  compile fileTree(dir: 'libs', include: ['*.jar'])
  compile(name: 'androidnative', ext: 'aar')
  compile(name: 'com.android.support.support-compat-25.2.0', ext: 'aar')
  compile(name: 'com.android.support.support-core-ui-25.2.0', ext: 'aar')
  compile(name: 'com.android.support.support-core-utils-25.2.0', ext: 'aar')
  compile(name: 'com.android.support.support-fragment-25.2.0', ext: 'aar')
  compile(name: 'com.android.support.support-media-compat-25.2.0', ext: 'aar')
  compile(name: 'com.android.support.support-v4-25.2.0', ext: 'aar')
  compile(name: 'com.google.android.gms.play-services-base-11.8.0', ext: 'aar')
  compile(name: 'com.google.android.gms.play-services-base-license-11.8.0', ext: 'aar')
  compile(name: 'com.google.android.gms.play-services-basement-11.8.0', ext: 'aar')
  compile(name: 'com.google.android.gms.play-services-basement-license-11.8.0', ext: 'aar')
  compile(name: 'com.google.android.gms.play-services-tasks-11.8.0', ext: 'aar')
  compile(name: 'com.google.android.gms.play-services-tasks-license-11.8.0', ext: 'aar')
  compile(name: 'com.google.firebase.firebase-analytics-11.8.0', ext: 'aar')
  compile(name: 'com.google.firebase.firebase-analytics-impl-11.8.0', ext: 'aar')
  compile(name: 'com.google.firebase.firebase-analytics-impl-license-11.8.0', ext: 'aar')
  compile(name: 'com.google.firebase.firebase-analytics-license-11.8.0', ext: 'aar')
  compile(name: 'com.google.firebase.firebase-analytics-unity-4.4.1', ext: 'aar')
  compile(name: 'com.google.firebase.firebase-app-unity-4.4.1', ext: 'aar')
  compile(name: 'com.google.firebase.firebase-common-11.8.0', ext: 'aar')
  compile(name: 'com.google.firebase.firebase-common-license-11.8.0', ext: 'aar')
  compile(name: 'com.google.firebase.firebase-core-11.8.0', ext: 'aar')
  compile(name: 'com.google.firebase.firebase-iid-11.8.0', ext: 'aar')
  compile(name: 'com.google.firebase.firebase-iid-license-11.8.0', ext: 'aar')
  compile(name: 'exoplayer-r1.5.11', ext: 'aar')
  compile(name: 'gvr-exoplayersupport-release', ext: 'aar')
  compile(name: 'gvr_android_common', ext: 'aar')
  compile(name: 'installreferrer-1.0', ext: 'aar')
  compile(name: 'kalpnikutilitylibrary-release', ext: 'aar')
  compile(name: 'mobile-native-popups', ext: 'aar')
  compile(name: 'unitygvractivity', ext: 'aar')
  compile project(':Firebase')
  compile project(':answers')
  compile project(':beta')
  compile project(':crashlytics')
  compile project(':crashlytics-wrapper')
  compile project(':fabric')
  compile project(':fabric-init')
  compile('com.google.firebase:firebase-messaging:11.8.0') {
    exclude module: 'support-v4'
  }
}

android {
  compileSdkVersion 27
  buildToolsVersion '27.0.3'

  defaultConfig {
    targetSdkVersion 27
    applicationId 'applicationId'
    multiDexEnabled true
  }

  lintOptions {
    abortOnError false
  }

  aaptOptions {
    noCompress '.unity3d', '.ress', '.resource', '.obb'
  }


  buildTypes {
    debug {
      jniDebuggable true
    }
    release {
      // Set minifyEnabled to true if you want to run ProGuard on your project
      minifyEnabled false
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'
    }
  }
}

apply plugin: 'com.google.gms.google-services'

2 个答案:

答案 0 :(得分:3)

我无法测试我准备好的build.gradle。但是,我认为以下的学习应该有效。

让我把你添加的内容放在你的gradle中。

DexArchiveMergerException主要是因为没有multidexEnabled true。我添加了属性。

apply plugin: 'com.android.application'移至顶部。

javaMaxHeapSize "4g"部分添加了dexOptions。如果找到同一个库的多个版本,则会添加resolutionStrategy以及packagingOption

apply plugin: 'com.android.application'

buildscript {
    repositories {
        jcenter()
        google()
    }
}

allprojects {
    repositories {
        flatDir {
            dirs 'libs'
        }
        google()
    }
}

android {
    compileSdkVersion 27
    buildToolsVersion '27.0.3'

    defaultConfig {
        targetSdkVersion 27
        applicationId 'applicationId'
        multiDexEnabled true
    }

    dexOptions {
        javaMaxHeapSize "4g"
    }

    lintOptions {
        abortOnError false
    }

    aaptOptions {
        noCompress '.unity3d', '.ress', '.resource', '.obb'
    }

    buildTypes {
        debug {
            jniDebuggable true
        }
        release {
            // Set minifyEnabled to true if you want to run ProGuard on your project
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'
        }
    }
}

android.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'
}

configurations.all {
    resolutionStrategy {
        force 'com.android.support:support-v4:25.2.0'
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile(name: 'androidnative', ext: 'aar')
    compile(name: 'com.android.support.support-compat-25.2.0', ext: 'aar')
    compile(name: 'com.android.support.support-core-ui-25.2.0', ext: 'aar')
    compile(name: 'com.android.support.support-core-utils-25.2.0', ext: 'aar')
    compile(name: 'com.android.support.support-fragment-25.2.0', ext: 'aar')
    compile(name: 'com.android.support.support-media-compat-25.2.0', ext: 'aar')
    compile(name: 'com.android.support.support-v4-25.2.0', ext: 'aar')
    compile(name: 'com.google.android.gms.play-services-base-11.8.0', ext: 'aar')
    compile(name: 'com.google.android.gms.play-services-base-license-11.8.0', ext: 'aar')
    compile(name: 'com.google.android.gms.play-services-basement-11.8.0', ext: 'aar')
    compile(name: 'com.google.android.gms.play-services-basement-license-11.8.0', ext: 'aar')
    compile(name: 'com.google.android.gms.play-services-tasks-11.8.0', ext: 'aar')
    compile(name: 'com.google.android.gms.play-services-tasks-license-11.8.0', ext: 'aar')
    compile(name: 'com.google.firebase.firebase-analytics-11.8.0', ext: 'aar')
    compile(name: 'com.google.firebase.firebase-analytics-impl-11.8.0', ext: 'aar')
    compile(name: 'com.google.firebase.firebase-analytics-impl-license-11.8.0', ext: 'aar')
    compile(name: 'com.google.firebase.firebase-analytics-license-11.8.0', ext: 'aar')
    compile(name: 'com.google.firebase.firebase-analytics-unity-4.4.1', ext: 'aar')
    compile(name: 'com.google.firebase.firebase-app-unity-4.4.1', ext: 'aar')
    compile(name: 'com.google.firebase.firebase-common-11.8.0', ext: 'aar')
    compile(name: 'com.google.firebase.firebase-common-license-11.8.0', ext: 'aar')
    compile(name: 'com.google.firebase.firebase-core-11.8.0', ext: 'aar')
    compile(name: 'com.google.firebase.firebase-iid-11.8.0', ext: 'aar')
    compile(name: 'com.google.firebase.firebase-iid-license-11.8.0', ext: 'aar')
    compile(name: 'exoplayer-r1.5.11', ext: 'aar')
    compile(name: 'gvr-exoplayersupport-release', ext: 'aar')
    compile(name: 'gvr_android_common', ext: 'aar')
    compile(name: 'installreferrer-1.0', ext: 'aar')
    compile(name: 'kalpnikutilitylibrary-release', ext: 'aar')
    compile(name: 'mobile-native-popups', ext: 'aar')
    compile(name: 'unitygvractivity', ext: 'aar')
    compile project(':Firebase')
    compile project(':answers')
    compile project(':beta')
    compile project(':crashlytics')
    compile project(':crashlytics-wrapper')
    compile project(':fabric')
    compile project(':fabric-init')
    compile('com.google.firebase:firebase-messaging:11.8.0') {
        exclude group: 'com.android.support'
    }
}

apply plugin: 'com.google.gms.google-services'

如果问题仍未解决,请尝试按照here MultiDexApplication启用您的应用。

如果您收到任何其他错误或不同类型的错误,请与我们联系。

答案 1 :(得分:3)

您可以更改此内容并尝试

android {
  compileSdkVersion 27
  buildToolsVersion '27.0.3'

  defaultConfig {
    targetSdkVersion 27
    applicationId 'applicationId'
    multiDexEnabled true
  }

  lintOptions {
    abortOnError false
  }

  aaptOptions {
    noCompress '.unity3d', '.ress', '.resource', '.obb'
  }


  buildTypes {
    debug {
      jniDebuggable true
    }
    release {
      // Set minifyEnabled to true if you want to run ProGuard on your project
      minifyEnabled false
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'
    }
  }
}

android {
  compileSdkVersion 27
  buildToolsVersion '27.0.3'

  defaultConfig {
    targetSdkVersion 27
    applicationId 'applicationId'
  }

  lintOptions {
    abortOnError false
  }

  aaptOptions {
    noCompress '.unity3d', '.ress', '.resource', '.obb'
  }


  buildTypes {
    debug {
      jniDebuggable true
      multiDexEnabled true
    }
    release {
      // Set minifyEnabled to true if you want to run ProGuard on your project
      multiDexEnabled true
      minifyEnabled false
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'
    }
  }
}

然后,在AndroidManifest.xml上添加此

<application
    android:debuggable="true"
    android:name="android.support.multidex.MultiDexApplication">
...
</application>