Kotlin could not find the require JDK tools in the Java installtion ‘/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home’ used by Gradle. Make sure is running on a JDK, not JRE.
The JAVA_HOME environment variable is not configured. The JAVA_HOME environment variable is not configured
First, install the JDK.
Obtain the JAVA installation directory /usr/libexec/java_home -v
Matching Java Virtual Machines (2):
1.8.261.12 (x86_64) “Oracle Corporation” – “Java”/Library/Internet plug-ins/JavaAppletPlugin plugin/Contents/Home
1.8.0 comes with _261 (x86_64) “Oracle Corporation” – “Java SE 8″/Library/Java/JavaVirtualMachines jdk1.8.0 _261. JDK/Contents/Home
/ Library/Java/JavaVirtualMachines jdk1.8.0 _261. JDK/Contents/Home
Edit profile under MAC:
Vim ~/.bash_profile. If the bash_profile file cannot be found, run touch.bash_profile
export ANDROID_HOME=/Users/user/Library/Android/sdk export PATH=${PATH}:${ANDROID_HOME}/tools export PATH = ${PATH} : ${ANDROID_HOME} / platform - the tools export NDK_ROOT = ${ANDROID_HOME} / the NDK / 21.0.6113669 export PATH = ${PATH} : ${ANDROID_HOME} / cmake / 3.10.2.4988404 / bin export JAVA_HOME = / Library/Java/JavaVirtualMachines jdk1.8.0 _261. JDK/Contents/Home export CLASSPAHT=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export PATH=$JAVA_HOME/bin:$PATH: # HomeBrew export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles export PATH="/usr/local/bin:$PATH" export PATH="/usr/local/sbin:$PATH" # HomeBrew ENDCopy the code
Note: HomeBrew is not required.
After editing, press Esc to exit insert mode, then shift + : enter wq! Exit editing mode.
Run the following command for it to take effect
source ~/.bash_profile
Validation:
Input echo $JAVA_HOME
/ Library/Java/JavaVirtualMachines jdk1.8.0 _261. JDK/Contents/Home
Note:
Environment variables are configured in ~/.bash_profile, but they do not take effect after each terminal restart. You need to run $source ~/.bash_profile again
MAC terminal types are ZSH and bash, bash initializes by default bash_profile and ZSH initializes by default ZSHRC
zsh: command not found: adb
MAC Catalina default ZSH terminal, so.bash_profile is not initialized.
The solution
- Modify the ~/.zshrc file
vim ~/.zshrc
At the end of the ~/.zshrc file, add the line source ~/.bash_profile
- You can also run the command CHSH -s /bin/bash to switch