Update JDK/JAVA in Android Studio
Go to File -> Project Structure
and check SDK Version. If lower than 1.8 change it.
If it is right, check build.gradle
file. Android build-tools 24.0.0 and higher requires Java 1.8. Try to lower them just for the moment.
Check also: https://discuss.gradle.org/t/cant-build-java-1-8-even-with-proper-java-version-in-use/2461/5
It may also a problem with too old Gradle version. Change gradle-plugin version to higher than 2.1.0
But the best way to fix a problem would be this: yesterday was released the newest Android Studio 2.2 with Gradle-plugin 2.2 and Android build-tools 24.0.3. Just update your IDE, it will also fix Gradle and build-tools version.
Hope it will help
Related videos on Youtube
Ema Pall
Updated on September 18, 2022Comments
-
Ema Pall almost 2 years
I updated Java, JDK (
javac
and so on) on my Ubuntu 14, trying out various methods (for which I asked this question).So after many troubles I'm 99.9% sure Java has been updated on the OS (if I type
java -version
on terminal, it gives meJava version 1.8.0_101
)But Android Studio, which is the principal reason for my updating the JDK, still gives and error like
"I cannot compile due to the fact that Java 1.8 version is needed" (sorry if i don't have the precise message. If it's needed I will update it)
So the problems seems to be related to Android Studio, not Ubuntu.
How do I make Android Studio notice that I updated my Java version?
Some notes:
- I'm pretty that my already set as default the 1.8 version, not the 1.7 (I used the
sudo update-alternatives --config java
command... - I installed Android Studio while I still had the 1.7 Java version on my pc, which could have caused this problem
- (Related to the above point): I actually de-installed and re-installed Android Studio (although it's just a folder to be decompressed, nothing really "installs") but it still gives the error message.
Just a last thing (which may seem odd): actually, before I updated the message was regarding the JDK version, and Android Studio could not even render the application look. After the message concerns more Java version (not JDK) and the application look is rendered, but it does not COMPILE the project.
I'm really sorry for my bad english and the confusion I may have made. Hoping someone will help, thank you really much :)
-
Taher Khorshidi almost 8 yearsyou need to specify "JAVA_HOME" at studio configs
- I'm pretty that my already set as default the 1.8 version, not the 1.7 (I used the