firebase / firebase-unity-sdk

The Firebase SDK for Unity
http://firebase.google.com
Apache License 2.0
234 stars 38 forks source link

[Bug] Unity 2021.3.43f1 Android build fails. #1096

Closed Ls9257 closed 3 months ago

Ls9257 commented 3 months ago

Description

Android build fails for Unity project with only Firebase Analytics installed. In my project, I tested Firebase 11.6.0-12.2.0 and all builds failed.

Reproducing the issue

Unity : 2021.3.43f1 Build Target : Android Firebase Analytics : 12.2.0 Gradle Version : 7.4.2 Compile Sdk Version : 34 Minimum Sdk Version : 22 Target Sdk Version : 34

Firebase Unity SDK Version

12.2.0

Unity editor version

2021.3.43f1

Installation Method

.unitypackage

Problematic Firebase Component(s)

Analytics

Other Firebase Component(s) in use

Analytics

Additional SDKs you are using

No

Targeted Platform(s)

Android

Unity editor platform

Windows

Scripting Runtime

IL2CPP

Release Distribution Type

Pre-built SDK from https://firebase.google.com/download/unity

Relevant Log Output

CommandInvokationFailure: Gradle build failed. 
F:\Program Files\Unity\Hub\Editor\2021.3.43f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\bin\java.exe -classpath "F:\Program Files\Unity\Hub\Editor\2021.3.43f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-7.5.1.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "assembleRelease"

