The ANDROID_HOME environment variable is not set or it points to a non-existent directory in Ubuntu
Asked Answered
E

2

5

I placed Android SDK inside /opt/android-sdk and also updated .bashrc file with the lines :

export ANDROID_HOME="/opt/android-sdk" export PATH=$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$PATH

then I reloaded the .bashrc file:

source ~/.bashrc

After that I checked the ANDROID_HOME by hitting the command as:

echo $ANDROID_HOME

which resulted as:

/opt/android-sdk

which is the correct location where I placed it. After that I created a NativeScript Mobile Application project :

tns create MobileApp --ng

then I entered inside the MobileApp directory and tried to add platform as Android:

tns platform add android

but I got this error which stated as follow :

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.

Did I miss anything in the above process of adding Android as platform in NativeScript Mobile Application project?

Erectile answered 28/12, 2016 at 15:39 Comment(4)
Try logging out of Ubuntu and logging back in, to make sure all your user processes have the ANDROID_HOME environment variable. Perhaps tns works with some previously-forked daemon process.Daphne
I did, but it didn't work. Anyway thanks for response.Erectile
This thread might help you I guess.Tanatanach
Pro-tip: console I/O is best presented in questions/answers here using code Markdown rather than quote blocks. Use a four-space prefix or select the text and click the 'code' button.Perfect
E
10

Issue solved :

I added ANDROID_HOME and PATH in .profile file in $HOME directory as :

export ANDROID_HOME="/opt/android-sdk" export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools

then I restarted the system and tried with below command :

tns platform add android

and then it worked. Here's the logs for reference.

Copying template files...
◠ Installing [email protected] node_modules/babel-traverse
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] ([email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected])
└── [email protected] ([email protected], [email protected])
◝ Installing [email protected] node_modules/babel-types
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected] ([email protected], [email protected])
◝ Installing [email protected] node_modules/babylon
◝ Installing [email protected] node_modules/lazy
Project successfully created.

Erectile answered 28/12, 2016 at 18:13 Comment(0)
D
1

There is a perfect solution here, you may face other problems too. I've provided the solutions for other as well.

setting up the NS (native script). tns doctor android home issue.unable to run this command.

  • Changed the environment variable to

  • set ANDROID_HOME=C:\ installation location \android-sdk

  • set PATH=%PATH%;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools

  • Close cmd or VS, and restarted it, ran it again

  • Done.

Unable to craete the basic project from tns create. (there was an issue with JSON string)

  • Delete all the files from this location.

  • C:\Users\binu\AppData\Roaming\npm and

  • C:\Users\binu\AppData\Roaming\npm-cache

  • Then update your npm to the latest version by running npm i npm@latest -g npm i -g nativescript

  • [Done]

Need to create android emulator to run the test, one of the method is avd manager.

  • cd $ANDROID_HOME/tools/bin

  • sdkmanager "system-images;android-25;google_apis;x86"

  • avdmanager create avd -n test -k "system-images;android-25;google_apis;x86"

  • and then run "tns run android"

  • but now if it shows black screen.

  • sdkmanager emulator

  • [done]

Deese answered 16/5, 2020 at 18:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.