I am trying to build an Ionic application with ionic build android with no success. I looked around answers in stackoverflow but I can seem to have the same situation.
I get the following error:
ANDROID_HOME=/Users/myuserID/development/android-sdk-macosx
JAVA_HOME=/Users/myuserID/Library/Java/JavaVirtualMachines/jdk1.8.0_71.jdk/Co>nten
ts/home
Running:
>/Users/myuserID/development/ionic/keepdoing/platforms/android/gradlew
cdvBuildDebug -b
/Users/myuserID/development/ionic/keepdoing/platforms/android/build.gradle -
Dorg.gradle.daemon=true
ERROR: JAVA_HOME is set to an invalid directory:
/Users/myuserID/Library/Java/JavaVirtualMachines/jdk1.8.0_71.jdk/Contents/hom>e
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
I have everything set in the .bash_profile:
export PATH=$PATH:/Users/myuserID/development/android-sdk-macosx/platform-
tools
export PATH=$PATH:/Users/myuserID/development/android-sdk-macosx/tools
export ANDROID_HOME="/Users/myuserID/development/android-sdk-macosx"
export
JAVA_HOME="/Users/myuserID/Library/Java/JavaVirtualMachines/jdk1.8.0_71.jdk
export PATH=$PATH:/usr/local/share/npm/bin
export PATH=$PATH:/usr/local/npm/bin
export PATH=$PATH:/usr/local/lib/node_modules/cordova/
export
PATH=$PATH:/Library/Java/JavaVirtualMachines/jdk1.8.0_71.jdk/Contents/home/bin
export PATH=$PATH:/Library/Java/JavaVirtualMachines/jdk1.8.0_71.jdk
But can't resolve this. Re-installed the android SDK to no avail.
Any help will be greatly appreciated.
A recent update to Android Studio should help anyone landing on this question in 2017! Android Studio 2.2+ comes bundled with a custom OpenJDK build, so there's no need to download a separate JDK.
The following are the adjusted instructions available at https://ionicframework.com/docs/developer-resources/platform-setup/mac-setup.html using the new locations bundled with Android Studio app.
Create and open the .bash_profile file in your favourite text editor:
touch ~/.bash_profile
open -a TextEdit ~/.bash_profile`
Populate the file with:
export JAVA_HOME=/Applications/Android\ Studio.app/Contents/jre/jdk/Contents/Home
export PATH=${JAVA_HOME}/bin:$PATH
# Set Android_HOME
export ANDROID_HOME=~/Library/Android/sdk/
# Add the Android SDK to the ANDROID_HOME variable
export PATH=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/tools:$PATH
#Set GRADLE_HOME
export GRADLE_HOME=/Applications/Android\ Studio.app/Contents/gradle/gradle-3.2
export PATH=$PATH:$GRADLE_HOME/bin
Save and close the file, then apply these changes by re-sourcing .bash_profile:
source ~/.bash_profile
You'll then be able to run the ionic commands using the built in tools within Android Studio.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With