Android build failed on 2021 LTS

Include the following details (edit as applicable):

  • Issue category: Unity Example Package
  • Device type & OS version: Android
  • Host machine & OS version: Windows 10
  • Issue Environment : Unity
  • ARDK version: 2.3
  • Unity version: 2021.3.12

Description of the issue:

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
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2021.3.12f1c2\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\build-tools\30.0.2\package.xml. Probably the SDK is read-only
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2021.3.12f1c2\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platform-tools\package.xml. Probably the SDK is read-only
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2021.3.12f1c2\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platforms\android-29\package.xml. Probably the SDK is read-only
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2021.3.12f1c2\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platforms\android-30\package.xml. Probably the SDK is read-only
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2021.3.12f1c2\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\tools\package.xml. Probably the SDK is read-only

Task :launcher:preBuild UP-TO-DATE
Task :unityLibrary:preBuild UP-TO-DATE
Task :launcher:preReleaseBuild UP-TO-DATE
Task :unityLibrary:preReleaseBuild UP-TO-DATE
Task :unityLibrary:compileReleaseAidl NO-SOURCE
Task :launcher:generateReleaseBuildConfig UP-TO-DATE
Task :unityLibrary:packageReleaseRenderscript NO-SOURCE
Task :launcher:compileReleaseAidl NO-SOURCE
Task :unityLibrary:compileReleaseRenderscript NO-SOURCE
Task :launcher:compileReleaseRenderscript NO-SOURCE
Task :unityLibrary:generateReleaseResValues UP-TO-DATE
Task :launcher:javaPreCompileRelease UP-TO-DATE
Task :unityLibrary:generateReleaseResources UP-TO-DATE
Task :launcher:generateReleaseResValues UP-TO-DATE
Task :launcher:generateReleaseResources UP-TO-DATE
Task :launcher:createReleaseCompatibleScreenManifests UP-TO-DATE
Task :launcher:extractDeepLinksRelease UP-TO-DATE
Task :unityLibrary:packageReleaseResources UP-TO-DATE
Task :launcher:prepareLintJar UP-TO-DATE
Task :unityLibrary:extractDeepLinksRelease UP-TO-DATE
Task :unityLibrary:compileReleaseLibraryResources UP-TO-DATE
Task :unityLibrary:parseReleaseLocalResources UP-TO-DATE
Task :unityLibrary:generateReleaseBuildConfig UP-TO-DATE
Task :unityLibrary:javaPreCompileRelease UP-TO-DATE
Task :unityLibrary:prepareLintJarForPublish UP-TO-DATE
Task :launcher:mergeReleaseResources UP-TO-DATE
Task :unityLibrary:mergeReleaseShaders UP-TO-DATE
Task :launcher:desugarReleaseFileDependencies UP-TO-DATE
Task :unityLibrary:compileReleaseShaders NO-SOURCE
Task :unityLibrary:generateReleaseAssets UP-TO-DATE
Task :launcher:checkReleaseDuplicateClasses UP-TO-DATE
Task :launcher:mergeExtDexRelease UP-TO-DATE
Task :launcher:mergeReleaseShaders UP-TO-DATE
Task :launcher:compileReleaseShaders NO-SOURCE
Task :launcher:generateReleaseAssets UP-TO-DATE
Task :launcher:processReleaseJavaRes NO-SOURCE
Task :launcher:collectReleaseDependencies UP-TO-DATE
Task :launcher:sdkReleaseDependencyData UP-TO-DATE
Task :launcher:mergeReleaseJniLibFolders UP-TO-DATE
Task :launcher:validateSigningRelease UP-TO-DATE
Task :unityLibrary:packageReleaseAssets
Task :unityLibrary:processReleaseJavaRes NO-SOURCE
Task :unityLibrary:bundleLibResRelease NO-SOURCE
Task :unityLibrary:mergeReleaseJniLibFolders UP-TO-DATE
Task :unityLibrary:mergeReleaseNativeLibs UP-TO-DATE
Task :unityLibrary:stripReleaseDebugSymbols UP-TO-DATE
Task :unityLibrary:copyReleaseJniLibsProjectOnly UP-TO-DATE
Task :launcher:mergeReleaseAssets
Task :launcher:mergeReleaseJavaResource UP-TO-DATE
Task :launcher:mergeReleaseNativeLibs UP-TO-DATE
Task :unityLibrary:processReleaseManifest
Task :unityLibrary:generateReleaseRFile UP-TO-DATE
Task :unityLibrary:compileReleaseJavaWithJavac UP-TO-DATE
Task :unityLibrary:bundleLibCompileToJarRelease UP-TO-DATE
Task :unityLibrary:bundleLibRuntimeToJarRelease UP-TO-DATE
Task :launcher:stripReleaseDebugSymbols
Task :launcher:processReleaseManifest
Task :launcher:processReleaseResources FAILED
40 actionable tasks: 6 executed, 34 up-to-date

UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

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\led1.gradle\caches\transforms-2\files-2.1\3d1b13a857e40c43266a99844bd8d18d\nar-dependencies\AndroidManifest.xml:28:9-30:40: AAPT: error: unexpected element found in .

 C:\Users\led1\.gradle\caches\transforms-2\files-2.1\3d1b13a857e40c43266a99844bd8d18d\nar-dependencies\AndroidManifest.xml:28:9-30:40: AAPT: error: unexpected element <uses-native-library> found in <manifest><application>.
  • 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.

  • Get more help at https://help.gradle.org

BUILD FAILED in 1s
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8

UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

CommandInvokationFailure: Gradle build failed.
C:\Program Files\Unity\Hub\Editor\2021.3.12f1c2\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\bin\java.exe -classpath “C:\Program Files\Unity\Hub\Editor\2021.3.12f1c2\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-6.1.1.jar” org.gradle.launcher.GradleMain “-Dorg.gradle.jvmargs=-Xmx4096m” “assembleRelease”

Environment Variables:
USERDOMAIN = DESKTOP-5NCG4VR
ProgramFiles = C:\Program Files
TMP = C:\Users\led1\AppData\Local\Temp
PROCESSOR_ARCHITECTURE = AMD64
PROCESSOR_REVISION = 9702
OS = Windows_NT
ALLUSERSPROFILE = C:\ProgramData
PROCESSOR_IDENTIFIER = Intel64 Family 6 Model 151 Stepping 2, GenuineIntel
CHROME_CRASHPAD_PIPE_NAME = \.\pipe\crashpad_14312_OACEFRDAJXMPMMKW
ProgramW6432 = C:\Program Files
USERPROFILE = C:\Users\led1
JAVA_HOME = C:\Program Files\Unity\Hub\Editor\2021.3.12f1c2\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK
CommonProgramFiles = C:\Program Files\Common Files
DriverData = C:\Windows\System32\Drivers\DriverData
ComSpec = C:\Windows\system32\cmd.exe
PSModulePath = C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules
PUBLIC = C:\Users\Public
USERNAME = led1
NUMBER_OF_PROCESSORS = 20
JAVA_TOOL_OPTIONS = -Dfile.encoding=UTF-8
HOMEDRIVE = C:
TEMP = C:\Users\led1\AppData\Local\Temp
Path = C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Users\led1\AppData\Local\Microsoft\WindowsApps;C:\Users\led1\AppData\Local\gitkraken\bin
COMPUTERNAME = DESKTOP-5NCG4VR
PATHEXT = .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
SystemDrive = C:
windir = C:\Windows
HOMEPATH = \Users\led1
CommonProgramFiles(x86) = C:\Program Files (x86)\Common Files
APPDATA = C:\Users\led1\AppData\Roaming
OneDrive = C:\Users\led1\OneDrive
PROCESSOR_LEVEL = 6
CommonProgramW6432 = C:\Program Files\Common Files
ProgramFiles(x86) = C:\Program Files (x86)
SystemRoot = C:\Windows
SESSIONNAME = Console
LOGONSERVER = \DESKTOP-5NCG4VR
LOCALAPPDATA = C:\Users\led1\AppData\Local
__COMPAT_LAYER = DetectorsAppHealth
USERDOMAIN_ROAMINGPROFILE = DESKTOP-5NCG4VR
ProgramData = C:\ProgramData
ORIGINAL_XDG_CURRENT_DESKTOP = undefined

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
Android resource linking failed
C:\Users\led1.gradle\caches\transforms-2\files-2.1\3d1b13a857e40c43266a99844bd8d18d\nar-dependencies\AndroidManifest.xml:28:9-30:40: AAPT: error: unexpected element found in .

 C:\Users\led1\.gradle\caches\transforms-2\files-2.1\3d1b13a857e40c43266a99844bd8d18d\nar-dependencies\AndroidManifest.xml:28:9-30:40: AAPT: error: unexpected element <uses-native-library> found in <manifest><application>.
  • 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.

  • Get more help at https://help.gradle.org

BUILD FAILED in 1s
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
]
stdout[

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
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2021.3.12f1c2\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\build-tools\30.0.2\package.xml. Probably the SDK is read-only
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2021.3.12f1c2\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platform-tools\package.xml. Probably the SDK is read-only
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2021.3.12f1c2\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platforms\android-29\package.xml. Probably the SDK is read-only
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2021.3.12f1c2\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platforms\android-30\package.xml. Probably the SDK is read-only
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2021.3.12f1c2\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\tools\package.xml. Probably the SDK is read-only

Task :launcher:preBuild UP-TO-DATE
Task :unityLibrary:preBuild UP-TO-DATE
Task :launcher:preReleaseBuild UP-TO-DATE
Task :unityLibrary:preReleaseBuild UP-TO-DATE
Task :unityLibrary:compileReleaseAidl NO-SOURCE
Task :launcher:generateReleaseBuildConfig UP-TO-DATE
Task :unityLibrary:packageReleaseRenderscript NO-SOURCE
Task :launcher:compileReleaseAidl NO-SOURCE
Task :unityLibrary:compileReleaseRenderscript NO-SOURCE
Task :launcher:compileReleaseRenderscript NO-SOURCE
Task :unityLibrary:generateReleaseResValues UP-TO-DATE
Task :launcher:javaPreCompileRelease UP-TO-DATE
Task :unityLibrary:generateReleaseResources UP-TO-DATE
Task :launcher:generateReleaseResValues UP-TO-DATE
Task :launcher:generateReleaseResources UP-TO-DATE
Task :launcher:createReleaseCompatibleScreenManifests UP-TO-DATE
Task :launcher:extractDeepLinksRelease UP-TO-DATE
Task :unityLibrary:packageReleaseResources UP-TO-DATE
Task :launcher:prepareLintJar UP-TO-DATE
Task :unityLibrary:extractDeepLinksRelease UP-TO-DATE
Task :unityLibrary:compileReleaseLibraryResources UP-TO-DATE
Task :unityLibrary:parseReleaseLocalResources UP-TO-DATE
Task :unityLibrary:generateReleaseBuildConfig UP-TO-DATE
Task :unityLibrary:javaPreCompileRelease UP-TO-DATE
Task :unityLibrary:prepareLintJarForPublish UP-TO-DATE
Task :launcher:mergeReleaseResources UP-TO-DATE
Task :unityLibrary:mergeReleaseShaders UP-TO-DATE
Task :launcher:desugarReleaseFileDependencies UP-TO-DATE
Task :unityLibrary:compileReleaseShaders NO-SOURCE
Task :unityLibrary:generateReleaseAssets UP-TO-DATE
Task :launcher:checkReleaseDuplicateClasses UP-TO-DATE
Task :launcher:mergeExtDexRelease UP-TO-DATE
Task :launcher:mergeReleaseShaders UP-TO-DATE
Task :launcher:compileReleaseShaders NO-SOURCE
Task :launcher:generateReleaseAssets UP-TO-DATE
Task :launcher:processReleaseJavaRes NO-SOURCE
Task :launcher:collectReleaseDependencies UP-TO-DATE
Task :launcher:sdkReleaseDependencyData UP-TO-DATE
Task :launcher:mergeReleaseJniLibFolders UP-TO-DATE
Task :launcher:validateSigningRelease UP-TO-DATE
Task :unityLibrary:packageReleaseAssets
Task :unityLibrary:processReleaseJavaRes NO-SOURCE
Task :unityLibrary:bundleLibResRelease NO-SOURCE
Task :unityLibrary:mergeReleaseJniLibFolders UP-TO-DATE
Task :unityLibrary:mergeReleaseNativeLibs UP-TO-DATE
Task :unityLibrary:stripReleaseDebugSymbols UP-TO-DATE
Task :unityLibrary:copyReleaseJniLibsProjectOnly UP-TO-DATE
Task :launcher:mergeReleaseAssets
Task :launcher:mergeReleaseJavaResource UP-TO-DATE
Task :launcher:mergeReleaseNativeLibs UP-TO-DATE
Task :unityLibrary:processReleaseManifest
Task :unityLibrary:generateReleaseRFile UP-TO-DATE
Task :unityLibrary:compileReleaseJavaWithJavac UP-TO-DATE
Task :unityLibrary:bundleLibCompileToJarRelease UP-TO-DATE
Task :unityLibrary:bundleLibRuntimeToJarRelease UP-TO-DATE
Task :launcher:stripReleaseDebugSymbols
Task :launcher:processReleaseManifest
Task :launcher:processReleaseResources FAILED
40 actionable tasks: 6 executed, 34 up-to-date
]
exit code: 1
UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at :0)
UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at :0)
UnityEditor.Android.Command.Run (System.String command, System.String args, System.String workingdir, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at :0)
UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action1[T] progress, System.String error) (at <f87ed6a5fa684ce19232b3ecf05a43a3>:0) UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, Unity.Android.Gradle.AndroidGradle androidGradle, System.String workingdir, System.String task, System.Action1[T] progress) (at :0)
Rethrow as GradleInvokationException: Gradle build failed
UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, Unity.Android.Gradle.AndroidGradle androidGradle, System.String workingdir, System.String task, System.Action`1[T] progress) (at :0)
UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at :0)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at :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 :0)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at :0)
UnityEditor.Android.PostProcessAndroidPlayer.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, AndroidPlayerBuildProgram.Data.AndroidPlayerBuildProgramOutput buildProgramOutput) (at :0)
UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at :0)
UnityEditor.PostprocessBuildPlayer.Postprocess (UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget target, System.Int32 subtarget, 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 :0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

2021 LTS, imported their packages, attempted to build the Mesh Saver scene, same error. Just a fresh project with their packages imported.

Edit -
Had to follow this guide: Building ARDK Apps for Android — Niantic Lightship Augmented Reality Developer Kit release-2.4.2 documentation
I either missed it or it was not mentioned in the official environment meshing youtube tutorial I was following.

Now it builds and runs just fine, but when clicking on “Run AR” button, it just permanently goes to a full black screen, not sure why.

Hello @Xiaoyong I apologize for getting back to you on this issue so late. It looks like our system had flagged your original post, so it didn’t come through, and it wasn’t until B11 replied that it came on our radar.

Is this problem still persisting and if so, can you please provide a screenshot of the error message that appears in the error box when the build fails? The ones you posted come from the Console and they can sometimes be shared among different build errors so the one that appears in the error box would be very helpful.

@B11 If you’re still experiencing any issues do you think you can submit a separate topic on our community forums? Since you’re father along than Xiaoyong it would be more beneficial to address this in a separate topic.

Hello! I was encountering the same issue and I tried to fix it by following the steps in the guide of @B11 . I downloaded the gradle version 8.0.2. However I started having a different bug. I wonder if the gradle version that i downloaded is too new. The error is the following one:

"FAILURE: Build failed with an exception.

  • What went wrong:
    A problem occurred configuring project ‘:unityLibrary’.

Failed to notify project evaluation listener.
org/gradle/api/plugins/MavenPlugin

  • 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.

BUILD FAILED in 1s
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8

UnityEditor.BuildPlayerWindow/DefaultBuildMethods:BuildPlayer (UnityEditor.BuildPlayerOptions)
Niantic.ARDK.AR.WayspotAnchors.Editor._RemoteAuthoringPresenceManager:OnBuild (UnityEditor.BuildPlayerOptions) (at Assets/ARDK/Editor/RemoteContent/_RemoteAuthoringPresenceManager.cs:170)
UnityEditor.GenericMenu:CatchMenu (object,string,int)"

(I don’t know if this should be considered the same error or if I need to report a new one).

**Edit: Nevermind. I tried with the gradle version 6.7.1 and i managed to build the app. Now I have the same issue as @B11 but at least the other 2 bugs are fixed. Sorry for the disturbance

Hello @JC_Pardo_Medina ,

Similar to B11, can you create a new topic and with it outline the issue and include some android logcat outputs (specifically any error messages) so that we can take a look?