Skip to content

"tns platform add android" throwing error #1564

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
DeepakDonde opened this issue Mar 3, 2016 · 7 comments
Closed

"tns platform add android" throwing error #1564

DeepakDonde opened this issue Mar 3, 2016 · 7 comments
Labels

Comments

@DeepakDonde
Copy link

I am getting so
log.txt
me issue while running "tns platform add android" command.
Every time when I run above command on cmd, I get following error -
"Unable to find "android.bat" executable file. Make sure you have set ANDROID_HOME environment variable correctly.(this is in red color on cmd).
Sending exception report (press Ctrl+C to stop)....... "
Can you please help me resolving this ?
I have attached log trace for your reference.
Please help.

@rosen-vladimirov
Copy link
Contributor

Hi @DeepakDonde ,
It looks like something's wrong with your Android SDK installation. May I ask you to uninstall the SDK and install it again as it looks like your tools directory is missing some of the required executables. Also make sure you've set your JAVA_HOME correctly as pointed in our help.

Could you give it a try and inform us if this helps?

@DeepakDonde
Copy link
Author

Hello @rosen-vladimirov ,
Thanks for the reply.

I have already tried installing new SDK and run it again but still its not working.

Please can you check following are my system configurations.
Android SDK : API 22 (Android 5.1.1)
Android SDK Build-tools : 23.0.2
Android Support Library : 23.2
JDK : jdk1.7.0_71 (JDK 7)
node.js : version 4.3.1

Following are my Environmental Variables -
JAVA_HOME : C:\Program Files\Java\jdk1.7.0_71
ANDROID_HOME : E:\ANDROID\sdk
path : %PATH%;C:\Program Files\Java\jdk1.7.0_71\bin;C:\Program Files\Java\jdk1.6.0_45\bin;C:\Program Files\nodejs;E:\ANDROID\sdk\tools;E:\ANDROID\sdk\platform-tools;

Also, when I run android.bat file on cmd, the sdk manager open as it should be. So I am wondering why it is not able to fine that "android.bat" file .. :|
Do I need to install JDK 8 ? is it compulsory? I read it somewhere JDK 7 will also do.
Am I missing something ? Please help. Its bit Urgent.

Thanks..

@rosen-vladimirov
Copy link
Contributor

Hi @DeepakDonde
It's recommended to install JDK 1.8.x.
Calling android directly from your terminal is working because you have added the tools directory to your PATH environment variable. Try calling %ANDROID_HOME%\tools\android from your terminal and see if it works - that's what CLI is trying to do.
I've checked for similar errors and it seems there were some issues in the android.bat file with JDK 1.7 (more info here), so please update your Java and try again.
The other configurations seems correct :)

@DeepakDonde
Copy link
Author

Hi @rosen-vladimirov
I have installed JDK 1.8.0_74 as per your recommendation. Also I have updated JAVA_HOME and path accordingly.
Still the error persists.. :|
I am stuck since 5 days on same error.

I also tried calling %ANDROID_HOME%\tools\android from my terminal as per your suggestion, It works perfectly fine !!

As per the documentation, I have run "tns doctor" on cmd, I am getting following :
NOTE: You can develop for iOS only on Mac OS X systems.
To be able to work with iOS devices and projects, you need Mac OS X Mavericks or
later.
No issues were detected.

Any other command that I can run and know where am I making mistake ?

@DeepakDonde
Copy link
Author

Hello @rosen-vladimirov ,
After so much hassle, it turn out to be a very basic and surprising error.
My working directory was containing the symbol "&", which was according to log file generated,was not acceptable .. :/
Log says : \r\nError: The working directory does not seem to be valid: 'E:\Android R\n',exitCode: 0 }

Now I have changed my directory name and it does not give that damn error anymore and platform android gets created properly. :)

Thanks for all your time and help ..!!
I really appreciate .. !!

@rosen-vladimirov
Copy link
Contributor

@DeepakDonde , thanks for sharing the problem and the fix you've found. Really weird behavior of android.bat file.
Anyway, I'm glad you resolved it.

@DocGreenRob
Copy link

I am having the same issue. Here is a screenshot of my environment variables. (see below)

env_vars

The error message is:

Unable to find "android.bat" executable file. Make sure you have set ANDROID_HOME environment variable correctly.
WARNING: The Android SDK is not installed or is not configured properly.
You will not be able to build your projects for Android and run them in the native emulator.
To be able to build for Android and run apps in the native emulator, verify that you have
installed the latest Android SDK and its dependencies as described in http://developer.android.com/sdk/index.html#Requirements

TIP: To avoid setting up the necessary environment variables, you can use the chocolatey package manager to install the Android SDK and its dependencies.

NOTE: You can develop for iOS only on Mac OS X systems.
To be able to work with iOS devices and projects, you need Mac OS X Mavericks or later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants