I am trying to build android for ionic in linux but its showing me an error like this
[Error: Failed to find \'ANDROID_HOME\' environment variable.
Windows - set environment variable permanently:
setx ANDROID_HOME "C:\Program Files\Android\android-sdk"
or
setx ANDROID_HOME "C:\Program Files (x86)\Android\android-sdk"
Great tutorial here: https://www.youtube.com/watch?v=kY22NSBwV_s
No need to do any bash commands/symlinks:
In my Case: I have put the correct path for Android and java but still getting the error.
The problem was that I have added the Android platform using sudo command.sudo ionic cordova platform android.
To solve my problem: First I have removed the platform android by running command
sudo ionic cordova platform rm android
then add the android platform again with out sudoionic cordova platform add android
but i get the error of permissions.
To resolve the error run command
sudo chmod -R 777 {Path-of-your-project}
in my case sudo chmod -R 777 ~/codebase/IonicProject
Then run command
ionic cordova platform add android
or
ionic cordova run android
~/.bashrcsudo su
vim ~/.bashrc
Common default install folders:
Example .bashrc
export ANDROID_HOME=/root/Android/Sdk
PATH=$PATH:$ANDROID_HOME/tools
PATH=$PATH:$ANDROID_HOME/platform-tools
source ~/.bashrc
When
ionic build androidstill fails it could be because of wrong sdk version. To install correct versions and images runandroidfrom command line. Since it is now in your PATH you should be able to run it from anywhere.
Case: using SO Windows, try:
set ANDROID_HOME=C:\\android-sdk-windows
set PATH=%PATH%;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools
more in: http://spring.io/guides/gs/android/
Case: you don't have platform-tools:
cordova platforms list
cordova platforms add <Your_platform, example: Android>
To add ANDROID_HOME value permanently,
gedit ~/.bashrc
and add the following lines
export ANDROID_HOME=/root/Android/Sdk
PATH=$PATH:$ANDROID_HOME/tools
Save the file and you need not update ANDROID_HOME value everytime.