You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by GitBox <gi...@apache.org> on 2019/07/23 06:55:42 UTC

[GitHub] [cordova-android] sc0ttdav3y edited a comment on issue #637: Java JDK version to use given Oracle licensing changes

sc0ttdav3y edited a comment on issue #637: Java JDK version to use given Oracle licensing changes
URL: https://github.com/apache/cordova-android/issues/637#issuecomment-514065674
 
 
   Hi all,
   
   Here's what worked for me as at July 2019, which is a TL;DR from all the links above along with some Google-fu. I can confirm this works on a clean MacOS Mojave, after first installing Android Studio 3.4.2 and Cordova 9.0.1.
   
   Hope this helps someone.
   
   --- 
   
   **Step one**: Install OpenJDK 8 from brew.
   
   ```
   brew tap AdoptOpenJDK/openjdk
   brew cask install adoptopenjdk8
   ```
   
   **Step two**: Update the environment variables to point to this version of the JDK (put the following into your `~/.bash_profile`).
   
   ```
   # The Android SDKs come from Android Studio and are placed here
   export ANDROID_SDK_ROOT="$HOME/Library/Android/sdk"
   
   # Point JAVA_HOME to your OpenJDK 8 
   export JAVA_HOME="/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home"
   
   # Add the emulator to the path (so "cordova android run" works)
   export PATH="${ANDROID_SDK_ROOT}/emulator:${PATH}"
   ```
   Now close and re-open your terminal window.
   
   **Step three**: 
   
   Now you should be able to run `cordova build android` :tada:
   
   --- 
   
   Notes: 
   
   - I also had to accept the license agreement for the SDK before the build worked, and I couldn't immediately find that documented so here goes:  
   ```
   # Run this on your bash prompt
   yes | $ANDROID_SDK_ROOT/tools/bin/sdkmanager "platforms;android-28"
   ```
   - The `JAVA_HOME` environment variable is only needed because Cordova's `check_reqs.js` currently doesn't handle searching for the required JDK (OpenJDK 8 = 1.8) when multiple JDKs are installed, which is the case when you install Android Studio (which installs JDK 12) and then install JDK 8 via brew. A fix for that may be to have the `check_java()` method in `check_reqs.js` (around line 145) run its `/usr/libexec/java_home` command with the parameter "`-v 1.8`", which will find 1.8's path (AdoptOpenJDK 8) when there are multiple JDKs installed.
   
   I hope this helps someone.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org