So there are actually 90+ errors in my console when build fails. l also click checked the " Custom Gradle Property Template" in my Player/Publishing Settings and I added “android.useAndroidX=true” and “android.enableJetifier=true” at the top of the “gradleTemplate.properties” file in the directory
“C:\Users\Aun\Unity Projects\ThunderTraveler\Assets\Plugins\Android”, but still no luck.
I also have set the JAVA_HOME environent variable correctly (I don’t know if it has something to do with environment variables or not)
What I did before these errors?
Before getting these errors, I integrated “google admob sdk version 6.0.1” in my project and implemented banner and interstitial ads with test ids. They were working fine in editor. when I created a build, the build created successfully with no errors. But test ads were not working in build. Then I start force resolving android dependencies but resolving android dependencies failed. Then I realized there are some corrupt files in gradle cache in the directory " C:\Users\Aun.gradle\wrapper\dists\gradle-5.1.1 bin \ 90y9l8txxfw1s2o6ctiqeruwn " which are causing the failure of resolving android dependencies.Then I deleted the corrupt files of Gradle Cache. The files were " gradle-5.1.1-bin.zip " and " gradle-5.1.1-bin.zip.lck " that I deleted from the directory " C:\Users\Aun.gradle\wrapper\dists\gradle-5.1.1-bin\90y9l8txxfw1s2o6ctiqeruwn ".
Then I restarted the resolving android dependencies and it started successfully and started downloading “gradle-5.1.1-bin.zip” file in the directory " C:\Users\Aun .gradle \ wrapper\dists\gradle-5.1.1-bin\ 90y9l8txxfw1s2o6ctiqeruwn " But due to slow internet connection on my system it did not downloaded successfully and failed, so I had to remove these files form gradle cache again.
Then I went to the official Website of Gradle and downloaded the gradle 5.1.1 with the name “gradle-5.1.1-all.zip”. I copied this file into “C:\Users\Aun.gradle \wrapper \dists\gradle-5.1.1-bin\ 90y9l8txxfw1s2o6ctiqeruwn” and renamed it from “gradle-5.1.1-all.zip” to “gradle-5.1.1-bin.zip”. Then I restarted force dependency resolver for android and It completed successfully with no error. But When I start building game for android, the build crashed with the error like " Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 " and other errors that I mentioned earlier.
I am using following tools:
Unity 2019.4.15f1
java version “1.8.0_271”
Google Admob version 6.0.1
Any idea how to fix this issue?
Thanks in Advance.
@Yury-Habets Thank you for pointing out this error. "C:\Users\Aun\UnityProjects\ThunderTraveler\Temp\gradleOut\launcher\build\intermediates\merged_manifests\release\AndroidManifest.xml : 41 : AAPT : error: unexpected element <queries> found in <manifest>."
After exploring this error I was able to fix it.
Solution:
Now to fix this error, go to Player Settings > Publishing Settings > and then tick “Custom Base Gradle Template”. So it will generate file at the location " assets / plugins / Android / baseProjectTemplate.gradle. Open this new generated file " baseProjectTemplate.gradle " and change the value of " classpath ‘com.android.tools.build:gradle:3.4.0’ " to
" classpath ‘com.android.tools.build:gradle:3.4.3’ ". Save these changes in a file and close it.
Now Restart Unity and start build for android. Since you are building first time after making changes, make sure to have proper internet connection because Unity will download some files during build time. Otherwise your build may crash with no internet connection. That’s all you need to do.
queries in Android Manifest is supported from specific gradle versions which were released later. So, you need may need to adjust the gradle version so that its supported with in unity.
If you want to know more details,
If Target Api is >= 30, Make sure your Unity version supports any of the minimum android gradle versions starting from 3.3.3, 3.4.3, 3.5.4, 3.6.4, 4.0.1.
Update:
Enable base gradle template option in publishing settings of Player Settings and update the android gradle plugin version in that file.
This error has caused me to lose the ability to build anything with unity. I’ve tried every single solution and nothing works. I’ve even installed other versions of Unity. These are the errors I’m Still getting:
A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
java.lang.OutOfMemoryError (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.
stderr[
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ‘:launcher:packageDebug’.
A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
java.lang.OutOfMemoryError (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.
What is the deal with this? It just started out of the blue and now I have no way to use any version of unity. Even after a complete restore, this thing keeps coming up. Any help beyond the already tried methods of checking and unchecking would be most appreciated.
I have had this issue tried everything here and nothing but simply putting my android sdk maximum target to the latest which is 33 it solved the issue!
FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ‘:launcher:processReleaseResources’. > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade > Android resource linking failed /Users/…/Android/Prj/IL2CPP/Gradle/unityLibrary/build/intermediates/library_manifest/release/AndroidManifest.xml:35:9-85: AAPT: error: unexpected element found in .
Any ideas? I’m building to this version. In Unity 2021.3.23f1
FAILURE: Build failed with an exception. * What went wrong: Execution failed for task :launcher:processReleaseResources. > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade > Android resource linking failed. C:\Users\Uche-Orji Michael.gradle\caches\transforms-2\files-2.1\cac0526fac8a06cd07b67df880360aca\jetified-facebook-common-15.2.0\AndroidManifest.xml:32:17-69: AAPT: error: unexpected element < property > found in < manifest>< application>. ```csharp
**manifest xmlns:android=“http://schemas.android.com/apk/res/android”
xmlns:tools=“http://schemas.android.com/tools”
package=“com.facebook.common” >
I upgraged my unity editor to 2022.3.10f1, and I change classpath ‘com.android.tools.build:gradle:4.1.0’ in my baseProjectTemplate.gradle to classpath ‘com.android.tools.build:gradle:7.1.2’ and everything started working well
plugins {
// If you are changing the Android Gradle Plugin version, make sure it is compatible with the Gradle version preinstalled with Unity
// See which Gradle version is preinstalled with Unity here Unity - Manual: Gradle for Android
// See official Gradle and Android Gradle Plugin compatibility table here Android Gradle plugin 8.5 release notes | Android Studio | Android Developers
// To specify a custom Gradle version in Unity, go do “Preferences > External Tools”, uncheck “Gradle Installed with Unity (recommended)” and specify a path to a custom Gradle version
id ‘com.android.application’ version ‘7.1.2’ apply false
id ‘com.android.library’ version ‘7.1.2’ apply false BUILD_SCRIPT_DEPS
}