Android Studio gradle wrong version - java

Updated Android studio.
Downloaded Gradle. Changed Gradle folder in PC's environmental settings.
In computer, gradle -version returns Gradle 4.4.1.
In Android Studio, returns Gradle 3.5
Smart Android IDE refuses to recognise gradle and I can't compile.
It even gives the wrong error message
Minimum supported Gradle version is 4.1. Current version is 3.5. If using the gradle wrapper, try editing the distributionUrl in C:\xxxxxx\gradle\wrapper\gradle-wrapper.properties to gradle-4.1-all.zip
I have tried restarting, invalidate and restart. Nothing works.
How to fix it?

You need to go to
File->Settings->Build,Execution,Deployment->Gradle
Then tick User local gradle distribution and set the path to your local gradle

Fixed it by restarting the computer.
Restarting the IDE is not good enough. After restarting computer and going into Android Studio's terminal, typing in gradle -version shows the correct version. That's when I know it'd work. Sure enough, gradle commands now work.
Answered this just to show how genius the IDE written by geniuses is.

I check android studio offical web, android studio IDE now support version just to gradle-4.1.
I think you can go to gradle-wrapper.properties, and change to distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
or
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-all.zip
, maybe it can solve the problem.
Reference site:
https://developer.android.com/studio/releases/gradle-plugin.html

I faced this problem and i had fixed it. first goto https://services.gradle.org/distributions/gradle-4.10.1-all.zip and download it locally. Goto File->Settings->Build,Execution,Deployment->Gradle and select "Use local gradle" and set local gradle path that you downloaded just.
gradle path

Related

You are missing the recommended SDK/JDK/NDK/ Install the recommended version using Unity Hub

So I've been getting these warnings in Unity 2019.410f1. Here's how it looks like:
But when I go to Hub to fix this, those packages are already installed.
However, there are no such folders in the directory where they are supposed to be (except for NDK folder, this one is fine). So here's my problem: JDK, NDK and SDK are NOT installed, but Unity Hub thinks overwise and doesn't let me install them. Reinstalling this version of Unity doesn't help either.
Does anyone know what can I do to fix this?
the bug
There has been a bug in unity forever with those.
The fix is, for jdk, sdk and ndk..
click copy path button,
untick the use version installed with unity box
paste in the path you just copied
(optional, save project and exit and repoen it)
Then just retick the boxes to put it back the way it was originaly
I dont think you are having this bug tho, your problem sounds different.
uninstall / reinstall
I'm really suprised uninstalling unity and reinstalling didnt fix it.
Maybe try uninstalling all versions of unity + unity hub, restart machine and start again installing unity hub.
Manually download
If nothing else works I think this would, but its not pretty..
Manually download sdk, jdk and ndk, untick the boxes and add the paths where you have put them. The jdk and ndk can just be downloaded.
jdk https://www.oracle.com/java/technologies/downloads/
ndk https://developer.android.com/ndk/downloads
But to get the sdk you have to install android studio, then download all the individual packages using the sdk manager (which is a tiny hard to find icon!)
Here's the steps I used to fix this:
Install and Open Android Studio
Open the SDK Manager
Copy the Android SDK Location (the SDK Manager shows this path)
Optionally install any SDKs you want using the SDK manager
Create a Symlink to point from the default Unity SDK folder to the default Android Studio SDK folder
On Windows, here's a symlink command you can use. You'll need to change the command to match the user on your system.
mklink /D "C:\Program Files\Unity\Hub\Editor\2020.3.20f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK" "C:\Users\YOUR_USER_HERE\AppData\Local\Android\Sdk"
Lastly, I had to refresh Unity to make the warning message go away.
Open Unity -> Edit -> Preferences -> External Tools -> uncheck & re-check the Android SDK Tools
For me Unity 2021.3.6f1. I fixed by changing the permission of the whole unity editor folder:
sudo chmod -R 777 Editor/
It was a bit extreme, but it worked for me.
It was the editor 2021.3.6f1 ubuntu 22.04
For me (Unity 2021.2.18f1) the problem happened because the NDK field's default value was wrong. The NDK was correctly downloaded by Unity but the path in Unity Editor was wrong so I changed the path to the correct one.
I could reproduce this error when installing older Unity Versions (for me 2020.3.25f1) with Unity Hub 3.x. For some reason the newer Unity Hub doesn't install Android SDK & NDK and OpenJDK for older Unity versions. It's a weird bug, but happened to me every time and on different machines. Possible Workarounds:
Manually install Android SDK, NDK & JDK and locate path in Unity Editor
Use Unity Hub 2.X when installing older Unity Versions
Install newer Unity Editor (e.g. 2021.3.10f1). For some reason sdk, ndk and jdk are properly installed here. You can either copy it over to the other Unity Editor installation (Might get a filename too long exception though) or just link to the path from the 2021 installation in your 2020 editor. Pay attention to the required version though. If there's a version missmatch this workaround doesn't work.
All in all weird bug, weird workarounds but for me all of them worked with the last one being the most convenient since I usually have the newest recommended version installed anyway :)

