Can't build Gradle failed and above JDK Java

CommandInvokationFailure: Gradle build failed. 
C:\Program Files\Unity\2022.2.0f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\bin\java.exe -classpath "C:\Program Files\Unity\2022.2.0f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-7.2.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "assembleRelease"


stderr[
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8

FAILURE: Build failed with an exception.

* Where:
Build file 'F:\\Library\Bee\Android\Prj\IL2CPP\Gradle\launcher\build.gradle' line: 1

* What went wrong:
A problem occurred evaluating project ':launcher'.
> Failed to apply plugin 'com.android.internal.application'.
   > ANDROID_SDK_HOME is set to the root of your SDK: C:\Users\media\AppData\Local\Android\Sdk
     ANDROID_SDK_HOME was meant to be the parent path of the preference folder expected by the Android tools.
     It is now deprecated.
     
     To set a custom preference folder location, use ANDROID_USER_HOME.
     
     It should NOT be set to the same directory as the root of your SDK.
     To set a custom SDK location, use ANDROID_HOME.

* 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
]
stdout[

]
exit code: 1
UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <d6ef319e15d14c43ba81bc70e508c266>:0)
UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <d6ef319e15d14c43ba81bc70e508c266>:0)
UnityEditor.Android.Command.Run (System.String command, System.String args, System.String workingdir, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <d6ef319e15d14c43ba81bc70e508c266>:0)
UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action`1[T] progress, System.String error) (at <d6ef319e15d14c43ba81bc70e508c266>:0)
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 <d6ef319e15d14c43ba81bc70e508c266>: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 <d6ef319e15d14c43ba81bc70e508c266>:0)
UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <d6ef319e15d14c43ba81bc70e508c266>:0)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <d6ef319e15d14c43ba81bc70e508c266>: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 <d6ef319e15d14c43ba81bc70e508c266>:0)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <d6ef319e15d14c43ba81bc70e508c266>:0)
UnityEditor.Android.PostProcessAndroidPlayer.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, AndroidPlayerBuildProgram.Data.AndroidPlayerBuildProgramOutput buildProgramOutput) (at <d6ef319e15d14c43ba81bc70e508c266>:0)
UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <d6ef319e15d14c43ba81bc70e508c266>: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 <a62328349c154758b537cb55981f61df>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

Unity Editor version: Unity 2022.2
ML2 OS version:
Unity SDK version:
Host OS: (Windows/MacOS)

Error messages from logs (syntax-highlighting is supported via Markdown):

Welcome to the Magic Leap Developer forum. Could you please provide more information about the issue you are running into and how we can reproduce it?
Have you followed the setup instruction steps as they are outlined in the Unity Getting Started Guide?

I see that you are using Unity Engine 2022.2.x which is not compatible with the SDK.

So by fixing my Setup problem by updating it I solved some issues from there. And now I'm getting

Unable to detect SDK in the selected directory. C:\Program Files\Unity\2022.3.40f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\cmdline-tools\latest\bin\sdkmanager.bat does not exist. Android SDK command-line tools component is not found. Make sure "Command-line Tools (latest)" is installed in the SDK manager.
If command-line tools are installed, but this message is still shown, please restart the Unity editor.

But Command-line Tools (latest) is installed, and Unity has been restarted.

Now using 2022.3.40


SDK folder is set to C:\Users\media\MagicLeap\mlsdk

After downgrading to 2022.3.20 the issue with Command-line Tools (latest) is resolved.

Now I'm back at

Failed to apply plugin 'com.android.internal.application'.
   > ANDROID_SDK_HOME is set to the root of your SDK: C:\Users\media\AppData\Local\Android\Sdk
     ANDROID_SDK_HOME was meant to be the parent path of the preference folder expected by the Android tools.
     It is now deprecated.

My 2022.1. version builds fine. And that is the version used for the Android project with ARFoundatoin integration for mobile devices, that is being transferred for ML2.

We do not support using 2022.1 to build Magic Leap 2 applications. Regarding the issue that you are having, are you using the Android tools that came with Unity?

You may need to add the module to you Unity Installation. Make sure you have enough storage on your computer before installing.




This issue is a general Unity build issue and you may also want to reach out on their forums to see what could be causing the build error as they might have more trouble shooting resources.

Yes, using modules that came with Unity. Everything is updated in the Android Studio. The project is targeting min 29 and up.

I looked at Unity forums but a lot of similar build failed issues non specific to this. Same error but different issues.

Does this issue occur when building the magic leap example project?

Do you mind trying to build with Unity 2022.3.11 ?

Did you try removing the path from your environment variables on your PC?

Have you been able to reproduce this on another PC?

Does this issue occur when building the magic leap example project?
Yes, it was, it also didn't build.
I handled the issue. Thanks for your help.

  1. Installed the 2022.3.18 version of Unity and
  2. Moved my Unity project in another folder on another disk.

And it built fine. I suppose it was the folder/disk permission issue.

Now when I build Examples I manage to install them to the device but they don't start or start and 'crash' just nothing happens.

Any advice?

Make sure you are on the latest version of the OS.

I would try re-downloading the examples in case anything else was not downloaded properly. And try to build again to the device.

We have the unity example project on our GitHub page: GitHub - magicleap/MagicLeapUnityExamples: This project contains Examples for the Magic Leap Unity SDK and has been configured so developers can start developing for the Magic Leap platform quickly.

Yes, new examples worked. And it loads the app on a device.

But I don't get any input from the controller. Raycast is static. ML Controller Interaction Profile is set up. Input System Package New.

Please make sure that the input actions on the controller are set properly. I think the component is called XR controller in unity. The reference for the position and rotation might be null.

If the input actions are set but the controller still does not work properly, make sure that that input action manager component is enabling the correct input actions.

I removed EyeGaze and Hand Interaction Profile and now it works. Thanks.

Do you have a reference to a topic about transfering the ARCore project using ARFoundation to ML2?

We do not have a guide but I will submit your feedback to the voice of customer team.

Additionally, in the image you posted, it appears that the input actions are not added to the action based controller component.

I recommend you create another topic if you run into any other issues so that we can make sure the topic question is marked with the relevant solution.

Additionally, in the image you posted, it appears that the input actions are not added to the action-based controller component.

That is right but it works once I removed Interaction profiles except ML2 Inter... Controller Profile. Input is driven by Input Action References from Input Action Asset from ML.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.