Environment Variables:
PROCESSOR_ARCHITECTURE = AMD64
TEMP = C:\Users\ADMINI~1\AppData\Local\Temp
AMPLITUDE_API_KEY_YELLOWBUCKET_DEV = 48835b4d1f5e342aefe5f016324d296a
GATEWAY_VM_OPTIONS = C:\jetbra\vmoptions\gateway.vmoptions
DriverData = C:\Windows\System32\Drivers\DriverData
USERDOMAIN = PC-20191031UDVW
CommonProgramFiles(x86) = C:\Program Files (x86)\Common Files
COMPUTERNAME = PC-20191031UDVW
DEBUG_ENV_VAR = UnityHub
LOGONSERVER = \\PC-20191031UDVW
AMPLITUDE_TOKEN_GREENBUCKET_PROD = ZpUcbAdZXJYzNSoHsAWtL_s_JppwWid9
PUBLIC = C:\Users\Public
ProgramData = C:\ProgramData
SESSIONNAME = Console
AMPLITUDE_TOKEN_YELLOWBUCKET_PROD = UYDQtPOw83dIfVy3SrW5oMyo7ru4PRkV
Path = C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\dotnet\;C:\Program Files (x86)\Java\jdk1.8.0_191\bin;C:\Program Files (x86)\Java\jdk1.8.0_191\jre\bin;C:\Users\Administrator\AppData\Local\Android\Sdk\platform-tools;C:\Users\Administrator\AppData\Local\Android\Sdk\tools;D:\Users\Administrator\AppData\Local\Programs\Python\Python312\Scripts\;D:\Users\Administrator\AppData\Local\Programs\Python\Python312\;C:\Users\Administrator\AppData\Local\Microsoft\WindowsApps;C:\Users\Administrator\.dotnet\tools;%DevEco Studio%;D:\Program Files\JetBrains\PyCharm 2024.1.1\bin;C:\Users\Administrator\AppData\Local\gitkraken\bin;F:\Program Files\JetBrains\JetBrains Rider 2023.1\bin;C:\Users\Administrator\AppData\Local\JetBrains\Toolbox\scripts;
APPDATA = C:\Users\Administrator\AppData\Roaming
RIDER_VM_OPTIONS = C:\jetbra\vmoptions\rider.vmoptions
windir = C:\Windows
AMPLITUDE_API_KEY_REDBUCKET_DEV = 46b8b46515e7632fc42a504b72e05fd0
ProgramFiles(x86) = C:\Program Files (x86)
ProgramW6432 = C:\Program Files
OS = Windows_NT
ANDROID_NDK_ROOT = F:\Program Files\Unity\Hub\Editor\2021.3.43f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK
DATAGRIP_VM_OPTIONS = C:\jetbra\vmoptions\datagrip.vmoptions
PROCESSOR_IDENTIFIER = Intel64 Family 6 Model 158 Stepping 13, GenuineIntel
HOMEPATH = \Users\Administrator
SystemRoot = C:\Windows
CLION_VM_OPTIONS = C:\jetbra\vmoptions\clion.vmoptions
AMPLITUDE_TOKEN_REDBUCKET_DEV = U4PSN7S7PuYVRODivvdcFwbu8R6IHGqa
JetBrains Rider = F:\Program Files\JetBrains\JetBrains Rider 2023.1\bin;
CHROME_CRASHPAD_PIPE_NAME = \\.\pipe\crashpad_2100_XFEPQICRVJXSAOUP
SystemDrive = C:
PROCESSOR_LEVEL = 6
CommonProgramFiles = C:\Program Files\Common Files
PyCharm = D:\Program Files\JetBrains\PyCharm 2024.1.1\bin;
JETBRAINS_CLIENT_VM_OPTIONS = C:\jetbra\vmoptions\jetbrains_client.vmoptions
DEVECOSTUDIO_VM_OPTIONS = C:\jetbra\vmoptions\devecostudio.vmoptions
USERDOMAIN_ROAMINGPROFILE = PC-20191031UDVW
JAVA_HOME = F:\Program Files\Unity\Hub\Editor\2021.3.43f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK
CommonProgramW6432 = C:\Program Files\Common Files
RUBYMINE_VM_OPTIONS = C:\jetbra\vmoptions\rubymine.vmoptions
AMPLITUDE_TOKEN_YELLOWBUCKET_DEV = wKi8foVigDditGFvmZewRFWsEbX9Y0YO
AMPLITUDE_API_KEY_GREENBUCKET_DEV = 3ded2a762163603391a425f688f990c8
AMPLITUDE_API_KEY_REDBUCKET_PROD = ca12bb461ea96f9bdf5df4ded7d52994
APPCODE_VM_OPTIONS = C:\jetbra\vmoptions\appcode.vmoptions
HOMEDRIVE = C:
AMPLITUDE_API_KEY_STAGING = 83ee04fccc67e4fcc7dd527c4c6f1e21
iGame = E:\iGame\
USERNAME = Administrator
AMPLITUDE_API_KEY_YELLOWBUCKET_PROD = e03a9bbe92dc38a88cdb068d24c65b46
PATHEXT = .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.BOX
AMPLITUDE_TOKEN_REDBUCKET_PROD = jTIgKs5KTZOjiqEEVdZFbgo_VRhABduL
NUMBER_OF_PROCESSORS = 8
PHPSTORM_VM_OPTIONS = C:\jetbra\vmoptions\phpstorm.vmoptions
AMPLITUDE_TOKEN_GREENBUCKET_DEV = 84H2gMm_FJzhr3mBaX1lM1JVukmCM7d9
PYCHARM_VM_OPTIONS = C:\jetbra\vmoptions\pycharm.vmoptions
AMPLITUDE_DEPLOYMENT_KEY_RED_BUCKET_DEV = client-wbjHYrmeSR87GmWOE7LDpf7sUySOIKHm
GOLAND_VM_OPTIONS = C:\jetbra\vmoptions\goland.vmoptions
PSModulePath = C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules
AMPLITUDE_API_KEY_GREENBUCKET_PROD = c86fea37a9e1d3f0878b96e15b111c7c
ComSpec = C:\Windows\system32\cmd.exe
WEBSTORM_VM_OPTIONS = C:\jetbra\vmoptions\webstorm.vmoptions
ORIGINAL_XDG_CURRENT_DESKTOP = undefined
ndk-stack = E:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\ndk-stack.cmd
PROCESSOR_REVISION = 9e0d
JETBRAINSCLIENT_VM_OPTIONS = C:\jetbra\vmoptions\jetbrainsclient.vmoptions
AMPLITUDE_DEPLOYMENT_KEY_RED_BUCKET_PROD = client-zH8Y7OK1i331EKuG77C6UxN8ygcM6LzS
TMP = C:\Users\ADMINI~1\AppData\Local\Temp
IDEA_VM_OPTIONS = C:\jetbra\vmoptions\idea.vmoptions
WEBIDE_VM_OPTIONS = C:\jetbra\vmoptions\webide.vmoptions
AMPLITUDE_API_KEY = 28f3cae0b33b8b3702120c9ed1a935aa
SENTRY_ACCESS_TOKEN = 3df78d9e53f8456aa90fbae044ce1a6261421ab1d0014674bc2e933477289017
ALLUSERSPROFILE = C:\ProgramData
DATASPELL_VM_OPTIONS = C:\jetbra\vmoptions\dataspell.vmoptions
STUDIO_VM_OPTIONS = C:\jetbra\vmoptions\studio.vmoptions
ProgramFiles = C:\Program Files
LOCALAPPDATA = C:\Users\Administrator\AppData\Local
USERPROFILE = C:\Users\Administrator
WOOTRIC_CLIENT_TOKEN = NPS-aa8be4c3

