Build problem after integrating Firebase SDK

First post, really hope someone can help me because this project is for college and it’s really important… Ok, so I’m tring to introduce firebase to my project and if I import any of the packages from the SDK my project loses the will to build. I’m on Unity 2017.3.3.f1

Here’s the error:

com.android.build.api.transform.TransformException:com.android.ide.common.process.ProcessException:java.util.concurrent.ExecutionException:com.android.dex.DexException: Multiple dex files define Landroid/support/compat/BuildConfig;

also:

CommandInvokationFailure: Gradle build failed.
C:\Program Files\Java\jdk1.8.0_131\bin\java.exe -classpath “C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-4.0.1.jar” org.gradle.launcher.GradleMain “-Dorg.gradle.jvmargs=-Xmx2048m” “assembleDebug”

stderr[

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:transformClassesWithDexForDebug’.

com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Landroid/support/compat/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 42s
]
stdout[
Starting a Gradle Daemon, 3 stopped Daemons could not be reused, use --status for details
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\niall\AppData\Local\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\niall\AppData\Local\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
:preDebugBuild UP-TO-DATE
:checkDebugManifest
:preReleaseBuild UP-TO-DATE
:prepareAnimatedVectorDrawable2510Library
:prepareAppcompatV72510Library
:prepareComAndroidSupportSupportCompat2520Library
:prepareComAndroidSupportSupportCoreUi2520Library
:prepareComAndroidSupportSupportCoreUtils2520Library
:prepareComAndroidSupportSupportFragment2520Library
:prepareComAndroidSupportSupportMediaCompat2520Library
:prepareComAndroidSupportSupportV42520Library
:prepareComGoogleAndroidGmsPlayServicesBase1180Library
:prepareComGoogleAndroidGmsPlayServicesBaseLicense1180Library
:prepareComGoogleAndroidGmsPlayServicesBasement1180Library
:prepareComGoogleAndroidGmsPlayServicesBasementLicense1180Library
:prepareComGoogleAndroidGmsPlayServicesTasks1180Library
:prepareComGoogleAndroidGmsPlayServicesTasksLicense1180Library
:prepareComGoogleFirebaseFirebaseAnalytics1180Library
:prepareComGoogleFirebaseFirebaseAnalyticsImpl1180Library
:prepareComGoogleFirebaseFirebaseAnalyticsImplLicense1180Library
:prepareComGoogleFirebaseFirebaseAnalyticsLicense1180Library
:prepareComGoogleFirebaseFirebaseAnalyticsUnity441Library
:prepareComGoogleFirebaseFirebaseAppUnity441Library
:prepareComGoogleFirebaseFirebaseCommon1180Library
:prepareComGoogleFirebaseFirebaseCommonLicense1180Library
:prepareComGoogleFirebaseFirebaseCore1180Library
:prepareComGoogleFirebaseFirebaseIid1180Library
:prepareComGoogleFirebaseFirebaseIidLicense1180Library
:prepareLighting_estimationLibrary
:prepareMapboxAndroidTelemetry210Library
:prepareSupportCompat2510Library
:prepareSupportCoreUi2510Library
:prepareSupportCoreUtils2510Library
:prepareSupportMediaCompat2510Library
:prepareSupportV42510Library
:prepareSupportVectorDrawable2510Library
:prepareUnityandroidpermissionsLibrary
:prepareUnitygarLibrary
:Firebase:preBuild UP-TO-DATE
:Firebase:preReleaseBuild UP-TO-DATE
:Firebase:checkReleaseManifest
:Firebase:prepareReleaseDependencies
:Firebase:compileReleaseAidl
:Firebase:compileReleaseNdk NO-SOURCE
:Firebase:compileLint
:Firebase:copyReleaseLint NO-SOURCE
:Firebase:mergeReleaseShaders
:Firebase:compileReleaseShaders
:Firebase:generateReleaseAssets
:Firebase:mergeReleaseAssets
:Firebase:mergeReleaseProguardFiles
:Firebase:packageReleaseRenderscript NO-SOURCE
:Firebase:compileReleaseRenderscript
:Firebase:generateReleaseResValues
:Firebase:generateReleaseResources
:Firebase:packageReleaseResources
:Firebase:processReleaseManifest
:Firebase:generateReleaseBuildConfig
:Firebase:processReleaseResources
:Firebase:generateReleaseSources
:Firebase:incrementalReleaseJavaCompilationSafeguard
:Firebase:javaPreCompileRelease
:Firebase:compileReleaseJavaWithJavac
:Firebase:processReleaseJavaRes NO-SOURCE
:Firebase:transformResourcesWithMergeJavaResForRelease
:Firebase:transformClassesAndResourcesWithSyncLibJarsForRelease
:Firebase:mergeReleaseJniLibFolders
:Firebase:transformNativeLibsWithMergeJniLibsForRelease
:Firebase:transformNativeLibsWithSyncJniLibsForRelease
:Firebase:bundleRelease
:prepareDebugDependencies
:compileDebugAidl
:compileDebugRenderscript
:generateDebugBuildConfig
:generateDebugResValues
:generateDebugResources
:mergeDebugResources
:processDebugManifest
:processDebugResources
:generateDebugSources
:incrementalDebugJavaCompilationSafeguard
:javaPreCompileDebug
:compileDebugJavaWithJavac
:compileDebugNdk NO-SOURCE
:compileDebugSources
:mergeDebugShaders
:compileDebugShaders
:generateDebugAssets
:mergeDebugAssets
:transformClassesWithDexForDebug FAILED
74 actionable tasks: 74 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.Action1 progress, System.String error) UnityEditor.Android.GradleWrapper.Run (System.String workingdir, System.String task, System.Action1 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()

Thanks,
Niall Phillips

This may help Add Firebase to your Unity project  |  Firebase for Unity

Sorry for the emoji’s :roll_eyes:

And thanks for replying so fast! I had skipped that part as I knew I was on .NET 3.5

I followed those steps but it seems I’m missing the referanced dotNet45/Unity.Compat.dll, must try and track that down

1 Like

Hi, I also faced this issue. I solved like that;
1- download and unzip ndk from this link NDK 下载  |  Android NDK  |  Android Developers
2- copy and paste the folder into your Android sdk folder (in your scenario sdk path is "C:\Users\niall\AppData\Local\Android\sdk"). Copied folder name should be “ndk-bundle”.

that’s all.

I tried that and the build is still failing. Here’s the error:

CommandInvokationFailure: Gradle build failed.
C:\Program Files\Java\jdk1.8.0_131\bin\java.exe -classpath “C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-4.0.1.jar” org.gradle.launcher.GradleMain “-Dorg.gradle.jvmargs=-Xmx2048m” “assembleDebug”
stderr[
FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:transformClassesWithDexForDebug’.

com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Landroid/support/coreui/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 17s
    ]
    stdout[
    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
    :preDebugBuild UP-TO-DATE
    :checkDebugManifest
    :preReleaseBuild UP-TO-DATE
    :prepareAnimatedVectorDrawable2510Library
    :prepareAppcompatV72510Library
    :prepareArcore_clientLibrary
    :prepareComAndroidSupportSupportCompat2520Library
    :prepareComAndroidSupportSupportCoreUi2520Library
    :prepareComAndroidSupportSupportCoreUtils2520Library
    :prepareComAndroidSupportSupportFragment2520Library
    :prepareComAndroidSupportSupportMediaCompat2520Library
    :prepareComAndroidSupportSupportV42520Library
    :prepareComGoogleAndroidGmsPlayServicesBase1180Library
    :prepareComGoogleAndroidGmsPlayServicesBaseLicense1180Library
    :prepareComGoogleAndroidGmsPlayServicesBasement1180Library
    :prepareComGoogleAndroidGmsPlayServicesBasementLicense1180Library
    :prepareComGoogleAndroidGmsPlayServicesTasks1180Library
    :prepareComGoogleAndroidGmsPlayServicesTasksLicense1180Library
    :prepareComGoogleFirebaseFirebaseAnalytics1180Library
    :prepareComGoogleFirebaseFirebaseAnalyticsImpl1180Library
    :prepareComGoogleFirebaseFirebaseAnalyticsImplLicense1180Library
    :prepareComGoogleFirebaseFirebaseAnalyticsLicense1180Library
    :prepareComGoogleFirebaseFirebaseAppUnity450Library
    :prepareComGoogleFirebaseFirebaseAuth1180Library
    :prepareComGoogleFirebaseFirebaseAuthLicense1180Library
    :prepareComGoogleFirebaseFirebaseAuthUnity450Library
    :prepareComGoogleFirebaseFirebaseCommon1180Library
    :prepareComGoogleFirebaseFirebaseCommonLicense1180Library
    :prepareComGoogleFirebaseFirebaseCore1180Library
    :prepareComGoogleFirebaseFirebaseIid1180Library
    :prepareComGoogleFirebaseFirebaseIidLicense1180Library
    :prepareGoogle_ar_requiredLibrary
    :prepareMapboxAndroidTelemetry210Library
    :prepareSupportCompat2510Library
    :prepareSupportCoreUi2510Library
    :prepareSupportCoreUtils2510Library
    :prepareSupportMediaCompat2510Library
    :prepareSupportV42510Library
    :prepareSupportVectorDrawable2510Library
    :prepareUnityandroidpermissionsLibrary
    :prepareUnitygarLibrary
    :Firebase:preBuild UP-TO-DATE
    :Firebase:preReleaseBuild UP-TO-DATE
    :Firebase:checkReleaseManifest
    :Firebase:prepareReleaseDependencies
    :Firebase:compileReleaseAidl
    :Firebase:compileReleaseNdk NO-SOURCE
    :Firebase:compileLint
    :Firebase:copyReleaseLint NO-SOURCE
    :Firebase:mergeReleaseShaders
    :Firebase:compileReleaseShaders
    :Firebase:generateReleaseAssets
    :Firebase:mergeReleaseAssets
    :Firebase:mergeReleaseProguardFiles
    :Firebase:packageReleaseRenderscript NO-SOURCE
    :Firebase:compileReleaseRenderscript
    :Firebase:generateReleaseResValues
    :Firebase:generateReleaseResources
    :Firebase:packageReleaseResources
    :Firebase:processReleaseManifest
    :Firebase:generateReleaseBuildConfig
    :Firebase:processReleaseResources
    :Firebase:generateReleaseSources
    :Firebase:incrementalReleaseJavaCompilationSafeguard
    :Firebase:javaPreCompileRelease
    :Firebase:compileReleaseJavaWithJavac
    :Firebase:processReleaseJavaRes NO-SOURCE
    :Firebase:transformResourcesWithMergeJavaResForRelease
    :Firebase:transformClassesAndResourcesWithSyncLibJarsForRelease
    :Firebase:mergeReleaseJniLibFolders
    :Firebase:transformNativeLibsWithMergeJniLibsForRelease
    :Firebase:transformNativeLibsWithStripDebugSymbolForRelease
    :Firebase:transformNativeLibsWithSyncJniLibsForRelease
    :Firebase:bundleRelease
    :prepareDebugDependencies
    :compileDebugAidl
    :compileDebugRenderscript
    :generateDebugBuildConfig
    :generateDebugResValues
    :generateDebugResources
    :mergeDebugResources
    :processDebugManifest
    :processDebugResources
    :generateDebugSources
    :incrementalDebugJavaCompilationSafeguard
    :javaPreCompileDebug
    :compileDebugJavaWithJavac
    :compileDebugNdk NO-SOURCE
    :compileDebugSources
    :mergeDebugShaders
    :compileDebugShaders
    :generateDebugAssets
    :mergeDebugAssets
    :transformClassesWithDexForDebug FAILED
    78 actionable tasks: 78 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.Action1 progress, System.String error) UnityEditor.Android.GradleWrapper.Run (System.String workingdir, System.String task, System.Action1 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()

I eventually got it working with the help of support from Mapbox, it was a plugin conflict

Would you be able to describe the fix, or link to it? I’m having the same problem and I’m using Mapbox

@davalosweldon Here’s the GitHub conversation that solved his problem: Plugin conflict with mapbox and Google Firebase · Issue #646 · mapbox/mapbox-unity-sdk · GitHub