The question is answered, right answer was accepted
Unity Build Error Android Build (SOLVED)
The problem was quite clear after a while. I had downloaded the Ads SDK from Unitys Asset store, and at the same time I had Built-in Ads Extension active. Disabling it made it work as I suppose you cant have duplicates :P
I'm trying to build the game like I have hundreds of times before. It works find when building as a PC build but when I try it for Android I get this message.
CommandInvokationFailure: Gradle build failed. C:\Program Files\Java\jdk1.8.0_181\bin\java.exe -classpath "C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-4.2.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 ':transformDexWithDexForRelease'.
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.
Get more help at https://help.gradle.org
BUILD FAILED in 23s ] stdout[ Starting a Gradle Daemon, 1 stopped Daemon could not be reused, use --status for details :preBuild UP-TO-DATE :preReleaseBuild :compileReleaseAidl :compileReleaseRenderscript :checkReleaseManifest :generateReleaseBuildConfig :prepareLintJar :generateReleaseResValues :generateReleaseResources :mergeReleaseResources :createReleaseCompatibleScreenManifests :processReleaseManifest :splitsDiscoveryTaskRelease :processReleaseResources :generateReleaseSources :javaPreCompileRelease :compileReleaseJavaWithJavac :compileReleaseNdk NO-SOURCE :compileReleaseSources :lintVitalRelease :mergeReleaseShaders :compileReleaseShaders :generateReleaseAssets :mergeReleaseAssets :transformClassesWithPreDexForRelease :transformDexWithDexForRelease FAILED 20 actionable tasks: 20 executed ] 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.Action`1 progress, System.String error) UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingdir, System.String task, System.Action`1 progress) Rethrow as GradleInvokationException: Gradle build failed UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, 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) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
Even though it has worked before. The only changes I have made was to add some scripts to handle Ads.
Thanks in advance! :)
Hello, how did you solve this problem? I also encountered this problem when I released Android.thanks!
You are actually my hero - I cannot tell you how much time I have wasted on this. Thank you.