markdown 如何在Android Studio中使用捆绑的JDK在终端中运行Gradle命令

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown 如何在Android Studio中使用捆绑的JDK在终端中运行Gradle命令相关的知识,希望对你有一定的参考价值。

# How To Use The Bundled JDK in Android Studio To Run Gradle Command In Terminal
[SOURCE](https://stackoverflow.com/a/43237101)

Because Android Studio (AS) comes with [a built in JDK](https://stackoverflow.com/a/46608636), we can try to use that as  our JRE (no need to download external JRE) to run Gradle command.

1. Go to your home directory (user’s home):
  ```
  cd ~
  or
  cd /Users/viet/
  ```

2. Create a `.bash_profile` file. In short, this file is loaded before Terminal loads your shell environment and contains all the startup configuration and preferences for your command line interface. For more information, see [here](https://natelandau.com/my-mac-osx-bash_profile/) and [here](https://coolestguidesontheplanet.com/add-shell-path-osx/).

3. Type `nano .bash_profile` – This command will open the `.bash_profile `document (or create it if it doesn’t already exist).

4. Paste in the path to the AS’s JDK. You can find out the path by going to `Application` and `right click Android Studio.app -> Show Package Contents`:
  ```
  export JAVA_HOME=/Applications/Android\ Studio.app/Contents/jre/jdk/Contents/Home/
  ```

5. Now save your changes by typing `ctrl + O` -> Hit return to save. Then exit Nano by typing `ctrl + X`.

6. Now we need to *activate* your changes. Type  `source .bash_profile` and watch your prompt change.

7. Might need to restart the computer for the Gradle command to take effect.

以上是关于markdown 如何在Android Studio中使用捆绑的JDK在终端中运行Gradle命令的主要内容,如果未能解决你的问题,请参考以下文章

在Android中c++里调用opencv

关于Android studio的安装和配置问题

markdown 如何在Android Studio中使用捆绑的JDK在终端中运行Gradle命令

Android Studio 中过时的 Kotlin 运行时警告

如何让hexo代码高亮?

md文件如何打开,markdown文件用啥打开