search
LoginSignup
5
Help us understand the problem. What are the problem?

More than 5 years have passed since last update.

posted at

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

うっかり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

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
What you can do with signing up
5
Help us understand the problem. What are the problem?