Search Issue Tracker
Fixed
Fixed in 2021.3.41f1
Votes
0
Found in
2021.3.39f1
Issue ID
UUM-74132
Regression
No
[Android] Build fails in Unity 2021 when targetSDK 34 and depending on androidX legacy library
Steps to reproduce:
1. Create a blank project in Unity 2021.3 for Android
2. Make sure the “Target API Level” is set to API 34
3. Enable custom Gradle Template for 'unityLibrary'
4. Under 'deps' add " implementation "androidx.legacy:legacy-support-v4:1.0.0'""
5. Enable custom properties and add Jetifier & androidX
6. Build project.
Or get the zip folder attached (from Scopely's test project)
Actual results:
Build fails with
{code:java}
Execution failed for task ':launcher:processDebugResources'.
> 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.{code}
This library, alongside with v13 is one of the core Androidx legacy libraries and used by SDKs such as Facebook, OneSignal etc. Usages examples .
It is currently not know if other Libraries are also affected - I have tried sporadic androidX libraries but they compiled OK.
By August 31st 2024, users are required to target API 34 in order to update apps on the play store.
Expected results:
Build compiles with no errors
Reproducible with versions:
2021.3.x with targetSDK 34 and AGP 4.2.2 / Gradle 6.7.1 / Java 8 / Buld Tools 30
2021.3.x with target SDK 34 and updated build-tools to 31/32/33/34
Test result from others
AGP 4.2.2 / gradle 6.7.1 / 33 - success
AGP 4.2.2 / gradle 6.7.1 / 34 - fail
AGP 4.2.2 / gradle 7.6.2 / 34 - fail
AGP 7.0.0 / gradle 7.0.2 / 34 - fail
AGP 7.0.0 / gradle 7.6.2 / 34 - fail
AGP 7.1.0 / gradle 7.2 / 34 - success
AGP 7.1.0 / gradle 7.6.2 / 34 - success
Not reproducible with versions / combinations:
- Unity 2022, Unity 6 and default java/agp/gradle setup
- Unity 2021 by exporting the 2021.3 project and changing the Gradle version to 7.2 and the plugin to 7.1.3 externally
- Unity 2021 default java/agp/gradle, target SDK 34 AND changing compileSDK to 33 through a custom Template
Notes:
- This is not a Unity issue because the same behaviour is exhibited with a blank Android project with AGP 4.2.2 and Gradle 6.x configuration that targets SDK 34 and imports these libraries. (link)
- It seems to be an issue with gradle/agp itself
- compileSDK to 33 is a dirty temp solution because it may conflict with other plugins' requirements
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Required SpriteMask class (ID 331) is stripped when "Strip Engine Code" is enabled
- “Maximized serialized file backup not found” error is thrown when minimizing a window in a newly opened project
- Build stack trace contains invalid lines when building with IL2CPP using scripts with delegates containing generic types in the signature
- Entities Systems window has a “Show Full Player Loop” dropdown which does nothing when clicked after enabling “Show Full Player Loop”
- Entities Hierarchy Search “Show/Hide” button’s Lens Icon is blurry when the Editor is on an external monitor
Resolution Note (fix version 2021.3.41f1):
Fix build failure when targetSDK 34 and depending on androidX legacy library. Updated Gradle version to 7.5.1 (from 6.7.1), AGP version to 7.4.2 (from 4.2.2) and JDK to 11 (from 1.8)