Building yields gradle errors after gradle update

Include the following details (edit as applicable):

  • Issue category: ARDK Documentation / Unity Example Package / Developer Tools
  • Device type & OS version: Android
  • Host machine & OS version: Windows
  • Issue Environment : Unity
  • Xcode version:
  • ARDK version: 2.4.2
  • Unity version: 2021.3.21f1

Description of the issue:

I am setting up a simple ARDK project, the ballDemo example to be precise. Run mode on Unity works perfectly, however, when i try to build the .apk i get build errors relating to the gradle, posted further below.
I have done the steps as described on:
https://lightship.dev/docs/ardk/ardk_fundamentals/building_android.html
Including updating the gradle, which i chose version 7.5.1, as it is the same as the example. I have also attempted version 8.0.2 and 6.7.1, which are the most recent and minimum gradle versions, which yielded the same errors.
I have succeeded in reproducing this problem on an empty project by following the steps as described on the step by step tutorial above without the lightship package, which leads me to believe this problem is solely related to the gradle.
If I use Unity’s default gradle (6.1.1) I get a different gradle error, which is to be expected since according to the notes on the tutorial above, current versions of ARDK require at least gradle 6.7.1.

To install the gradles, i downloaded the binary .zip from:

Unzipped it, and then pointed Unity to the \lib file inside (step 2):
C:\Users\andre\Desktop\LightShip resources\gradle\gradle-6.7.1\lib

Afterwards, I checked the box “Custom Base Gradle Template” (step 3)
And edited the created file:

From here, building failed and yieded the following errors:

Errors:
A)
Exception: Gradle install not valid
Unity.Android.Gradle.AndroidGradle…ctor (System.String gradleLauncherPath, System.Int32 jvmHeapSize) (at :0)
UnityEditor.Android.GradleWrapper.CreateGradleInstance () (at :0)
UnityEditor.Android.PostProcessAndroidPlayer.ExecuteWarmup (System.String stagingArea) (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 <57a8ad0d1492436d8cfee9ba8e6618f8>:0)
UnityEditor.DefaultBuildMethods:BuildPlayer(BuildPlayerOptions)
Niantic.ARDK.AR.WayspotAnchors.Editor._RemoteAuthoringPresenceManager:OnBuild(BuildPlayerOptions) (at Assets/ARDK/Editor/RemoteContent/_RemoteAuthoringPresenceManager.cs:170)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

B)
Build completed with a result of ‘Failed’ in 38 seconds (38020 ms)
UnityEditor.BuildPlayerWindow/DefaultBuildMethods:BuildPlayer (UnityEditor.BuildPlayerOptions)
Niantic.ARDK.AR.WayspotAnchors.Editor._RemoteAuthoringPresenceManager:OnBuild (UnityEditor.BuildPlayerOptions) (at Assets/ARDK/Editor/RemoteContent/_RemoteAuthoringPresenceManager.cs:170)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

C)
UnityEditor.BuildPlayerWindow+BuildMethodException: 2 errors
at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x002da] in <57a8ad0d1492436d8cfee9ba8e6618f8>:0
at Niantic.ARDK.AR.WayspotAnchors.Editor._RemoteAuthoringPresenceManager.OnBuild (UnityEditor.BuildPlayerOptions options) [0x00044] in C:\Users\andre\Documents\GitHub\Test\Assets\ARDK\Editor\RemoteContent_RemoteAuthoringPresenceManager.cs:170
at (wrapper delegate-invoke) System.Action`1[UnityEditor.BuildPlayerOptions].invoke_void_T(UnityEditor.BuildPlayerOptions)
at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x00072] in <57a8ad0d1492436d8cfee9ba8e6618f8>:0
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

Any help is greatly apreciatted, if any information is missing feel free to request it. :slightly_smiling_face:

Hi Andreia,

It looks like the Gradle version you’re trying to use requires at least the Android Gradle Plugin of version 8.0 according to Android Gradle plugin release notes  |  Android Developers. Which, unfortunately, requires Java 11 which is incompatible with Unity’s requirement of Java 8. In addition, as you pointed out, this issue isn’t directly tied to Lightship thus it is out of our scope of support. I recommend posting in the Unity community forums for more information.

I’m sorry I wasn’t much help!

-Maverick L.

Hi Maverick, thank you for your answer despite not being exactly a LightShip issue,
I realized what I did wrong on my method and resolved it, which I’ll leave here in case others run into the same problem as me.
After trying a lot of things, I realized that I needed to make the path on step 2 to the gradle folder and not the lib folder. For this, I used gradle 6.7.1, with version 4.2.0. on the text properties file from step 3.

Should have been:
C:\Users\andre\Desktop\LightShip resources\gradle\gradle-6.7.1

With this it built and successfully deployed on an Android with API 31/32.

Awesome! I’m glad you were able to get it to build! Thank you so much for providing a lot of information in your initial post and in your solution response. We really appreciate it when users go out of their way to not only get help for themselves but to also leave breadcrumbs for someone else that might encounter the same issue.

Happy developing!