Android Studio is incompatible with the Gradle

There are several questions with solutions to this, but I'm not getting any luck with them.
I'm using IntelliJ (rather than the raw Android Studio). As far as I can tell I have the latest version of Gradle. I've never used Gradle before, so I'm not totally sure.
Error running app: This version of Android Studio is incompatible with the Gradle Plugin used. Try disabling Instant Run (or updating either the IDE or the Gradle plugin to the latest version)
It might be that Gladle is indeed out of date. How can I check and confirm or fix this?
If it's not that, what else can it be?
(I'm using the latest version of IntelliJ (2016.2.5) RUNNING ON Windows 10)
P.S. I have tried disabling Instant Run, with no effect.
You need to find out your gradle plugin version and check the compatibility with your IDE here. And here you can find which code base of Intellij Idea used in specific Android Studio version.
But I suggest that you should use Android Studio. GL

Getting error when trying to run new project in Android Studio 2.2.1

I just updated to Android Studio 2.2.1 for Mac. Then I updated the JDK to version 8. Tried to start a new project and run it. I got the following error:
Error:(1, 1) A problem occurred evaluating project ':app'.
java.lang.UnsupportedClassVersionError: com/android/build/gradle/AppPlugin : Unsupported major.minor version 52.0
I also tried going back to JDK version 7 as it says on google site that JDK 8 is unstable for Mac. still got the same error.
Check your android build tools dependencies. In your build.gradle if its something like:
classpath "com.android.tools.build:gradle:+"
It has likely downloaded the alpha of 2.2 and that can cause the error you are seeing.
Try
classpath "com.android.tools.build:gradle:2.1.0"
If you are already using the right build tools version but keep getting this error, maybe one of the third party Android libraries you are using is causing the problem due to the same reason. You can force the dependency version to be used (including transitive) by changing
classpath "com.android.tools.build:gradle:2.1.0"
to
classpath('com.android.tools.build:gradle:2.1.0') {
force = true
}
Documentation: gist and official gradle docs.
I was also facing same problem. I upgraded Android Studio and as it forced to But we need to configure same in App Settings as well.
You can try to update JAVA_HOME to point to JDK 8 location.
In my case, I've updated Android studio project's SDK settings, changed java version in my PATH env variable, but still this error occured. Only updating JAVA_HOME helped me.
I was also facing the same problem. I upgraded Android Studio and as it forced to install JDK 8, downloaded and installed this as well. But we need to configure same in App Settings as well.
Select Project [Right click on the app module] -> Open Module Settings -> Select SDK Location from Left Menu - > Configured correct JDK Version i.e removed the old version and updated path of JDK. Save.
Sync Project.
Problem solved!
EDIT: Elaborated Project word.
If you are on Jenkins, check Java version in Jenkins->Manage Jenkins->Global Tool Configuration->JDK
I had to update mine to JDK 8.
I had same error in 2.3 beta 1 ,
Fixed as follow :
Download latest java jdk
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
In Android Studio , go to File > Project Structure > SDK Location > select JDK Location path to point to the new jdk installed (Ex: C:\Program Files\Java\jdk1.8.0_111 )
Done !
Ufff, I changed like everything I was able to find to jdk 8 and still no result but then I found Gradle settings in Intellij (preferences > gradle > GradleJVM) and it was ofc wrong, changed that and woala.
I meet the problem too, but I have changed nothing before it's happening. I think google is purposely. Google is trying to use openJDK instead of JDK because of the lawsuit between google and oracle. So, in the new version 2.2.0 of android, we found that there are some new files in the installed folder:
android studio 2.1 files
android studio 2.2 files
Then, I think we have two method to fix it:
Change the JDK environment variable of your OS.
Just click menu File --> Project Structure, choose Use embedded JDK (recommended). I chose this way and it work.
Good luck...
I had a same problem what is work for me is that .
Go
*File>Settings>(on the panel left)Build,Execution,Deployment . then click on Gradle
There is option to Update Gradle. Click on that it will time 3 to 4min and after that error gone.
The simplest way is to update Android Studio to v2.2.3, it includes a fix of JDK8:
Bug fix for a JDK8/Kotlin compiler + dx issue (issue 227729)
It's solved my problem.

Eclipse to Android Studio - Gradle Issue

I receive errors when trying to import my Cordova based, eclipse exported "build.gradle" file, when importing into Android Studio:
"Gradle version 1.6 is required. Current version is 1.9"
However, upon changing the version using a local gradle distribution I receive the following:
"You are using an old, unsupported version of Gradle. Please use version 1.8 or greater."
Anyone have any ideas how to resolve this?
Stumbled upon the same issue, you should check this link where everything is pretty well explained:
http://rexstjohn.com/exporting-android-project-eclipse-android-studio-0-4-0/

No Android project type in Eclipse->File->New-Project

I am running CentOS 5.5 x86_64 with JDK 1.6, Eclipse Galileo, and the 0.9.7 ADT is installed; however, after installation, the Android project type is not available. I have checked in the installed packages list and it is installed. Anybody encounter this problem before? Could it be due to my use of the 64-bit java VM that is installed on my system?
This usually happens when you dont select any android SDK in "Preferences > Android" You just have to reset the perspective in eclipse, Windows > Reset Perspective.
Hope this is still helpful.
Hope you have already set the Android Preferences if not Window -> Preferences-> Android and browse to the android SDK folder.
In rare cases even after doing this step, Android Project option doesn't show up in File -> New. But you can get it by File -> New -> Project .. and choose the android project from the options displayed.
Ok. I reinstalled eclipse and android. I think the problem was that I hadn't unpacked the android tools first. The plugin was installed, but it had nothing to talk to! Anyway, all the android related stuff now shows up in Eclipse.
Using Windows 7, 64-bit edition, with the latest Eclipse (Indigo) and the latest ADT plugin, I had the exact same problem. No Android project type, no Android in Windows/Preferences.
Like #Rubberman I solved the problem by totally re-installing Eclipse. Eclipse doesn't seem to use the standard Add/Remove Program stuff in Windows; I just deleted the Eclipse install directories and my Eclipse workspace directory, re-installed Eclipse, and re-installed the ADT plugin.
I would have liked to have just removed the plugin and re-installed without deleting the whole of my Eclipse install, but I couldn't figure out a way to do that. I don't see any way to remove a plugin, and when I tried to choose ADT for installation Eclipse gave me an error, saying "I can't install that because it is already installed."
I Know its a very old post..but still it may help someone with same problem...
I wanted to jst share that we can uninstall the plugins without the need of reinstalling eclipps..by simply going to 'already installed application' link and selecting all the android related options and simply clicking on uninstall button..Now you can add fresh android sdk to your ecllips..I have tried it and it works..
Hope, I helped aomeone..:-)
Ok, been looking for the answer to this for an hour, it's not well mentioned.
if you are using linux then you need to add 2 more things to install ADT correctly:
GEF from http://download.eclipse.org/tools/gef/updates/releases
WST Server Adapters from http://download.eclipse.org/releases/galileo/ (modify for your release)
do it the same as the adt plugin install.
maybe you need to uninstall then reinstall the adt plugin after?
sources:
ubuntuforums.org/showthread.php?t=1595684
sonalsantan.blogspot.com/2010/10/eclipse-adt-plugin-on-ubuntu-1010-after.html
You have to install the Eclipse plugin called ADT.

Categories