Hi, I just integrate Unity ads and try to export my game to android platform and got this error: (My game run and export completely normal before adding unity ads).
“com.android.build.api.transform. TransformException: com.android.ide.common.process. ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lcom/unity3d/ads/BuildConfig; See the Console for detail”.
Here’s the detailed problem:
CommandInvokationFailure: Gradle build failed.
C:\Program Files\Java\jdk1.8.0_161\bin\java.exe -classpath “C:\Program Files\Unity 2018.1.0b4\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-4.0.1.jar” org.gradle.launcher.GradleMain “-Dorg.gradle.jvmargs=-Xmx2048m” “assembleRelease”
stderr[
FAILURE: Build failed with an exception.
- What went wrong:
Execution failed for task ‘:transformClassesWithDexForRelease’.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lcom/unity3d/ads/BuildConfig;
- Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED in 15s
]
stdout[
NDK is missing a “platforms” directory.
If you are using NDK, verify the ndk.dir is set to a valid NDK directory. It is currently set to C:\Users\HP\AppData\Local\Android\android-sdk\ndk-bundle.
If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.
NDK is missing a “platforms” directory.
If you are using NDK, verify the ndk.dir is set to a valid NDK directory. It is currently set to C:\Users\HP\AppData\Local\Android\android-sdk\ndk-bundle.
If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.
The setTestClassesDir(File) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use the setTestClassesDirs(FileCollection) method instead.
The getTestClassesDir() method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use the getTestClassesDirs() method instead.
The ConfigurableReport.setDestination(Object) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use the method ConfigurableReport.setDestination(File) instead.
:preBuild UP-TO-DATE
:preReleaseBuild UP-TO-DATE
:checkReleaseManifest
:preDebugBuild UP-TO-DATE
:prepareAdmoblibReleaseLibrary
:prepareAppcompatV72610Library
:preparePlayServicesAds1180Library
:preparePlayServicesAdsLite1180Library
:preparePlayServicesBasement1180Library
:preparePlayServicesGass1180Library
:prepareSupportCompat2610Library
:prepareSupportV42610Library
:prepareUnityAdapter2100Library
:prepareUnityAdsLibrary
:prepareUnityAdsSdk21Library
:GoogleMobileAdsPlugin:preBuild UP-TO-DATE
:GoogleMobileAdsPlugin:preReleaseBuild UP-TO-DATE
:GoogleMobileAdsPlugin:checkReleaseManifest
:GoogleMobileAdsPlugin:prepareReleaseDependencies
:GoogleMobileAdsPlugin:compileReleaseAidl
:GoogleMobileAdsPlugin:compileReleaseNdk NO-SOURCE
:GoogleMobileAdsPlugin:compileLint
:GoogleMobileAdsPlugin:copyReleaseLint NO-SOURCE
:GoogleMobileAdsPlugin:mergeReleaseShaders
:GoogleMobileAdsPlugin:compileReleaseShaders
:GoogleMobileAdsPlugin:generateReleaseAssets
:GoogleMobileAdsPlugin:mergeReleaseAssets
:GoogleMobileAdsPlugin:mergeReleaseProguardFiles UP-TO-DATE
:GoogleMobileAdsPlugin:packageReleaseRenderscript NO-SOURCE
:GoogleMobileAdsPlugin:compileReleaseRenderscript
:GoogleMobileAdsPlugin:generateReleaseResValues
:GoogleMobileAdsPlugin:generateReleaseResources
:GoogleMobileAdsPlugin:packageReleaseResources
:GoogleMobileAdsPlugin:processReleaseManifest
:GoogleMobileAdsPlugin:generateReleaseBuildConfig
:GoogleMobileAdsPlugin:processReleaseResources
:GoogleMobileAdsPlugin:generateReleaseSources
:GoogleMobileAdsPlugin:incrementalReleaseJavaCompilationSafeguard
:GoogleMobileAdsPlugin:javaPreCompileRelease
:GoogleMobileAdsPlugin:compileReleaseJavaWithJavac
:GoogleMobileAdsPlugin:processReleaseJavaRes NO-SOURCE
:GoogleMobileAdsPlugin:transformResourcesWithMergeJavaResForRelease
:GoogleMobileAdsPlugin:transformClassesAndResourcesWithSyncLibJarsForRelease
:GoogleMobileAdsPlugin:mergeReleaseJniLibFolders
:GoogleMobileAdsPlugin:transformNativeLibsWithMergeJniLibsForRelease
:GoogleMobileAdsPlugin:transformNativeLibsWithSyncJniLibsForRelease
:GoogleMobileAdsPlugin:bundleRelease
:prepareReleaseDependencies
:compileReleaseAidl UP-TO-DATE
:compileReleaseRenderscript UP-TO-DATE
:generateReleaseBuildConfig UP-TO-DATE
:generateReleaseResValues UP-TO-DATE
:generateReleaseResources UP-TO-DATE
:mergeReleaseResources UP-TO-DATE
:processReleaseManifest
:processReleaseResources
:generateReleaseSources
:incrementalReleaseJavaCompilationSafeguard UP-TO-DATE
:javaPreCompileRelease
:compileReleaseJavaWithJavac UP-TO-DATE
:compileReleaseNdk NO-SOURCE
:compileReleaseSources UP-TO-DATE
:lintVitalRelease
:mergeReleaseShaders UP-TO-DATE
:compileReleaseShaders UP-TO-DATE
:generateReleaseAssets UP-TO-DATE
:mergeReleaseAssets
:transformClassesWithDexForRelease FAILED
51 actionable tasks: 41 executed, 10 up-to-date
]
exit code: 1
UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action1 progress, System.String error) UnityEditor.Android.GradleWrapper.Run (System.String workingdir, System.String task, System.Action
1 progress)
Rethrow as GradleInvokationException: Gradle build failed
UnityEditor.Android.GradleWrapper.Run (System.String workingdir, System.String task, System.Action`1 progress)
UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context)
UnityEditor.BuildPlayerWindow:BuildPlayerAndRun()
Does anyone know how to fix this problem? I’m using Unity 2018.1.0b4 on Window 10 - 64 bit
Thanks