Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio: Buildtools 24.0.1 requires Java 1.8 or above.

I'm trying to setup an Android dev environment on Mac.

My starting point is Java 1.7 I believe. So I installed android studio and opened the project I'd like to build. And it says:

Error:Buildtools 24.0.1 requires Java 1.8 or above.  Current JDK version is 1.7.

So I went and download Java 1.8 u101 and installed that. No luck. Then I removed Android Studio and re-installed it and re-installed the SDK and still no luck.

My Java Control Pannel says: Java 8 update 101. Output of /usr/bin/java:

java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)

Output of /usr/bin/javac

javac 1.8.0_101

What have I done wrong?

like image 497
lang2 Avatar asked Aug 24 '16 06:08

lang2


People also ask

Which Java version do I need for Android Studio?

A copy of the latest OpenJDK comes bundled with Android Studio 2.2 and higher, and this is the JDK version we recommend you use for your Android projects.

Is Java required for Android Studio?

Since Android apps are written in Java, you will need the Oracle Java compiler and libraries on your system. These are collectively called the Java Development Kit or "JDK" for short. (If you are certain that you already have JDK 1.8 or higher on your computer, such as from taking CS 106A, you can skip to Step 2.)

Can I use Java 8 in Android Studio?

Java 8 language features are now supported by the Android build system in the javac/dx compilation path. Android Studio's Gradle plugin now desugars Java 8 class files to Java 7-compatible class files, so you can use lambdas, method references and other features of Java 8.

What version of Java does Android 11 use?

Java 8 APIs are available starting with Android 8 (API level 26). Some Java 9 APIs (like List. of()) are available starting with Android 11 (API level 30).


1 Answers

Make sure your JDK Version through Project Structure

enter image description here

You can add this in your gradle section

    compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
  }
like image 161
IntelliJ Amiya Avatar answered Sep 27 '22 20:09

IntelliJ Amiya