how to set set the ANDROID_HOME environment variable in mac - android

I had set create .bash_profile file and save these lines:
export ANDROID_HOME=/Users/macbookpro/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
and then enter in terminal: source ~/.bash_profile
and if I enter in terminal this command: echo $ANDROID_HOME
I have the correct path:
/Users/macbookpro/Library/Android/sdk
but If I run command:
ionic cordova run android
in my ionic project, I got this error:
ERROR running one or more of the platforms: Android SDK not found. Make
sure that it is installed. If it is not at the default location, set
the ANDROID_HOME environment variable.
You may not have the required environment or OS to run this project
what should I do!

Related

While installing IONIC, ANDROID_HOME variable is set but getting 'Failed to find 'ANDROID_HOME' environment variable'

As the title states, I've set up the variable in my .bashrc like so
export ANDROID_HOME=$HOME/Android/Sdk
PATH=$PATH:$HOME/Android/Sdk:$HOME/Android/Sdk/tools
export PATH
and shows fine when I do:
printenv ANDROID_HOME
/home/chris/Android/Sdk
printenv PATH also shows the right paths.
I can cd into that directory and go into the tools directory and run ./android and it works fine (it's there).
However, doing:
ionic build android
(in a separate directory, same shell) I get:
Error: Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually.
Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory.
I have re-installed IONIC and re-installed the Android SDK as well.. Any ideas?
Ubuntu 16.10 64bit
Thanks.
Ok I figured it out, I was trying to
sudo ionic build android
instead of just
ionic build android
..and sudo has a different set of env variables. Learn something new everyday!
I started to use sudo because I was getting some permission denied errors, but it should've all been cleared, instead of resorting to super user!

Cannot build ionic project due to ANDROID_HOME path issues

I use linux mint. I set the path on ~/.bash_profile like:
export ANDROID_HOME=/home/mss/android-sdks
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
When I build ionic project on android :-
lenovo-g50 ~/IONIC/apps $ cordova run android
Running command:
/home/mss/IONIC/apps/hooks/after_prepare/010_add_platform_class.js /home/mss/IONIC/apps
Add to body class: platform-android
Error: Android SDK not found. Make sure that it is installed. If it is not at the default location, set the ANDROID_HOME environment variable.
in windows OS
set PATH=%PATH%;C:\Users\userName\AppData\Local\Android\android-sdk\tools;C:\Users\userName\AppData\Local\Android\android-sdk\platform-tools
IN mac
export PATH=${PATH}:/Users/userName/Documents/android-sdk-mac_x86/platform-tools:/Users/userName/Documents/android-sdk-mac_x86/tools
You have to download the sdk. I think your environment variable are set properly, but you don't have the required SDK. type android -v in your console and it start the SDK manager or you can start it manualy in ANDROID_HOME directory. You need to install several build tools and in minimum one SDK Platform.

Failed to find 'ANDROID_HOME' and 'android' while running ionic

I am getting following error when I am running sudo ionic build android
Error: Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually.
Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory.
I have unzipped android-sdk inside '/opt'.android command runs fine from terminal.
I am setting my $ANDROID_HOME in ~/.bashrc
export ANDROID_HOME="/opt"
export PATH=$PATH:$ANDROID_HOME
export PATH=$PATH:/opt/platform-tools
export PATH=$PATH:/opt/tools
echo $ANDROID_HOME gives /opt.
echo $PATH gives /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/arvind/workspace:/opt:/opt/platform-tools:/opt/tools
P.S.: Running android from terminal gives following warning.( Don't know if it matters ).
(Android SDK Manager:6041): IBUS-WARNING **: The owner of /home/user1/.config/ibus/bus is not root!
If you have installed ionic globally(use sudo npm install -g ionic), you should not add sudo when you use ionic cli command. Just use:
ionic platform rm android
ionic platform add android
ionic build android
Hope this will help you, regards!
you just have to point out the bin directory inside android studio as:
inside ~/.bashrc
export ANDROID_HOME=/path/to/android-studio/
export PATH=$PATH:$ANDROID_HOME/bin
now echo $PATH and make sure the android studio is included in the path.

Error: ANDROID_HOME is not set and "android" command not in your PATH on OS X

I am getting this error in terminal when attempting to execute this command:
$ cordova platform add android
I read these answers here:
Error: ANDROID_HOME is not set and "android" command not in your PATH. You must fulfill at least one of these conditions
ANDROID_HOME is not set and "android" command not in your PATH Phonegap
however I don't know where to place the code they provide.
I am running OS X.
Option 1
for windows
Right click on My computer -> properties -> Advanced system setting -> Environment Variables
Now Edit Path on system variables to
;/yourSdkHome/tools;/youSdkHome/platform-tools
Option 2
In Windows machine, Open Command prompt and enter each of this commands one by one
set ANDROID_HOME=**C:\\android-sdk-windows**
set PATH=%PATH%;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools
In MAC Machine, open Terminal and enter these one by one
export ANDROID_HOME=/<installation location>/android-sdk-macosx
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
Note - C:\\android-sdk-windows should be replaced by the path of Android SDK in your machine.
<installation location> should be replaced by the path of Android SDK in your machine.
Example
in MAC machine, if install location is ~/adt-bundle-mac-x86_64/sdk
first line should be
export ANDROID_HOME=~/adt-bundle-mac-x86_64/sdk

Cannot build Phonegap project from command line

I have built a Phonegap app and am now trying to integrate it with Phonegap Build. I'm following the very simple guide here.
So I am doing:
sudo npm install -g phonegap
sudo phonegap create hello com.example.hello HelloWorld
cd hello
sudo phonegap local build android
The last command results in the error:
The command `android` failed. Make sure you have the latest Android SDK installed, and the `android` command (inside the tools/ folder) added to your path. Output: /bin/sh: 1: android: not found
I then did:
which android
with the result:
/home/mark/Development/adt-bundle-linux-x86_64-20130522/sdk/tools/android
which is the corrent path.
The phonegap version is 3.1.0-0.15.0.
Any ideas why I am getting this error?
Edit
If I run:
sudo phonegap local build /home/mark/Development/adt-bundle-linux-x86_64-20130522/sdk/tools/android
I get yet another error:
/usr/local/lib/node_modules/phonegap/lib/phonegap/local.build.js:141
platformPath = path.join('.', 'platforms', platform.local);
^
TypeError: Cannot read property 'local' of undefined
at LocalBuildCommand.module.exports.addPlatform (/usr/local/lib/node_modules/phonegap/lib/phonegap/local.build.js:141:60)
at LocalBuildCommand.execute (/usr/local/lib/node_modules/phonegap/lib/phonegap/local.build.js:95:32)
at LocalBuildCommand.run (/usr/local/lib/node_modules/phonegap/lib/phonegap/local.build.js:70:10)
at Object.build (/usr/local/lib/node_modules/phonegap/lib/phonegap/util/command.js:28:25)
at CLI.module.exports (/usr/local/lib/node_modules/phonegap/lib/cli/local.build.js:34:20)
at CLI.module.exports [as argv] (/usr/local/lib/node_modules/phonegap/lib/cli/argv.js:66:17)
at Object.<anonymous> (/usr/local/lib/node_modules/phonegap/bin/phonegap.js:24:21)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:349:32)
Laters version of android sdk moved adb to platform-tools. Try to include both tools and platform-tools in your path. see
~/Tools/adt-bundle-linux-x86_64-20131030/sdk $ cat tools/adb_has_moved.txt
The adb tool has moved to platform-tools/
If you don't see this directory in your SDK, launch the SDK and AVD
Manager (execute the android tool) and install "Android SDK
Platform-tools"
Please also update your PATH environment variable to include the
platform-tools/ directory, so you can execute adb from any location.
I use following export commands.
export ANDROID_BUNDLE_HOME="$ATILLA_TOOLS/adt-bundle-linux-x86_64-20131030"
export ANDROID_SDK_HOME="$ANDROID_BUNDLE_HOME/sdk"
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
export PATH=$PATH:$ANDROID_SDK_HOME/tools
export PATH=$PATH:$ANDROID_SDK_HOME/platform-tools
both adb and android should work in command line. Also try to use
phonegap local build android
without sudo.
see following example
$phonegap create deneme1
[phonegap] created project at /home/atilla/Projects/Denemeler/a/deneme1
$cd deneme1/
$phonegap local build android
[phonegap] adding the Android platform...
[phonegap] compiling
Android... [phonegap] successfully compiled Android app
After this successful message try to find your platform and apk file.
$ls -al platforms/
$ls -al platforms/android/
$ls -al platforms/android/bin
you should see HelloWorld-debug.apk in this directory.
-rw-r--r-- 1 atilla atilla 1542462 Ara 5 14:31 HelloWorld-debug.apk
install the phonegap npm global package with sudo, it's ok.
But then you should run phonegap with your own user
sudo npm install -g phonegap
phonegap create hello com.example.hello HelloWorld
phonegap local build android
executing with sudo you are switching to root user therefore environment variables as $PATH are not necessarily the same.
Try to Add your Android Path to your PATH Enviroment Variables.
if you use Linux, first try:
echo $PATH
This command display your PATH variable, search the Android path on this.
If you don't see the android path, you need to add that path on your enviroment variable.
Try this:
echo 'export PATH=$PATH:/home/user/mis_prog' >> /home/user/.bashrc
You must edit the configuration file of your login shell.
As usually the BASH shell is the most used, you must edit your /home/user/.bashrc.
For this you will use a text editor or just a command to make the task easier.
If you use some Windows Version, you can edith the enviroment variable PATH from system propertyes, something like this: http://www.computerhope.com/issues/ch000549.htm

Categories

Resources