stderr[
ע: E:\JiaPeng\Beta\My project\Library\Bee\Android\Prj\IL2CPP\Gradle\unityLibrary\src\main\java\com\unity3d\player\UnityPlayerActivity.javaʹ�û򸲸����ѹ�ʱ�� API��
ע: �й���ϸ��Ϣ, ��ʹ�� -Xlint:deprecation ���±��롣
ERROR:D8: com.android.tools.r8.kotlin.H

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':launcher:mergeExtDexRelease'.
> Could not resolve all files for configuration ':launcher:releaseRuntimeClasspath'.
   > Failed to transform play-services-measurement-api-22.0.2.aar (com.google.android.gms:play-services-measurement-api:22.0.2) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=false, dexing-min-sdk=22, org.gradle.status=release, org.gradle.usage=java-runtime}.
      > Execution failed for DexingWithClasspathTransform: C:\Users\Administrator\.gradle\caches\transforms-3\64b0c7447f3c6bbe741650ffe23d8c98\transformed\jetified-play-services-measurement-api-22.0.2-runtime.jar.
         > Error while dexing.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
java.lang.StackOverflowError (no error message)

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
==============================================================================

* Get more help at https://help.gradle.org

BUILD FAILED in 13s
]
stdout[
WARNING:We recommend using a newer Android Gradle plugin to use compileSdk = 34

This Android Gradle plugin (7.4.2) was tested up to compileSdk = 33

This warning can be suppressed by adding
    android.suppressUnsupportedCompileSdk=34
to this project's gradle.properties

The build will continue, but you are strongly encouraged to update your project to
use a newer Android Gradle Plugin that has been tested with compileSdk = 34
> Task :unityLibrary:preBuild UP-TO-DATE
> Task :unityLibrary:preReleaseBuild UP-TO-DATE
> Task :unityLibrary:compileReleaseAidl NO-SOURCE
> Task :launcher:preBuild UP-TO-DATE
> Task :launcher:preReleaseBuild UP-TO-DATE
> Task :launcher:compileReleaseAidl NO-SOURCE
> Task :launcher:generateReleaseBuildConfig UP-TO-DATE
> Task :launcher:javaPreCompileRelease UP-TO-DATE
> Task :launcher:generateReleaseResValues UP-TO-DATE
> Task :launcher:createReleaseCompatibleScreenManifests UP-TO-DATE
> Task :launcher:extractProguardFiles UP-TO-DATE
> Task :launcher:writeReleaseApplicationId UP-TO-DATE
> Task :launcher:analyticsRecordingRelease
> Task :launcher:mergeReleaseJniLibFolders UP-TO-DATE
> Task :launcher:checkReleaseDuplicateClasses
> Task :launcher:mergeReleaseShaders UP-TO-DATE
> Task :launcher:compileReleaseShaders NO-SOURCE
> Task :launcher:generateReleaseAssets UP-TO-DATE
> Task :launcher:processReleaseJavaRes NO-SOURCE
> Task :launcher:collectReleaseDependencies
> Task :unityLibrary:mergeReleaseJniLibFolders
> Task :unityLibrary:compileReleaseRenderscript NO-SOURCE
> Task :unityLibrary:generateReleaseResValues UP-TO-DATE
> Task :unityLibrary:extractDeepLinksForAarRelease UP-TO-DATE
> Task :unityLibrary:generateReleaseBuildConfig UP-TO-DATE
> Task :launcher:sdkReleaseDependencyData
> Task :unityLibrary:generateReleaseResources UP-TO-DATE
> Task :launcher:validateSigningRelease UP-TO-DATE
> Task :launcher:writeReleaseAppMetadata UP-TO-DATE
> Task :launcher:writeReleaseSigningConfigVersions UP-TO-DATE
> Task :unityLibrary:packageReleaseResources UP-TO-DATE
> Task :unityLibrary:parseReleaseLocalResources UP-TO-DATE
> Task :unityLibrary:processReleaseManifest UP-TO-DATE
> Task :unityLibrary:mergeReleaseNativeLibs
> Task :unityLibrary:javaPreCompileRelease UP-TO-DATE
> Task :unityLibrary:mergeReleaseShaders UP-TO-DATE
> Task :unityLibrary:compileReleaseShaders NO-SOURCE
> Task :unityLibrary:generateReleaseAssets UP-TO-DATE
> Task :unityLibrary:stripReleaseDebugSymbols
> Task :unityLibrary:generateReleaseRFile
> Task :unityLibrary:packageReleaseAssets
> Task :unityLibrary:extractReleaseAnnotations
> Task :launcher:mergeReleaseAssets
> Task :unityLibrary:copyReleaseJniLibsProjectAndLocalJars
> Task :launcher:compressReleaseAssets

> Task :unityLibrary:compileReleaseJavaWithJavac

> Task :unityLibrary:mergeReleaseGeneratedProguardFiles UP-TO-DATE
> Task :unityLibrary:mergeReleaseConsumerProguardFiles UP-TO-DATE
> Task :unityLibrary:packageReleaseRenderscript NO-SOURCE
> Task :launcher:compileReleaseRenderscript NO-SOURCE
> Task :unityLibrary:prepareLintJarForPublish UP-TO-DATE
> Task :unityLibrary:prepareReleaseArtProfile UP-TO-DATE
> Task :unityLibrary:processReleaseJavaRes UP-TO-DATE
> Task :unityLibrary:writeReleaseAarMetadata UP-TO-DATE
> Task :unityLibrary:extractDeepLinksRelease UP-TO-DATE
> Task :unityLibrary:compileReleaseLibraryResources UP-TO-DATE
> Task :launcher:mapReleaseSourceSetPaths
> Task :unityLibrary:bundleLibResRelease UP-TO-DATE
> Task :unityLibrary:bundleLibRuntimeToJarRelease UP-TO-DATE
> Task :unityLibrary:createFullJarRelease UP-TO-DATE
> Task :unityLibrary:writeReleaseLintModelMetadata UP-TO-DATE
> Task :launcher:generateReleaseResources UP-TO-DATE
> Task :launcher:checkReleaseAarMetadata
> Task :unityLibrary:bundleLibCompileToJarRelease
> Task :unityLibrary:copyReleaseJniLibsProjectOnly
> Task :unityLibrary:mergeReleaseJavaResource
> Task :unityLibrary:syncReleaseLibJars UP-TO-DATE
> Task :unityLibrary:bundleReleaseLocalLintAar
> Task :launcher:desugarReleaseFileDependencies
> Task :launcher:extractDeepLinksRelease UP-TO-DATE
> Task :launcher:mergeReleaseResources
> Task :launcher:processReleaseMainManifest
> Task :launcher:processReleaseManifest
> Task :launcher:mergeReleaseNativeLibs

> Task :launcher:mergeExtDexRelease FAILED

> Task :launcher:processReleaseManifestForPackage
60 actionable tasks: 27 executed, 33 up-to-date
]
exit code: 1
UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <2b14495ea31d4b37b57e542ae0104c90>:0)
UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <2b14495ea31d4b37b57e542ae0104c90>:0)
UnityEditor.Android.Command.Run (System.String command, System.String args, System.String workingdir, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <2b14495ea31d4b37b57e542ae0104c90>:0)
UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action`1[T] progress, System.String error) (at <2b14495ea31d4b37b57e542ae0104c90>:0)
UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, Unity.Android.Gradle.AndroidGradle androidGradle, System.String workingdir, System.String task, System.Action`1[T] progress) (at <2b14495ea31d4b37b57e542ae0104c90>:0)
Rethrow as GradleInvokationException: Gradle build failed
UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, Unity.Android.Gradle.AndroidGradle androidGradle, System.String workingdir, System.String task, System.Action`1[T] progress) (at <2b14495ea31d4b37b57e542ae0104c90>:0)
UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <2b14495ea31d4b37b57e542ae0104c90>:0)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <2b14495ea31d4b37b57e542ae0104c90>:0)
Rethrow as BuildFailedException: Exception of type 'UnityEditor.Build.BuildFailedException' was thrown.
UnityEditor.Android.PostProcessor.CancelPostProcess.AbortBuild (System.String title, System.String message, System.Exception ex) (at <2b14495ea31d4b37b57e542ae0104c90>:0)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <2b14495ea31d4b37b57e542ae0104c90>:0)
UnityEditor.Android.PostProcessAndroidPlayer.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, AndroidPlayerBuildProgram.Data.AndroidPlayerBuildProgramOutput buildProgramOutput) (at <2b14495ea31d4b37b57e542ae0104c90>:0)
UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <2b14495ea31d4b37b57e542ae0104c90>:0)
UnityEditor.PostprocessBuildPlayer.Postprocess (UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget target, System.Int32 subtarget, System.String installPath, System.String companyName, System.String productName, System.Int32 width, System.Int32 height, UnityEditor.BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at <ea43272efbac4151b76b66ed968f32af>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

If using CocoaPods for Apple platforms, the project's Podfile.lock

Assets/Plugins/Android Android.zip

google-oss-bot commented 3 months ago

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

Ls9257 commented 3 months ago

I tested 10.5.0 and had the same problem, but I changed to other SDKS that worked, such as Admob

argzdev commented 3 months ago

Thanks for reaching out, @Ls9257. This issue could be related to this r8 issue. The r8 tool included with lower versions of Gradle doesn't seem to work correctly. Could you try these solutions and see if it works?

  1. Change Minimum Sdk Version to 24

or

  1. Enable Minify via Project Settings > Publishing Settings > Minify > Release/Debug.

Let me know if it works. Thanks!

caseypugh commented 3 months ago

I was having the same issue and been through all the different Github issue threads and their suggestions. I'm using:

Bumping the min sdk version to 24 does work, however, it's not a solution in my case since I have a production app that would remove support for many users. Also, the minifying Release/Debug didnt do anything for me.

So for anyone looking to keep their min sdk version at 23 the combination of these two hacks worked for me: