Can´t build for android

  • Device type & OS version: Android
  • Host machine & OS version: Windows
  • Xcode version:
  • ARDK version:
  • Unity version: 2020.3.19f1

Bug reproduction steps: I’ve followed the guide to setup the build for Android devices tutorial. I’m currently using gradle 8.1.1. Here is the complete log: CommandInvokationFailure: Gradle build failed.
C:\Program Files\Unity\Hub\Editor\2020.3.19f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\bin\java.exe -classpath “C:\Gradle\gradle-8.1.1\lib\gradle-launcher-8.1.1.jar” org.gradle.launcher.GradleMain “-Dorg.gradle.jvmargs=-Xmx4096m” “assembleRelease”

stderr[

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 5s
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
]
stdout[
Starting a Gradle Daemon, 1 incompatible and 2 stopped Daemons could not be reused, use --status for details

Configure project :launcher
WARNING:: The option setting ‘android.enableR8=false’ is deprecated.
It will be removed in version 7.0 of the Android Gradle plugin.
You will no longer be able to disable R8

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

You can use ‘–warning-mode all’ to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See Command-Line Interface
]
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 <c8b3b39837d14a59b516963b78bf9032>:0) UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, 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, 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.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 :0)
UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at :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 <97ba64834c8f4edc84e3d8e30b04f122>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

Here is also a screenshot of my gradle config:
preferences

EDIT: changed to gradle 6.7.1 and receveid new error: CommandInvokationFailure: Gradle build failed.
C:\Program Files\Unity\Hub\Editor\2020.3.19f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\bin\java.exe -classpath “C:\Gradle\gradle-6.7.1\lib\gradle-launcher-6.7.1.jar” org.gradle.launcher.GradleMain “-Dorg.gradle.jvmargs=-Xmx4096m” “assembleRelease”

stderr[

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:launcher:checkReleaseAarMetadata’.

A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
The minCompileSdk (31) specified in a
dependency’s AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module’s compileSdkVersion (android-30).
Dependency: :androidx.browser.browser-1.4.0:.
AAR metadata file: C:\Users\Pichau.gradle\caches\transforms-2\files-2.1\cfbe3a952017d885b762e4b06dc37ee4\androidx.browser.browser-1.4.0\META-INF\com\android\build\gradle\aar-metadata.properties.

  • 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 1m 17s
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 setting ‘android.enableR8=false’ is deprecated.
It will be removed in version 7.0 of the Android Gradle plugin.
You will no longer be able to disable R8
WARNING:: Using flatDirs should be avoided because it doesn’t support any meta-data formats.
Currently detected usages:

  • repository flatDir used in: root project ‘gradleOut’, project ‘:launcher’, project ‘:unityLibrary’, …
    WARNING:: Please remove usages of jcenter() Maven repository from your build scripts and migrate your build to other Maven repositories.
    This repository is deprecated and it will be shut down in the future.
    See JCenter service update  |  Android Studio  |  Android Developers for more information.
    Currently detected usages in: root project ‘gradleOut’, project ‘:launcher’, project ‘:unityLibrary’, …
    Exception while marshalling C:\Program Files\Unity\Hub\Editor\2020.3.19f1\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\2020.3.19f1\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.3.19f1\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\2020.3.19f1\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\2020.3.19f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\tools\package.xml. Probably the SDK is read-only
    Exception while marshalling C:\Program Files\Unity\Hub\Editor\2020.3.19f1\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\2020.3.19f1\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.3.19f1\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\2020.3.19f1\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\2020.3.19f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\tools\package.xml. Probably the SDK is read-only

Task :launcher:preBuild UP-TO-DATE
Task :unityLibrary:FirebaseApp.androidlib:preBuild UP-TO-DATE
Task :unityLibrary:preBuild UP-TO-DATE
Task :unityLibrary:preReleaseBuild UP-TO-DATE
Task :unityLibrary:FirebaseApp.androidlib:preReleaseBuild UP-TO-DATE
Task :launcher:preReleaseBuild UP-TO-DATE
Task :unityLibrary:packageReleaseRenderscript NO-SOURCE
Task :unityLibrary:FirebaseApp.androidlib:compileReleaseAidl NO-SOURCE
Task :unityLibrary:compileReleaseAidl NO-SOURCE
Task :unityLibrary:FirebaseApp.androidlib:packageReleaseRenderscript NO-SOURCE
Task :unityLibrary:generateReleaseResValues
Task :unityLibrary:writeReleaseAarMetadata
Task :unityLibrary:FirebaseApp.androidlib:writeReleaseAarMetadata
Task :unityLibrary:compileReleaseRenderscript NO-SOURCE
Task :unityLibrary:FirebaseApp.androidlib:compileReleaseRenderscript NO-SOURCE
Task :unityLibrary:generateReleaseResources
Task :unityLibrary:FirebaseApp.androidlib:generateReleaseResValues
Task :unityLibrary:FirebaseApp.androidlib:generateReleaseResources
Task :launcher:generateReleaseBuildConfig
Task :launcher:compileReleaseAidl NO-SOURCE
Task :launcher:compileReleaseRenderscript NO-SOURCE
Task :launcher:javaPreCompileRelease
Task :launcher:writeReleaseApplicationId
Task :launcher:analyticsRecordingRelease
Task :launcher:generateReleaseResValues
Task :launcher:generateReleaseResources
Task :launcher:createReleaseCompatibleScreenManifests
Task :launcher:extractDeepLinksRelease
Task :launcher:mergeReleaseJniLibFolders
Task :launcher:mergeReleaseShaders
Task :launcher:compileReleaseShaders NO-SOURCE
Task :launcher:generateReleaseAssets UP-TO-DATE
Task :unityLibrary:FirebaseApp.androidlib:packageReleaseResources
Task :unityLibrary:FirebaseApp.androidlib:extractDeepLinksRelease
Task :unityLibrary:packageReleaseResources
Task :unityLibrary:extractDeepLinksRelease
Task :unityLibrary:FirebaseApp.androidlib:processReleaseManifest
Task :unityLibrary:processReleaseManifest
Task :launcher:checkReleaseDuplicateClasses
Task :unityLibrary:compileReleaseLibraryResources
Task :unityLibrary:generateReleaseBuildConfig
Task :unityLibrary:FirebaseApp.androidlib:compileReleaseLibraryResources
Task :unityLibrary:javaPreCompileRelease
Task :unityLibrary:FirebaseApp.androidlib:generateReleaseBuildConfig
Task :unityLibrary:processReleaseJavaRes NO-SOURCE
Task :unityLibrary:prepareLintJarForPublish
Task :unityLibrary:bundleLibResRelease NO-SOURCE
Task :unityLibrary:FirebaseApp.androidlib:javaPreCompileRelease
Task :unityLibrary:FirebaseApp.androidlib:prepareLintJarForPublish
Task :unityLibrary:FirebaseApp.androidlib:processReleaseJavaRes NO-SOURCE
Task :unityLibrary:FirebaseApp.androidlib:bundleLibResRelease NO-SOURCE
Task :unityLibrary:FirebaseApp.androidlib:parseReleaseLocalResources
Task :unityLibrary:parseReleaseLocalResources
Task :unityLibrary:FirebaseApp.androidlib:mergeReleaseJniLibFolders
Task :unityLibrary:FirebaseApp.androidlib:mergeReleaseNativeLibs NO-SOURCE
Task :unityLibrary:FirebaseApp.androidlib:stripReleaseDebugSymbols NO-SOURCE
Task :unityLibrary:FirebaseApp.androidlib:copyReleaseJniLibsProjectOnly
Task :unityLibrary:FirebaseApp.androidlib:mergeReleaseShaders
Task :unityLibrary:FirebaseApp.androidlib:compileReleaseShaders NO-SOURCE
Task :unityLibrary:FirebaseApp.androidlib:generateReleaseAssets UP-TO-DATE
Task :unityLibrary:FirebaseApp.androidlib:packageReleaseAssets
Task :unityLibrary:FirebaseApp.androidlib:generateReleaseRFile
Task :unityLibrary:mergeReleaseJniLibFolders
Task :launcher:checkReleaseAarMetadata FAILED

Task :launcher:processReleaseMainManifest
[:arcore:] C:\Users\Pichau.gradle\caches\transforms-2\files-2.1\636e1e33c1dda36f8ef25c66486b774b\arcore\AndroidManifest.xml Warning:
Package name ‘com.google.ar.core’ used in: :arcore:, :unityandroidpermissions:.

Task :unityLibrary:generateReleaseRFile
Task :launcher:mergeReleaseResources
Task :unityLibrary:FirebaseApp.androidlib:compileReleaseJavaWithJavac
41 actionable tasks: 41 executed
]
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 <c8b3b39837d14a59b516963b78bf9032>:0) UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, 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, 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.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 :0)
UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at :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 <97ba64834c8f4edc84e3d8e30b04f122>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

Hello Alefe,

That version of Gradle that you’re using will cause issues with Android builds. I recommend sticking to the recommended 6.7.1.

Please have a look at this forum post for more information: How to Resolve Gradle Build Error: "The option setting 'android.enableR8=false' is deprecated..."

If the information on the forum post does not resolve your issue, please reply back here, not on the guide itself :slight_smile:

Yep, use 6.7.
I also got 7.2 working but not 8+

I’ve already followed the steps of the topic. I’m still getting this error(the same error of my edit):

  • What went wrong:
    Execution failed for task ‘:launcher:checkReleaseAarMetadata’.

A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
The minCompileSdk (31) specified in a
dependency’s AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module’s compileSdkVersion (android-30).
Dependency: :androidx.browser.browser-1.4.0:.
AAR metadata file: C:\Users\Pichau.gradle\caches\transforms-2\files-2.1\cfbe3a952017d885b762e4b06dc37ee4\androidx.browser.browser-1.4.0\META-INF\com\android\build\gradle\aar-metadata.properties.

I updated my Android SDK to API level 31 and now the build is complete, but when I installed it on my device, I was unable to run the app. Any idea why? The only options I have is to uninstall the app or force stop (this option appears but I can’t press it).The application does not appear as an executable. I can only see it in device settings.

Could it be my AndroidManifest? I change it to be exactly like the one on this guide: Building ARDK Apps for Android — Niantic Lightship Augmented Reality Developer Kit release-2.5.2 documentation

When i use the default AndroidManifest from unity, i got a new error:

Execution failed for task ‘:unityLibrary:processReleaseManifest’.

A failure occurred while executing com.android.build.gradle.tasks.ProcessLibraryManifest$ProcessLibWorkAction
Manifest merger failed : Apps targeting Android 12 and higher are required to specify an explicit value for android:exported when the corresponding component has an intent filter defined. See <activity>  |  Android Developers for details.

I was successful in building the application. Now I have a new problem. I will open a new topic