Help us understand the problem. What is going on with this article?

Java 9だとAndroidプロジェクトのGradleが立ち上がらない

More than 1 year has passed since last update.

うっかりJAVA_HOMEを設定しておらずJava 9が入っていると以下のとおりコケます

% ./gradlew
Parallel execution with configuration on demand is an incubating feature.

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Failed to notify project evaluation listener.
   > Could not initialize class com.android.sdklib.repository.AndroidSdkHandler

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

* Get more help at https://help.gradle.org

BUILD FAILED in 1s

brew cask で入るJavaのバージョンが1.9になっていてハマりました…。

Java 8を入れて java_home で1.8が入っていることを確認します。
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

% /usr/libexec/java_home -V
Matching Java Virtual Machines (2):
    9, x86_64:  "Java SE 9"     /Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home
    1.8.0_144, x86_64:  "Java SE 8"     /Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home

$JAVA_HOME が1.8に設定されたら多分いい感じに動きます。

% export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
% echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home
Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away