LoginSignup
1
1

More than 1 year has passed since last update.

Android Studioで初めてのビルドがうまくいかない時にしたこと。(Mac)

Posted at

Flutter大学のこの動画を観ながら環境構築していましたが、Android Studioの最初のビルドがうまくいかず、困っていましたが、解決できたので、記事にしておきます。

前提

  • MacOS Big Sur バージョン 11.5
  • Android Studio 2020.3.1.22

出てきたエラーメッセージ

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugKotlin'.
> Kotlin could not find the required JDK tools in the Java installation '/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home' used by Gradle. Make sure Gradle is running on a JDK, not JRE.

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

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

BUILD FAILED in 1s
Exception: Gradle task assembleDebug failed with exit code 1

どうやら、JDKにパスが通っていないということらしいので、こちらの記事にしたがって、JDKをインストールしたらうまくいきました。

[1] https://adoptopenjdk.net にアクセス

[2] [OpenJDK 11]・[HotSpot]を選択したあと、[Latest Release]をクリック

[3] インストール

[4] ターミナルで下記コマンドを実行

cd ~
echo JAVA_HOME=/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home >> .zshrc
source .zshrc
echo $JAVA_HOME
cd ~
echo PATH=$PATH:$JAVA_HOME/bin >> .zshrc
source .zshrc
echo $PATH
1
1
0

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
  3. You can use dark theme
What you can do with signing up
1
1