I’m having a huge issue. I simply can’t build my game anymore on Android. It says there is an error with AAPT2 but it doesn’t make much sense to me. And it seems it manage to make the build if the addressables build it empty.
This is quite important for me since I have to ship my game in 6 days !
Anybody knows what the hell could be happening?
i forgot to say, I’m working on 2020.1.6
And exporting the project to android Studio doesn’t work either.
CommandInvokationFailure: Gradle build failed.
C:\Program Files\Unity\Hub\Editor\2020.1.6f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\bin\java.exe -classpath “C:\Program Files\Unity\Hub\Editor\2020.1.6f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-5.6.4.jar” org.gradle.launcher.GradleMain “-Dorg.gradle.jvmargs=-Xmx8192m” “assembleRelease”
stderr[
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
AAPT2 aapt2-3.6.0-6040484-windows Daemon #0: Unexpected error during link, attempting to stop daemon.
This should not happen under normal circumstances, please file an issue if it does.
BUILD FAILED in 1m 11s
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
]
stdout[
Starting a Gradle Daemon, 1 incompatible Daemon could not be reused, use --status for details
Configure project :launcher
WARNING: The option ‘android.enableR8’ is deprecated and should not be used anymore.
It will be removed in a future version of the Android Gradle plugin, and will no longer allow you to disable R8.
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2020.1.6f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\build-tools\28.0.3\package.xml. Probably the SDK is read-only
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2020.1.6f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platform-tools\package.xml. Probably the SDK is read-only
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2020.1.6f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platforms\android-28\package.xml. Probably the SDK is read-only
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2020.1.6f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\tools\package.xml. Probably the SDK is read-only
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2020.1.6f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\build-tools\28.0.3\package.xml. Probably the SDK is read-only
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2020.1.6f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platform-tools\package.xml. Probably the SDK is read-only
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2020.1.6f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platforms\android-28\package.xml. Probably the SDK is read-only
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2020.1.6f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\tools\package.xml. Probably the SDK is read-only
Task :unityLibrary:preBuild UP-TO-DATE
Task :launcher:preBuild UP-TO-DATE
Task :unityLibrary:preReleaseBuild UP-TO-DATE
Task :launcher:preReleaseBuild UP-TO-DATE
Task :unityLibrary:compileReleaseAidl NO-SOURCE
Task :unityLibrary:packageReleaseRenderscript NO-SOURCE
Task :unityLibrary:compileReleaseRenderscript NO-SOURCE
Task :launcher:generateReleaseBuildConfig
Task :unityLibrary:generateReleaseBuildConfig
Task :launcher:compileReleaseAidl NO-SOURCE
Task :launcher:compileReleaseRenderscript NO-SOURCE
Task :unityLibrary:generateReleaseResValues
Task :unityLibrary:generateReleaseResources
Task :launcher:mainApkListPersistenceRelease
Task :launcher:generateReleaseResValues
Task :launcher:generateReleaseResources
Task :launcher:createReleaseCompatibleScreenManifests
Task :launcher:extractDeepLinksRelease
Task :launcher:prepareLintJar
Task :unityLibrary:packageReleaseResources
Task :launcher:checkReleaseDuplicateClasses
Task :launcher:mergeReleaseShaders
Task :launcher:compileReleaseShaders
Task :launcher:generateReleaseAssets
Task :launcher:processReleaseJavaRes NO-SOURCE
Task :launcher:mergeReleaseJniLibFolders
Task :unityLibrary:extractDeepLinksRelease
Task :unityLibrary:mergeReleaseShaders
Task :unityLibrary:compileReleaseShaders
Task :unityLibrary:generateReleaseAssets
Task :launcher:validateSigningRelease
Task :launcher:mergeReleaseResources
Task :launcher:desugarReleaseFileDependencies
Task :launcher:mergeExtDexRelease
Task :unityLibrary:packageReleaseAssets
Task :unityLibrary:processReleaseJavaRes NO-SOURCE
Task :unityLibrary:mergeReleaseJniLibFolders
Task :unityLibrary:prepareLintJarForPublish
Task :unityLibrary:compileReleaseLibraryResources
Task :unityLibrary:processReleaseManifest
Task :unityLibrary:bundleLibResRelease
Task :unityLibrary:javaPreCompileRelease
Task :unityLibrary:parseReleaseLocalResources
Task :unityLibrary:mergeReleaseNativeLibs
Task :unityLibrary:stripReleaseDebugSymbols
Task :unityLibrary:copyReleaseJniLibsProjectOnly
Task :unityLibrary:generateReleaseRFile
Task :unityLibrary:compileReleaseJavaWithJavac
Task :unityLibrary:bundleLibRuntimeRelease
Task :unityLibrary:bundleLibCompileRelease
Task :launcher:mergeReleaseAssets
Task :launcher:processReleaseManifest
Task :launcher:processReleaseResources FAILED
Task :launcher:javaPreCompileRelease
39 actionable tasks: 39 executed
]
exit code: 1
UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <5f8140421e7d41ada100b629c3033aa7>:0)
UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <5f8140421e7d41ada100b629c3033aa7>:0)
UnityEditor.Android.Command.Run (System.String command, System.String args, System.String workingdir, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <5f8140421e7d41ada100b629c3033aa7>:0)
UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action1[T] progress, System.String error) (at <5f8140421e7d41ada100b629c3033aa7>:0) UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingdir, System.String task, System.Action
1[T] progress) (at <5f8140421e7d41ada100b629c3033aa7>:0)
Rethrow as GradleInvokationException: Gradle build failed
UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingdir, System.String task, System.Action`1[T] progress) (at <5f8140421e7d41ada100b629c3033aa7>:0)
UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <5f8140421e7d41ada100b629c3033aa7>:0)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <5f8140421e7d41ada100b629c3033aa7>: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 <5f8140421e7d41ada100b629c3033aa7>:0)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <5f8140421e7d41ada100b629c3033aa7>:0)
UnityEditor.Android.PostProcessAndroidPlayer.PostProcess (UnityEditor.BuildTarget target, System.String stagingAreaData, System.String stagingArea, System.String playerPackage, System.String installPath, System.String companyName, System.String productName, UnityEditor.BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at <5f8140421e7d41ada100b629c3033aa7>:0)
UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <5f8140421e7d41ada100b629c3033aa7>:0)
UnityEditor.PostprocessBuildPlayer.Postprocess (UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget target, 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 <67055f1be3654e2a987254d5437ee5b8>:0)
UnityEngine.GUIUtility:processEvent(Int32, IntPtr, Boolean&)
ok, after a lot of tries, it seems the build crashes if there are too many bundles in the streaming assets folder…
I had to pack the bundles to “pack together” or “by label” to make it work.
The problem is that now, the ingame loadings are super slow, and the RAM used is much higher. So I now expect the game to crash on low-end devices…
1 Like
I have the same problem, but everything happens when I put GoogleMobileAds, (well, it also happens when I put vuforia, but I already solved that) apparently it is more difficult to compile in UNITY than to carry out the same project itself. I am not a programmer, but with all the Unity errors, apparently that I am a simple novice who only knows how to put “Hello world” I solve or try to solve the Unity problems.
hello, is there a workaround now ?
1 Like
This is a compatible bug between com.android.tools.build:gradle:3.6.0 and unity 2020, Please do following step to resolve:
1, Edit → Player Setting → Publishing Settings, click “Custom Base Gradle Template” blew the Build section.
2, You will find a “Assets\Plugins\Android\baseProjectTemplate.gradle” file was generated, open it by text editor.
3, change
“classpath ‘com.android.tools.build:gradle:3.6.0’”
into
“classpath ‘com.android.tools.build:gradle:3.4.0’”
Build again, and don’t forget to add it to your CVS.
If you get solved and like this solution, please do me a favor to mark a star for this repo:
https://github.com/yasio/yasio
This repo’s author find this solution and he told me.
7 Likes
Jorge Olvera:
I have the same problem, but everything happens when I put GoogleMobileAds, (well, it also happens when I put vuforia, but I already solved that) apparently it is more difficult to compile in UNITY than to carry out the same project itself. I am not a programmer, but with all the Unity errors, apparently that I am a simple novice who only knows how to put “Hello world” I solve or try to solve the Unity problems.
I had a similar issue when builds started failing after integrating GoogleMobileAds and came across this thread. Solved it by enabling Custom Gradle Properties in Publishing Settings, and adding android.useAndroidX=true and android.enableJetifier=true to the settings file. Also enabled JetBrains via the External Dependency Manager → Android Resolver → Settings but that didn’t work on its own without the properties file change
Solved Thank you jerry_tianzhizhi
i am still facing in unity 2020.2.7 with grale 5.6.4
the option ‘android.enableR8’ is deprecated and should not be used anymore. It will be removed in a future version of the Android Gradle plugin, and will no longer allow you to disable R8
Set to minimum API level to at least 21. It worked for me.
On Unity 2020.3.19 I’ve got the minimum api set to 23 and I’m getting this error.
1 Like
Wasp3r
November 9, 2021, 8:15am
12
Same thing, 2020.3.7 and minimum API set to 23
1 Like
Changing both the minimum and target API’s to level 29 (which I believe is what’s installed on my Quest 2, for which this build is intended) – I would get the following error:
With Publish Settings>>Minify>>Use R8 unticked, I got this error:
Configure project :launcher
WARNING: The option setting ‘android.enableR8=false’ is deprecated.
It will be removed in version 5.0 of the Android Gradle plugin.
You will no longer be able to disable R8
Build-tool 31.0.0 is missing DX at D:\Android\SDK\build-tools\31.0.0\dx.bat
If it was ticked, I got this error:
Configure project :launcher
WARNING: The option setting ‘android.enableR8=true’ is deprecated.
It will be removed in version 5.0 of the Android Gradle plugin.
You will no longer be able to disable R8
Build-tool 31.0.0 is missing DX at D:\Android\SDK\build-tools\31.0.0\dx.bat
So, ticking the box is deprecated and not ticking the box is deprecated??!
I reinstalled Android SDK 12 (API 31) despite not even targeting that api, yet the build would still fail with multiple complaints about it being corrupted. For whatever reason, the dx.bat file was missing from that API installation, as the above error messages say. So, I fabricated it based on the d8.bat file – making the couple of changes that are different between the d8.bat and dx.bat in other API installations.
Line 53
set jarfile=d8.jar
Changes to
set jarfile=dx.jar
Line 109
call “%java_exe%” %javaOpts% -Djava.ext.dirs=“%frameworkdir%” -cp “%jarpath%” com.android.tools.r8.D8 %params%
Changes to
call “%java_exe%” %javaOpts% -Djava.ext.dirs=“%frameworkdir%” -jar “%jarpath%” %params%
Since the dx.jar file is also missing the build will still fail…
No idea why Android Studio isn’t installing the dx.jar and dx.bat files for this particular api. Searching the internet I found somebody solved this by copying the dx.dar file from their API 30 installation, which I then tried.
…and it worked!
jerry_tianzhizhi:
This is a compatible bug between com.android.tools.build:gradle:3.6.0 and unity 2020, Please do following step to resolve:
1, Edit → Player Setting → Publishing Settings, click “Custom Base Gradle Template” blew the Build section.
2, You will find a “Assets\Plugins\Android\baseProjectTemplate.gradle” file was generated, open it by text editor.
3, change
“classpath ‘com.android.tools.build:gradle:3.6.0’”
into
“classpath ‘com.android.tools.build:gradle:3.4.0’”
Build again, and don’t forget to add it to your CVS.
If you get solved and like this solution, please do me a favor to mark a star for this repo:
https://github.com/yasio/yasio
This repo’s author find this solution and he told me.
Hey!! Thnx for the Solution…it works
2 Likes
Hello!
In case there is somebody with this problem and mentioned solution did not work for him, I had a similar error during android build using 2020.3.26 and in my case it was caused by my antivirus blocking some android SDK files for some reason. I am using Avast but you might have the same problem with other antivirus as well.
I have temporarily disabled my antivirus before build and it built without problem, you can try it as well.