-
Notifications
You must be signed in to change notification settings - Fork 46
Unity 2021.3.40f1 Android build fails. #1070
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight. |
Hi @IShix-g, thanks for reaching out. Unfortunately, it seems that there's an issue with Firebase SDK version
Now according to the Unity forums, Unity Editors currently do not support compileSdkVersion 34, and is currently being worked on by their engineers. There are workarounds, by the Unity engineer, however I haven't tried it myself. While waiting for Unity to fix the version to support compileSdkVersion 34, another mitigation would be to downgrade Firebase SDK version 11.9.0 and also lower your compileSdkVersion to 33 or lower. Let me know if that works. Thanks! |
Hi @argzdev, I tried following the instructions and was able to install it without any problems. If you specify Unity 2019.1 or later, it would be helpful if you could at least develop the plugin with the current LTS in mind. I know this may be difficult, but please consider this. Thank you for your reply. |
Has anyone tried/got a solid work around for this? Getting the same error and tried the Unity engineer instructions, absolutely nothing has worked thus far. Been trying to build for days and getting nowhere. Any instructions for a work around posted here would be truly appreciated. (as unity forums appear to be down) |
Hi @lilzubr, In my case, I am using the older version, 11.6.0. I'd like to hear how you all handle this. Build environmentUnity : 2021.3.40f1 (sillicon) External Tools![]() Player > Android > BuildUnity 2021.3.37f1 or later : Updated Android Gradle Plugin to 4.2.2 (from 4.0.1). Custom Base Gradle Template no longer requires an upgrade process. |
I got this same error when using the latest Unity 2022.3.38f1 LTS with the latest Firebase unity SDK 12.1.0 while targeting Android 34:
The problem doesn't happen when targeting Android 33. @argzdev The Unity thread you linked to is about a different "AAPT2" error that Unity devs are working on fixing in Unity 2021 LTS (see Unity announcement about Unity 2021 + Android 34 build failure). However, Unity devs claim Unity 2022 doesn't have this "AAPT2" error and I can confirm it's indeed the case. Their "AAPT2" workaround does work with Unity 2021 but it only addresses the "AAPT2" error and after that I'm getting the "Failed to transform" error above. From the many Unity threads I have been following, Unity devs are not working on the above error which only happens when you have a dependency on Firebase. I tried the following combinations and can't get Android 34 build to work:
Google has a deadline of 08/30/2024 to require all app updates to target Android 34. There is a risk that the Unity devs can't get the AAPT2 error fixed in time for Unity 2021. I think it's very unlikely we can count on them to get the "Failed to transform" error fixed in time. Can Firebase devs help here? |
After more testing, I'm able to get Android 34 to build with either of the following:
This must be a compatibility issue due to the old Gradle/AGP version used by Unity. |
Thanks for the extra details and workaround, @fengx1024. I'm sure this'll help a lot of developers with the similar issue. For what it's worth, the problem is due to the version compatibility of the Unity editor with the Android Gradle plugin. In the Unity documentations, the version compatibility is shown that the Unity Editor versions does not have AGP 8.1+. This is not something we can control on Firebase side.
We can only wait for Unity to fully support AGP 8 onwards. |
Same problem here as well, but 11.6.0 and below works without issue:
Just curious, how did the new SDK versions with issues get passed and released? This is 100% reproducible and should be able to catch by testing against different Unity versions before releasing. |
@argzdev
I believe that many developers only use LTS. I can't imagine when it will be supported. |
That table is now outdated, new Gradle/AGP versions included in latest Unity versions are:
|
Builds seem to be failing in newer Unity 2021.3.41f1 with error message:
To reproduce:
|
Hi all, I personally haven't been able to reliably reproduce this issue, the closest I have come has been installing 2021.3.20f1 (really, any version before 38f1), which originally only has android-29 and 30 platform support, which gives me a different error than everyone else is reporting ( My best guess is that there is something different about my own machine, and the test machines, between the various tool installations, that is being used to avoid this issue. However, looking at the generated Android project created by Unity, all the paths seem to pointing to the Android SDK, NDK, Java JDK, and Gradle version that comes with that version of Unity. If you all could double check that as well, I would appreciate it, as that might be a possible explanation, that it is pulling in a different version of those tools than expected. Another thing that could be shared would be the final generated build.gradle file, with the actual numbers it is using. This should be in your Unity project at a path like
Note that the targetSdkVersion is 34, which is now required by the Firebase Android SDK, and thus the Firebase Unity SDK. Also, check the file at Also, as for why this became an issue with 11.7.0, that included an update to the Firebase Android SDK which increased the compileSdkVersion to 33 (https://firebase.google.com/support/release-notes/android#analytics_v21-4-0), and that number since increased to 34 with the 12.0.0 release, which included this Android dependency update (https://firebase.google.com/support/release-notes/android#2024-05-02). But if it isn't possible to target 33 or 34, a fallback option is to use 11.6.0, though I know the Play Store is going to start requiring the newer targets at some point, so ideally we can figure out what the issue is. |
@a-maurice I think you were not able to reproduce the error because your test app has a minSdkVersion too high. In my tests, the "Failed to transform" error only happens when minSdkVersion <= 23. |
Can we expect another version of Unity that has all the correct and compatible versions of Gradle, Android SDK etc? |
@fengx1024 Unfortunately, changing the minSdkVersion doesn't seem to cause a clean build to fail for me either, though that was a good callout. |
Same problem here. As said above upgrading to minSdkVersion >= 24 solves the issue, I couldn't do that |
Unity editor below Unity 6 don't support API 34 and there is major change in update so either target 33 with old plugin or just add below given file to make editor compatible. Also make user you gradle version is above 6.8 else you will get new errors. Please follow this link to add settingTemplate.gradle. |
Also as a fix option, you can use a version of unity that uses AGP 7.1.2 (e.g. 2022.3.30f1). Or for other versions of unity, you can downgrade AGP by enabling “Custom Base Gradle Template” in the project settings and downgrading the AGP version in Assets/Plugins/Android/settingsTemplate.gradle from 7.4.2 to 7.1.2. |
Which API are you targeting? |
Same error for me |
Related issue reported here: googlesamples/unity-jar-resolver#699 |
Hello! We have the same problem in preparing for Google own requirements. I suppose we are waiting this to be resolved on the next week? I really appreciate your time. We have 10+ projects and loaded development pipeline, with less than 1 month till deadline we have less and less time to finish. If we can help in any way - let me know! |
My project details: Platform: Mac M1 Unity version: 2021.3.31f1 (updating to 2021.3.41f1) Firebase products used: version 11.9.0 (updating to 12.1.0) Firebase.Analytics Firebase.App Firebase.Crashlytics Firebase.DynamicLinks Firebase.Messaging Firebase.Platform Firebase.RemoteConfig Firebase.TaskExtension Google.MiniJson Using ExternalDependencyManager: Yes Cur min android sdk: 22 (updating to 24) Cur target sdk: 33 (updating to 34) Steps: Upgrade project to 2021.3.41f1 Build- If you get the “build tools 32.0.0 is corrupted, install using sdk manager” error, then rename “/Applications/Unity/Hub/Editor/2021.3.41f1/PlaybackEngines/AndroidPlayer/SDK/build-tools/32.0.0/d8” file to dx and “/Applications/Unity/Hub/Editor/2021.3.41f1/PlaybackEngines/AndroidPlayer/SDK/build-tools/32.0.0/lib/d8.jar” to dx.jar Then, if you are getting “Could not find com.google.firebase:firebase-analytics-unity:12.1.0.” type errors, then follow this link. After doing this my build was successful without crashing. |
SDK 34 |
Thank you all for the alternative solutions. We've also made some changes on our side with the solution suggested by @manugildev. This pull request that is now available in the most EDM4U release If however, you'd like use this with Unity version
Note, the EDM4U is currently available in |
Unity : 2022.3.40f1 (sillicon) Cutom Main Gradle:Assets/Plugins/Android/mainTemplate.gradle
Custom Gradle Properties:Assets/Plugins/Android/gradleTemplate.properties
Custom gradle settings templateAssets/Plugins/Android/settingsTemplate.properties
Reproducing the issueGenerate an empty project for Unity 2022.3.40f1 Firebase Unity SDK Version12.2.0 Unity editor version2022.3.40f1 Installation Method.unitypackage Problematic Firebase Component(s)Analytics Additional SDKs you are usingFirebase Analytics : 12.2.0 only Targeted Platform(s)Android Platforms Unity editor platformWindows Scripting RuntimeIL2CPP Relevant Log Output
|
@Bestlis Your issue has already been reported googlesamples/unity-jar-resolver#703. As a workaround to fix it while Google investigates a real fix:
|
Thanks! It works!))🎉 |
Unfortunately it still broken for me even with the above fixes. I'm on Unity 2021.3.42f1 with latest firebase version. This is the error log i'm getting: This is actually inconsistent for me. It sometimes build successfully, but most of the time it will fail with the above error. Note here that these builds are being built using TeamCity for automation. |
@vincent-savysoda, taking a quick glance at your logs, Firebase is not causing the issue.
The issue is due to your code or setup that is causing the inconsistent build. Please file a new issue if you believe Firebase is this. Thanks! |
Hi folks, the Firebase Unity SDK version |
My workaround is as below: I think it's better. Because minSdkVersion can be the minimal that Unity can provide (22). My working environment:
|
What gradle file did you change to support sdk 22? |
Hey @StinkySteak, you may check out the solutions we've discussed here to support SDK 22. |
Description
Android build fails for Unity project with only Firebase Analytics installed.
For my game project, only Firebase Analytics and Messaging 11.6.0 pass build without problems, all versions after 11.7.0 fail to build.
Build environment
Unity : 2021.3.40f1 (sillicon)
Build Target : Android
Firebase Analytics : 12.1.0
Gradle Version : 4.2.2
Compile Sdk Version : 34
Minimum Sdk Version : 22
Target Sdk Version : 34
BuildToolsVersion : 30.0.2
Cutom Main Gradle:
Assets/Plugins/Android/mainTemplate.gradle
Custom Gradle Properties:
Assets/Plugins/Android/gradleTemplate.properties
Reproducing the issue
Firebase Unity SDK Version
12.1.0
Unity editor version
2021.3.40f1
Installation Method
.unitypackage
Problematic Firebase Component(s)
Analytics
Other Firebase Component(s) in use
No response
Additional SDKs you are using
Firebase Analytics : 12.1.0 only
Targeted Platform(s)
Apple Platforms
Unity editor platform
Mac
Scripting Runtime
IL2CPP
Release Distribution Type
Pre-built SDK from https://firebase.google.com/download/unity
Relevant Log Output
The text was updated successfully, but these errors were encountered: