Hi folks,
We have been informed of build failures when including certain Plugins (such as Facebook and OneSignal) in Unity 2021 projects and targeting API 34. The error displayed is similar to:
> A failure occurred while executing com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction
> AAPT2 aapt2-4.2.2-7147631-osx Daemon #0: Unexpected error during link, attempting to stop daemon.
This should not happen under normal circumstances, please file an issue if it does.
This appears to be an AGP (Android Gradle Plugin) 4.x issue that has been fixed in newer AGP versions (7.2+). It is encountered when specific legacy libraries are added by 3rd-party plugins as dependencies to an Android Project, and the project targets API 34.
The libraries we have currently identified as problematic are:
androidx.legacy:legacy-support-v4:1.0.0androidx.legacy:legacy-support-v13:1.0.0
We have not observed this issue with other AndroidX libraries.
What Unity is doing
For stability purposes, once a Unity version becomes LTS, we ālockā Android tooling major versions over the LTS lifespan. This is a rare scenario where we have decided to āunlockā. Third-party plugins are still using these legacy libraries, and the AGP issue has not yet been fixed in 4.x.
As a result, we are updating the engine tooling for 2021.3 with high priority. The updated 2021.3 tooling will map 2022.3 also making the upgradeability between LTS versions smoother.
Changes:
- Current 2021.3.40f1 tooling AGP 4.2.2 / Gradle 6.7.1 / Java 8
- Upcoming 2021.3.XXf1 tooling AGP 7.4.2 / Gradle 7.5.1 / Java 11
If you are a game developer on Unity 2021 affected by the issue:
To test and target API 34 in the meantime
Option 1
Export your game as an Android Studio Project. Update the requirements to minimum AGP 7.2.0 / Gradle 7.2.0 / Java 11
Option 2
Evaluate whether these plugins are needed in your project and whether those library dependencies are actually used by those plugins.
If you are a plugin developer
Consider moving away from Android legacy libraries that have not been updated since 2018. Replace your productsā dependencies with androidX specific equivalents.
FAQ
When will the updated 2021 be released?
Because it involves a major Java/Gradle/AGP upgrade for the Engine, and the focus of an LTS is stability, we cannot commit yet to a definite release date. Our ambition is the next 2021 LTS patch (end of July 2024), given the engineās stability is preserved. We will provide an update as soon as we can confirm.
Are any other Unity versions impacted by this issue?
No other supported Unity versions are impacted. We can confirm that Unity 2022 LTS and Unity 6 do not exhibit this behaviour. Unity 2020 or older are almost certainly affected.
The deadline for targeting API 34 is August 31 - what if I donāt have enough time?
We have informed Google about the impact of this AGP issue to Unity Creators. You are allowed to request an extension until November using the usual Google Play Console / Policy pages. Usually this opens around the beginning of August. Please mention Unity 2021 and AGP/Legacy Library issues in your extension request.
I am on 2021.3 but not affected by the issue - what do I need to do?
We recommend that users on LTS receive the latest patch releases. In this case, you can upgrade at your convenience. As this is a major update to Android tooling, please ensure your Templates, build setup, and integrations work as expected.
Iām on an unsupported version of Unity (2020 or older). What can I do?
Updates are no longer provided for these versions. We recommend either updating to a supported LTS stream or exporting your project to Android Studio and following Option 1 above.
Can I direct Unity to use a different version of Java/Gradle/AGP?
You can, through the Editor Preferences/External Tools, and Custom Android Templates. However in this case a different major Java version is required (11) by AGP 7.x. Unity releases are ālockedā to major compatible Java versions. Unity 2021 is currently locked to Java 8.x and changing to Java 11 will not work. The only alternative is to export to Android Studio.
