Unity Version: 2017.30b4 (although I have also tried the latest release build)
macOS Sierra 10.2.6
android studio 2.3.3
latest NDK installed
latest Java installed
I have tried to fix this issue by following this process (but for Mac):
Go to your Android SDK Folder. (If you
did not change the path during Android
Studio installation you will find the
SDK folder here:
C:\Users\YourUsername\AppData\Local\Android\sdk
Rename the old Android sdk “Tool”
folder : [Your Android SDK root]/tools
→ toolsXXXX
Download Android SDK Tools, Revision
25.2.5 (January 2017):
http://dl-ssl.google.com/android/repository/tools_r25.2.5-windows.zip
This fix got me further in the build process, but I’m still getting a failure:
CommandInvokationFailure: Gradle build failed.
/Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home/bin/java -Xmx1024M -classpath “/Applications/Unity/PlaybackEngines/AndroidPlayer/Tools/gradle/lib/gradle-launcher-4.0.1.jar” org.gradle.launcher.GradleMain “–no-daemon” “assembleDebug”
Hello!
Downgrading to Java jdk 8 (
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
) was part of the answer for me.
It only worked after I
ALSO
went to Android Studio–>Settings -->SDK tools → uninstall the update 28-rc1
(I had to do this because I had previously installed the r25.2.5 version of SDK manually by replacing the tools, but the 28-rc1 version will not be compatible with the downgraded Java jdk, causing yet another problem)
This are the two answers I combined in order to solve my problems:
Unable to list target platforms. Please make sure the android sdk path is correct. See the Console for more details. - Questions & Answers - Unity Discussions
Build Error Unity2017.3.1f1 - Questions & Answers - Unity Discussions
Hope This helped
Try to use gradle
2.3.0
instead of 2.1.0 or 4.0.1
You need to edit file
mainTemplate.gradle
in project folder \Assets\Plugins\Android\
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
https://forum.unity.com/threads/gradle-build-error-gradle-version-2-10-is-required-current-version-is-4-0-1.499520/
This problem took me two days to figure out after reinstalling Android SDK, updating all my files, following Google quick-start guide to the best of my ability. Replacing the tools folder with the older version did fix the SDK path issue but then I was getting this same Gradle issue.
As someone mentioned above what fixed this for me was replacing the JDK. Java SE Development Kit 8u161 is the version that worked for me. All I can say is… hallelujah!
This method helped me get rid of the error (Instail Android SDK to disk D, or another, but not to disk C)
"Aleksandr Pushkin:
Attention to those who can not install the Android SDK. How I did:
Download Android Studio from the official site.
Download at the very bottom of the same site “SDK tools package”,
Unpack the “SDK tools package” in the Program Files (if I had a folder lying on the desktop, Android Studio did not work)
Specify Unity and when opening Android Studio, the path to the “SDK tools package”."
Then you can get another error : Unable Android SDK file…
Method of solving in this video:
Unable to list target platforms in Unity5 FIX!!! - YouTube
In my case, I got the error when trying to build the app without internet connection.
Five minutes later I moved to somewhere else with Wifi and it worked.
Not sure if it was just coincidence, but I thought I would mention it in case it helps others.
Hello !
After two days of searching and have try all possible things, downgrade to jdk 8, replace the tools folder, edit manifest, create custom gradle template and add all necessary dependancies…
I finally find the problem ! I previously rename my Project folder and change his place in a other folder so it cause troubleshooting with gradle.
I just replace the folder in his original place and rename it by his orginal name and everything work again !
If you have wasted a lot of time fixing unity Gradle error but nothing worked then you tried unity internal builder but that gave “Parsing Package error”
then try this, it will not help you make your project using unity’s Gradle but it will make your project without any error successfully.
Export your project from unity to a folder eg: ProjectName_Gradle.
open android studio, make sure you are connected to the internet .
close current project then select “Open Gradle, eclipse ADT, etc;” option and open ProjectName_Gradle folder.
check the version of buildTools installed in your android-SDK by opening android-SDK settings from the android studio itself.
edit “build.gradle” file under Gradle Scripts section or under your project.
and change “buildToolsVersion” to the latest version installed in your SDK.
then click “syn project with Gradle Files” from file option and let it sync.
it may ask to update Gradle version, then click update
now there should not be any errors.
now try building APK.
This is a project error
Please! check the project are difrent types of unusuall setting
can be fix
and remember in case of Gradel Build Failed
in player settings debug, release (gradel or proguard) choose none
There are few way to solve gradle build
change from system build from gradle to internal
You can resolve gradle by going C:\Users(user name path).gradle and delete this .gradle file build again and make sure you are connected to internet.
sometime it also occur because of minimum API level of sdk so try to change them to Android 4.4 or 5.0
for full detail visit How to fix Android Gradle Build failed error in unity