nativescript-cli: The ANDROID_HOME environment variable is not set
I am receiving the following message when I try to add the Android platform:
The ANDROID_HOME environment variable is not set or it points to a non-existent directory. You will not be able to perform any build-related operations for Android.
When I run echo $ANDROID_HOME
on my Mac, it prints out the following:
/Users/nraboy/Library/Android-SDK
I validate this path by executing cd $ANDROID_HOME
followed by a ls
and everything seems normal.
My Android installation is valid because it works fine with React Native, Ionic Framework, and native Android development.
Here is the process I used for installing NativeScript on my machine:
sudo curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.29.0/install.sh | bash
nvm install 0.12.7
nvm use 0.12.7
sudo npm install -g nativescript
Yes, I am using NVM to manage my Node.js versions.
Here are my full --log trace
for Android:
$ tns platform add android --log trace
Exec uname -a
stdout: Darwin macbookpro 14.5.0 Darwin Kernel Version 14.5.0: Wed Jul 29 02:26:53 PDT 2015; root:xnu-2782.40.9~1/RELEASE_X86_64 x86_64
stderr:
Exec npm -v
stdout: 2.11.3
stderr:
spawn: java -version
Exec node-gyp -v
stdout:
stderr: /bin/sh: node-gyp: command not found
Exec xcodebuild -version
stdout: Xcode 7.0.1
Build version 7A1001
stderr:
Exec pod --version
stdout:
stderr: /bin/sh: pod: command not found
Exec adb version
stdout: Android Debug Bridge version 1.0.32
Revision eac51f2bb6a8-android
stderr:
Exec android -h
stdout:
Usage:
android [global options] action [action options]
Global options:
-h --help : Help on a specific command.
-v --verbose : Verbose mode, shows errors, warnings and all messages.
--clear-cache: Clear the SDK Manager repository manifest cache.
-s --silent : Silent mode, shows errors only.
Valid
actions
are
composed
of a verb
and an
optional
direct
object:
- sdk : Displays the SDK Manager window.
- avd : Displays the AVD Manager window.
- list : Lists existing targets or virtual devices.
- list avd : Lists existing Android Virtual Devices.
- list target : Lists existing targets.
- list device : Lists existing devices.
- list sdk : Lists remote SDK repository.
- create avd : Creates a new Android Virtual Device.
- move avd : Moves or renames an Android Virtual Device.
- delete avd : Deletes an Android Virtual Device.
- update avd : Updates an Android Virtual Device to match the folders
of a new SDK.
- create project : Creates a new Android project.
- update project : Updates an Android project (must already have an
AndroidManifest.xml).
- create test-project : Creates a new Android project for a test package.
- update test-project : Updates the Android project for a test package (must
already have an AndroidManifest.xml).
- create lib-project : Creates a new Android library project.
- update lib-project : Updates an Android library project (must already have
an AndroidManifest.xml).
- create uitest-project: Creates a new UI test project.
- update adb : Updates adb to support the USB devices declared in the
SDK add-ons.
- update sdk : Updates the SDK by suggesting new platforms to install
if available.
stderr:
Exec mono --version
stdout: Mono JIT compiler version 4.0.2 ((detached/c99aa0c Thu Jun 11 18:53:01 EDT 2015)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS: normal
SIGSEGV: altstack
Notification: kqueue
Architecture: x86
Disabled: none
Misc: softdebug
LLVM: yes(3.6.0svn-mono-(detached/a173357)
GC: sgen
stderr:
Exec git --version
stdout: git version 2.3.8 (Apple Git-58)
stderr:
Exec gradle -v
stdout:
------------------------------------------------------------
Gradle 2.4
------------------------------------------------------------
Build time: 2015-05-05 08:09:24 UTC
Build number: none
Revision: 5c9c3bc20ca1c281ac7972643f1e2d190f2c943c
Groovy: 2.3.10
Ant: Apache Ant(TM) version 1.9.4 compiled on April 29 2014
JVM: 1.7.0_79 (Oracle Corporation 24.79-b02)
OS: Mac OS X 10.10.5 x86_64
stderr:
Exec javac -version
stdout:
stderr: javac 1.7.0_79
System information:
{ procInfo: 'nativescript/1.4.2',
platform: 'darwin',
os: 'Darwin macbookpro 14.5.0 Darwin Kernel Version 14.5.0: Wed Jul 29 02:26:53 PDT 2015; root:xnu-2782.40.9~1/RELEASE_X86_64 x86_64\n',
shell: '/bin/bash',
dotNetVer: null,
procArch: 'x64',
nodeVer: 'v0.12.7',
npmVer: '2.11.3',
javaVer: '1.7.0',
nodeGypVer: null,
xcodeVer: 'Xcode 7.0.1\nBuild version 7A1001\n',
itunesInstalled: true,
cocoapodVer: null,
adbVer: 'Android Debug Bridge version 1.0.32',
androidInstalled: true,
monoVer: '4.0.2',
gitVer: '2.3.8 (Apple Git-58)',
gradleVer: '2.4',
javacVersion: '1.7.0_79' }
Initializing analytics statuses.
Analytics statuses:
{ TrackFeatureUsage: 0, TrackExceptions: 0 }
Trying to track feature 'CLI' with value 'platform'.
AnalyticsInstallationID: f137150b-da8f-4e4c-b8bf-0553dd8d46ed
monitor not started
monitor not started
monitor has started, connecting to http://5752dabccfc54c4ab82aea9626b7338e.monitor-eqatec.com/json.ashx
BeforeHookName for command platform-add is before-platform-add
AfterHookName for command platform-add is after-platform-add
Looking for project in '/Users/nraboy/Desktop/nsproject'
Project directory is '/Users/nraboy/Desktop/nsproject'.
spawn: adb version
Statistics was sent successfully (xhr).
Analytics statuses:
{ TrackFeatureUsage: 0, TrackExceptions: 0 }
Trying to track feature 'CLI' with value 'platform|add'.
BeforeHookName for command platform|add is before-platform
AfterHookName for command platform|add is after-platform
Statistics was sent successfully (xhr).
Statistics was sent successfully (xhr).
Exec android list targets
stdout: Available Android targets:
----------
id: 1 or "android-19"
Name: Android 4.4.2
Type: Platform
API level: 19
Revision: 4
Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in
Tag/ABIs : default/armeabi-v7a, default/x86
----------
id: 2 or "android-20"
Name: Android 4.4W.2
Type: Platform
API level: 20
Revision: 2
Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in, AndroidWearRound, AndroidWearSquare, AndroidWearRound, AndroidWearSquare
Tag/ABIs : android-wear/armeabi-v7a, android-wear/x86
----------
id: 3 or "android-21"
Name: Android 5.0.1
Type: Platform
API level: 21
Revision: 2
Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in, AndroidWearRound, AndroidWearSquare, AndroidWearRound, AndroidWearSquare
Tag/ABIs : android-tv/armeabi-v7a, android-tv/x86, android-wear/armeabi-v7a, android-wear/x86, default/armeabi-v7a, default/x86, default/x86_64
----------
id: 4 or "android-22"
Name: Android 5.1.1
Type: Platform
API level: 22
Revision: 2
Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in
Tag/ABIs : android-tv/armeabi-v7a, android-tv/x86, default/armeabi-v7a, default/x86, default/x86_64
----------
id: 5 or "android-MNC"
Name: Android M (Preview)
Type: Platform
API level: MNC
Revision: 2
Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in
Tag/ABIs : no ABIs.
----------
id: 6 or "android-23"
Name: Android 6.0
Type: Platform
API level: 23
Revision: 1
Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in
Tag/ABIs : android-tv/armeabi-v7a, android-tv/x86, default/armeabi-v7a, default/x86, default/x86_64
----------
id: 7 or "Google Inc.:Glass Development Kit Preview:19"
Name: Glass Development Kit Preview
Type: Add-On
Vendor: Google Inc.
Revision: 11
Description: Preview of the Glass Development Kit
Based on Android 4.4.2 (API level 19)
Libraries:
* com.google.android.glass (gdk.jar)
APIs for Glass Development Kit Preview
Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in
Tag/ABIs : no ABIs.
----------
id: 8 or "Google Inc.:Google APIs:19"
Name: Google APIs
Type: Add-On
Vendor: Google Inc.
Revision: 16
Description: Android + Google APIs
Based on Android 4.4.2 (API level 19)
Libraries:
* com.google.android.media.effects (effects.jar)
Collection of video effects
* com.android.future.usb.accessory (usb.jar)
API for USB Accessories
* com.google.android.maps (maps.jar)
API for Google Maps
Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in
Tag/ABIs : default/armeabi-v7a
----------
id: 9 or "Google Inc.:Google APIs (x86 System Image):19"
Name: Google APIs (x86 System Image)
Type: Add-On
Vendor: Google Inc.
Revision: 16
Description: Android x86 + Google APIs
Based on Android 4.4.2 (API level 19)
Libraries:
* com.google.android.media.effects (effects.jar)
Collection of video effects
* com.android.future.usb.accessory (usb.jar)
API for USB Accessories
* com.google.android.maps (maps.jar)
API for Google Maps
Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in
Tag/ABIs : default/x86
----------
id: 10 or "Google Inc.:Google APIs:21"
Name: Google APIs
Type: Add-On
Vendor: Google Inc.
Revision: 1
Description: Android + Google APIs
Based on Android 5.0.1 (API level 21)
Libraries:
* com.google.android.media.effects (effects.jar)
Collection of video effects
* com.android.future.usb.accessory (usb.jar)
API for USB Accessories
* com.google.android.maps (maps.jar)
API for Google Maps
Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in, AndroidWearRound, AndroidWearSquare, AndroidWearRound, AndroidWearSquare
Tag/ABIs : google_apis/armeabi-v7a, google_apis/x86, google_apis/x86_64
----------
id: 11 or "Google Inc.:Google APIs:22"
Name: Google APIs
Type: Add-On
Vendor: Google Inc.
Revision: 1
Description: Android + Google APIs
Based on Android 5.1.1 (API level 22)
Libraries:
* com.google.android.media.effects (effects.jar)
Collection of video effects
* com.android.future.usb.accessory (usb.jar)
API for USB Accessories
* com.google.android.maps (maps.jar)
API for Google Maps
Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in
Tag/ABIs : google_apis/armeabi-v7a, google_apis/x86, google_apis/x86_64
----------
id: 12 or "Google Inc.:Google APIs:23"
Name: Google APIs
Type: Add-On
Vendor: Google Inc.
Revision: 1
Description: Android + Google APIs
Based on Android 6.0 (API level 23)
Libraries:
* com.google.android.media.effects (effects.jar)
Collection of video effects
* com.android.future.usb.accessory (usb.jar)
API for USB Accessories
* com.google.android.maps (maps.jar)
API for Google Maps
Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in
Tag/ABIs : no ABIs.
stderr:
Creating NativeScript project for the android platform
Path: /Users/nraboy/Desktop/nsproject/platforms/android
Package: org.nativescript.nsproject
Name: nsproject
Copying template files...
Using version 1.4.0.
Shasum of file /Users/nraboy/.npm/tns-android/1.4.0/package.tgz is db6759935a327b63ca20d175a8ef82a3ee7e915a
Checking shasum of package: tns-android@1.4.0: expected db6759935a327b63ca20d175a8ef82a3ee7e915a, actual db6759935a327b63ca20d175a8ef82a3ee7e915a.
Exec android list targets
stdout: Available Android targets:
----------
id: 1 or "android-19"
Name: Android 4.4.2
Type: Platform
API level: 19
Revision: 4
Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in
Tag/ABIs : default/armeabi-v7a, default/x86
----------
id: 2 or "android-20"
Name: Android 4.4W.2
Type: Platform
API level: 20
Revision: 2
Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in, AndroidWearRound, AndroidWearSquare, AndroidWearRound, AndroidWearSquare
Tag/ABIs : android-wear/armeabi-v7a, android-wear/x86
----------
id: 3 or "android-21"
Name: Android 5.0.1
Type: Platform
API level: 21
Revision: 2
Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in, AndroidWearRound, AndroidWearSquare, AndroidWearRound, AndroidWearSquare
Tag/ABIs : android-tv/armeabi-v7a, android-tv/x86, android-wear/armeabi-v7a, android-wear/x86, default/armeabi-v7a, default/x86, default/x86_64
----------
id: 4 or "android-22"
Name: Android 5.1.1
Type: Platform
API level: 22
Revision: 2
Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in
Tag/ABIs : android-tv/armeabi-v7a, android-tv/x86, default/armeabi-v7a, default/x86, default/x86_64
----------
id: 5 or "android-MNC"
Name: Android M (Preview)
Type: Platform
API level: MNC
Revision: 2
Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in
Tag/ABIs : no ABIs.
----------
id: 6 or "android-23"
Name: Android 6.0
Type: Platform
API level: 23
Revision: 1
Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in
Tag/ABIs : android-tv/armeabi-v7a, android-tv/x86, default/armeabi-v7a, default/x86, default/x86_64
----------
id: 7 or "Google Inc.:Glass Development Kit Preview:19"
Name: Glass Development Kit Preview
Type: Add-On
Vendor: Google Inc.
Revision: 11
Description: Preview of the Glass Development Kit
Based on Android 4.4.2 (API level 19)
Libraries:
* com.google.android.glass (gdk.jar)
APIs for Glass Development Kit Preview
Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in
Tag/ABIs : no ABIs.
----------
id: 8 or "Google Inc.:Google APIs:19"
Name: Google APIs
Type: Add-On
Vendor: Google Inc.
Revision: 16
Description: Android + Google APIs
Based on Android 4.4.2 (API level 19)
Libraries:
* com.google.android.media.effects (effects.jar)
Collection of video effects
* com.android.future.usb.accessory (usb.jar)
API for USB Accessories
* com.google.android.maps (maps.jar)
API for Google Maps
Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in
Tag/ABIs : default/armeabi-v7a
----------
id: 9 or "Google Inc.:Google APIs (x86 System Image):19"
Name: Google APIs (x86 System Image)
Type: Add-On
Vendor: Google Inc.
Revision: 16
Description: Android x86 + Google APIs
Based on Android 4.4.2 (API level 19)
Libraries:
* com.google.android.media.effects (effects.jar)
Collection of video effects
* com.android.future.usb.accessory (usb.jar)
API for USB Accessories
* com.google.android.maps (maps.jar)
API for Google Maps
Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in
Tag/ABIs : default/x86
----------
id: 10 or "Google Inc.:Google APIs:21"
Name: Google APIs
Type: Add-On
Vendor: Google Inc.
Revision: 1
Description: Android + Google APIs
Based on Android 5.0.1 (API level 21)
Libraries:
* com.google.android.media.effects (effects.jar)
Collection of video effects
* com.android.future.usb.accessory (usb.jar)
API for USB Accessories
* com.google.android.maps (maps.jar)
API for Google Maps
Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in, AndroidWearRound, AndroidWearSquare, AndroidWearRound, AndroidWearSquare
Tag/ABIs : google_apis/armeabi-v7a, google_apis/x86, google_apis/x86_64
----------
id: 11 or "Google Inc.:Google APIs:22"
Name: Google APIs
Type: Add-On
Vendor: Google Inc.
Revision: 1
Description: Android + Google APIs
Based on Android 5.1.1 (API level 22)
Libraries:
* com.google.android.media.effects (effects.jar)
Collection of video effects
* com.android.future.usb.accessory (usb.jar)
API for USB Accessories
* com.google.android.maps (maps.jar)
API for Google Maps
Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in
Tag/ABIs : google_apis/armeabi-v7a, google_apis/x86, google_apis/x86_64
----------
id: 12 or "Google Inc.:Google APIs:23"
Name: Google APIs
Type: Add-On
Vendor: Google Inc.
Revision: 1
Description: Android + Google APIs
Based on Android 6.0 (API level 23)
Libraries:
* com.google.android.media.effects (effects.jar)
Collection of video effects
* com.android.future.usb.accessory (usb.jar)
API for USB Accessories
* com.google.android.maps (maps.jar)
API for Google Maps
Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in
Tag/ABIs : no ABIs.
stderr:
Selected targetSdk is: 23
Selected AppCompat version is: undefined
The ANDROID_HOME environment variable is not set or it points to a non-existent directory. You will not be able to perform any build-related operations for Android.
Any suggestions appreciated.
Thanks,
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 37 (7 by maintainers)
For anybody else who was on information overload - if you have a ~/.bash_profile set up, this is the issue. Quickly add this to your ~/.bash_profile:
export ANDROID_HOME=/usr/local/opt/android-sdk
export JAVA_HOME=/Library/Java/Home
and you should be good to go.
Hi @seppel1992 , It looks like you have not set your ANDROID_HOME environment variable. You can try:
export ANDROID_HOME=<path to your android-sdk>
where<path to your android-sdk>
is the path to installation folder of Android SDK (the folder in which tools, and platform-tools directories are).Please note that this command will only set the ANDROID_HOME for your current shell, consider adding the row to your
.bashrc
file (in case you are using bash)I had the same issue on OSX and I fixed it instaling the Android Studio. After that, I set the ANDROID_HOME and worked pretty well.
export ANDROID_HOME=/Users/$(whoami)/Library/Android/sdk/
If you have the Android Studio in your machine, you should use the path provided by Android Studio. That is different that the one returned by “which android”. In my case it points to a folder in my user home.
The path should be set under the bash_profile file ( $ nano ~/.bash_profile)
I had problems at the begging, but they were fixed after I created a dummy project in android studio and run it in the emulator.
A second problem I had was that the emulator I was trying to use required too much memory, so I deleted it and downloaded a different emulator that needs less memory. This can be done in Android Studio.
I hope that helps.
solved in my case by running the following in cmd (windows 10)
stackoverflow
I had this issue, and it was caused by the permissions for NodeJS. I was having to run the install script with
sudo
, and was getting the ANDROID_HOME error listed above. I resolved the issue by running:sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}
I just wanted to add this here, since it wasn’t obvious to me at first, and thought it might help others that stumble across this issue. The linked issue #1744 solved my problem, I had a
~/.bash_profile
that I setup awhile ago, and totally forgot about, which was causing my terminal to ignore the exported variables defined in~/.profile
.@rosen-vladimirov Yes this resolved my issue. Thanks!
Hey @Simone-cogno , The user-settings.json.lock file is created by CLI during command execution. Once a command finishes, the file should be remove. However, it looks like you have executed some command with sudo and the directory permissions are messed. The other option is that the file itself still exist and is owned by the root user. Anyway, can you please verify that your user is the owner of
~/.local/share/.nativescript-cli
directory and all of its subdirectories. You can fix the ownership by executing:Also you can safely remove the
/home/simo/.local/share/.nativescript-cli/user-settings.json.lock
file:After that execute
tns doctor
without sudo - you do not need sudo for CLI commands.@leocaseiro: Thanks, your solution worked for me, but you’ve got a typo in the command there.
ANROID_HOME -> ANDROID_HOME
My Issue was I had
ANDROID_HOME
set through my individual User account path, so it looked like this:C:\Users\[MyAccount]\AppData\Local\Android\android-sdk
When in-fact it should have looked like this:C:\Program Files\Android\android-sdk
Hope this helps
@jpsalvadorm63 In windows 10, I changed it to “C:\Program Files (x86)\Android\android-sdk”, logged out and back in, and it’s now working.
In windows 10,
the ANDROID_HOME generated is: ${Env:LOCALAPPDATA}\Android\android-sdk
I changed to: %LOCALAPPDATA%\Android\sdk
but still not working
I already started the AVD
Any help is welcome. I’m running my first two hours in nativescript
In osx I’ve added following to .bash_profile:
It’s getting all from both files and it’s working for me.
@vinita1505,
You can modify
~/.bash_profile
or~/.bashrc
file: