CommandInvokationFailure: Gradle build failed!

Hi guys,

I know this has been asked in different threads but still couldn’t find the solution to my problem. When I try to build for Android Gradle gives the following error. I am using Unity 2018 and I have GoogleAds and Chartboost SDKS in my project. The project is also an AR project using VUFORIA! ı can build it easily for IOS but when it comes to Android I can not build it. I have Android Studio installed and have Java 8 installed also.

I tried many ways building using internal (this way the project can not merge Android Manifests)
You can see the full error log in console below.

Btw I am working in a Mac and my SDK and Java installation paths are as follow.

/Users/volkankutlubay/Library/Android/sdk

/Library/Java/JavaVirtualMachines/jdk1.8.0_171.jdk/Contents/Home

Thank you

CommandInvokationFailure: Gradle build failed.
/Library/Java/JavaVirtualMachines/jdk1.8.0_171.jdk/Contents/Home/bin/java -classpath “/Volumes/Untitled/Applications/Unity/PlaybackEngines/AndroidPlayer/Tools/gradle/lib/gradle-launcher-4.0.1.jar” org.gradle.launcher.GradleMain “-Dorg.gradle.jvmargs=-Xmx2048m” “assembleRelease”

stderr[

FAILURE: Build failed with an exception.

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

Failed to find Build Tools revision 28.0.0

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED in 7s
]
stdout[
NDK is missing a “platforms” directory.
If you are using NDK, verify the ndk.dir is set to a valid NDK directory. It is currently set to /Users/volkankutlubay/Library/Android/sdk/ndk-bundle.
If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.

]
exit code: 1
UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action1 progress, System.String error) UnityEditor.Android.GradleWrapper.Run (System.String workingdir, System.String task, System.Action1 progress)
Rethrow as GradleInvokationException: Gradle build failed
UnityEditor.Android.GradleWrapper.Run (System.String workingdir, System.String task, System.Action`1 progress)
UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

I am also interested in a solution. I am also on a mac using Vuforia.

Found a solution (2018),

That’s it. This ended up working for me.

2 Likes

Hi thank you! ok I will try. I already have java 8 downloaded and I actually can create an apk when I start an empty project but not with my current vuforia project. Only I didn’t install the latest Android SDK tools 25. I will give it a try. Also when I change the build from gradle to internal it says " can not merge Android Manifests" The reason is I have like 2 ad networks implemented which are Admob and Chartboost. Do you know how to fix this?? Thank you!

Another thing is when I look at my Android Studio SDK manager it says that as SDK Platforms I only have 8, 7.1.1 and 7.0 I don’t have below. Can that also cause a problem.

3505750--279678--unity.jpg

Hi again! Sorry too many text. I did everything you said and it was going ok but now I have this another error. Have you come across this before??

“Unable to convert classes into dex format. See the Console for details.”

Thank you btw for your help!

@volcank , I got it to build this way, but unfortunately, it will not install itself on my android phone (Samsung Galaxy S8). I am currently looking into another solution. It might be a bug we have to deal with until the next Unity version. I will let you know if I come up with anything.

1 Like

Hmm ok no problem thank you for all the help I am still bugging my self on this. Maybe should move on to learn other things in Unity for now!

Hi somehow I managed to create an apk but everything worked after I deleted the Google Mobile Ads Network I guess that was creating a problem. Yes Also my app didn’t open in my Blue Stacks App in Mac. Maybe try to downgrade from Nougat 7.0 to something like 4.1 and try to reinstall to your phone.

Edit: Yes I managed to create an APK that worked in Bluestacks after I built it with 4.1 the lowest API.

Hi!

I had the same problem! I did just that! All made as here written and helped! The last point is very important!

Thanks.