What environment variable to set for "android update project -p ..." - android

I'm trying to set up ANT for my Android project. According to the Android website, the command to use is
android update project -p name
Unfortunately, the command "android" is not available on my command line (Windows 7).
Can you please tell me what kind of environment variables do I have to set up? The SDK is located in C:\Program Files (x86)\Android\android-sdk, I assume I will need that.
Do I just have to extend "path" or is there the need to create new variables (something like "JAVA_HOME", but for android).
Thank you

C:\Program Files (x86)\Android\android-sdk\tools
C:\Program Files (x86)\Android\android-sdk\platform-tools
are both valuable to have on the path. I don't remember which has the android binary, but, with both, you will definitely get it. With both you will also get adb and progaurd.
And also, extend PATH don't create a new one.

Related

Is there a way to tell WebStorm EAP where to find android_home?

Anyone managed to solve the issue with ANDROID_HOME variable with WebStorm EAP?
I have set up the variable at my machine level, and did it at WebStorm level but does not work:
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
Any idea?
I was facing the same problem in Ubuntu 15.10. It worked nicely when I compiled the program from terminal, but not when I tried the same command from WebStorm IDE.
The solution was trivial, yet hard to find. If you start the program from the launcher (or desktop file), the environmental variables are not getting populated the same way as from the .bashrc file. That is why there was no ANDROID_HOME at all, and the PATH was also different.
The accepted answer from this thread solved my problem: My .bashrc alias not run in .desktop file
Solution for Linux:
Find the WebStorm IDE desktop file (Mine was located at ~/.local/share/applications/jetbrains-webstorm.desktop)
Edit the Exec command (Add bash -ic before the executable file: Exec=bash -ic "/path/to/webstorm/bin/webstorm.sh" %f)
If you know the path to your android sdk home from your root then what you need to do is as a root user edit the /etc/profile and add this line at the end
export ANDROID_HOME="path/to/my/sdk"
To edit the /etc/profile file you can use nano,
sudo nano /etc/profile
add the export line at the end of the file, then press ctrl+o on your keyboard to save and ctrl+x on your keyboard to close.
Then restart your computer, you have successfully added the ANDROID_HOME env variable to your OS
In Linux, one should mind the difference between a login and an interactive shell environments. The former is visible to any application in a session, the latter - only to a shell (and processes launched from that shell). The correct solution is moving your variables into a login environment (~/.profile, ~/.bash_profile etc.) and restarting a session.
Under macOS, all JetBrains IDEs explicitly load a shell environment. If some variable isn't visible to some IDE component, then it's a bug either in that component or in a code which loads the environment; both cases better be reported to http://youtrack.jetbrains.com.

Launch Android SDK manager - Tools directory doesn't exist? Mac

I'm on mac, I think I've done everything right so far. following these instructions:
http://developer.android.com/sdk/installing/adding-packages.html
it says to navigate to tools/ directory in terminal. Here are my steps.
Open terminal
cd Applications
result is: No such file or directory
path to my tools directory is as follows
Applications->adt-bundle-mac-x86_64-20130219 ->SDK -> tools
I tried putting my folder onto my desktop, both the tools folder, and my adt-bundle because I could change directory to my desktop, and when I enter ls to the terminal I see my tools folder, and my adt-bundle is there,
but the problem is when I try to enter
cd tools
or
cd adt-bundle(etc...)
it says that it is not a directory.
what do I do?
Go to this directory:
cd /adt-bundle-mac-x86_64-20131030/sdk/tools
and run:
./android
I recently encountered this issue, and figured I'd post on this for clarification or for anyone still encountering it.
It seems you have to be at the root of the /adt-bundle-mac-VERSION/sdkdirectory in order to execute the "android" command.
I normally cd into the directory until I reach the location of the command, but in this case I encountered the same issue as the original poster.
You must use the tab key to the android command...
ie...
locate your installation /adt-bundle-mac-x86_64-20131030/sdk hit TAB key /tools hit TAB key /android
instead of cd adt-bundle-mac-x86_64-20131030/ cd/sdk cd/tools android
If done properly the SDK manager should launch for you.
Hope this helps anybody out there.
You can launch the SDK Manager by using the GUI:
Launch Android Studio
Create a new blank project
In the toolbar, look for the icon with tooltip "SDK Manager"
A lot of answers have been given here that you should go to /{path-to-your-android-sdk}/tools
and run ./android.
For me, this did not work. When I opened the android file located at my /{path-to-your-android-sdk}/tools directory with a text editor, it contained the following:
#!/bin/bash
echo The "android" command is no longer available.
echo For manual SDK and AVD management, please use Android Studio.
echo For command-line tools, use tools/bin/sdkmanager and tools/bin/avdmanager
exit 1
So the right approach now, is as stated by #Shijil in his comment.
In the directory for your android sdk, you should use:
For SDK Manager:
cd tools
cd bin
./sdkmanager
For AVD Manager:
cd tools
cd bin
./avdmanager
NB For the last command in each of the options above, you will have to supply additional args depending on the operation you want to perform. An example arg that works for both is --list. Running the commands without any args will only display the possible args you could have passed.
Personally, I think using the GUI in android studio is easier. Especially for linux beginners.
Use cd /users/user/...your path.../android-sdk/tools
and then :
./android
Here is your "tools" directory for Android Studio in OS X El Captain(Yosemite also has the same path hopefully):
Users/user-name/Library/Android/sdk/tools
In the terminal, just type: Library/Android/sdk/tools
and hit enter. And you are in the tools folder.
Please note that user-name refers to the mac user
Better open terminal and type which android.
It will tell you the path where you have the package installed.
Then yeah, you just have to execute that path on the terminal.
Your android package might have been installed with Homebrew or others, so the path can be different.
Edit: typo
For me the directory was cd /Users/your_user_name/Library/Android/sdk/tools/
and after that the command was ./android list targets
I hope this can help

Android SDK Manager will not run

i'm on a Windows 7 Pro x64 with java jdk 7u7.
I try to install the Android SDK on my computer, but when i launch SDK Manager.exe, a dos-windows is opening and instantly closing. So i tried to launch tools/android.bat. But that didn't work, it say to me that :
"'C:\PROGRA~2\Android\ANDROI~1\tools\lib\\find_java.exe -s' isn't a external or internal command ...
ERROR No suitable java such ..."
What i have do for fix error :
Install Java 6u35
Install Java x32 and x64
Check my path
Launch in administrator
Install in C:\Dev the sdk
Install with android-sdk.zip or with android-sdk.exe
Add android directory in path
But anyone of this try was successful.
Someone can help me?
There appear to be several ways to launch the SDK Manager:
SDK Manager.exe in the root of the Android SDK.
SDK Manager.exe in sdk\tools\lib of the Android SDK.
Window -> Android SDK Manager menu in Eclipse
android.bat in sdk\tools of the Android SDK.
In my case, it looks like android.bat fails on the line:
for /f %%a in ('%java_exe% -jar lib\archquery.jar') do set swt_path=lib\%%a
As far as what that line is doing... if I manually run: "[path_to_java]java" -jar lib\archquery.jar
It successfully returns: x86_64
But when the batch file runs that same command, I don't know why but it fails with the error message:
Unable to access jarfile lib\archquery.jar
So the variable swt_path gets set to an empty string. Everything breaks down from there.
The batch file sets the correct value for the variable java_exe. Others have commonly reported this as a problem, but those workarounds weren't relevant in my case.
People have recommended commenting out the problem line by adding REM to the beginning of it, and adding a line to manually set the swt_path variable, which is a valid workaround:
REM for /f %%a in ('%java_exe% -jar lib\archquery.jar') do set swt_path=lib\%%a
set swt_path=lib\x86
BUT, the critical issue in my case is that it's choosing to load a jar file from either the lib\x86 or the lib\x86_64 folder here. At some point, things were getting confused between the BAT file error, a 32-bit JDK, and a 64-bit Android SDK.
SO, the workaround in my case was to:
Uninstall ALL versions of Java
Install the JDK
You can either use the 32-bit Android SDK and install the 32-bit JDK
Or use the 64-bit Android SDK and install the 64-bit JDK
But the "bitness" of the JDK should match the Android SDK. It appears that either of the 32-bit or the 64-bit will work on a 64-bit computer, AS LONG AS the JDK bitness matches the Android SDK bitness.
Edit "android.bat"
If using the 32-bit Android SDK/JDK, use lib\x86:
REM for /f %%a in ('%java_exe% -jar lib\archquery.jar') do set swt_path=lib\%%a
set swt_path=lib\x86
If using the 64-bit Android SDK/JDK, use lib\x86_64:
REM for /f %%a in ('%java_exe% -jar lib\archquery.jar') do set swt_path=lib\%%a
set swt_path=lib\x86_64
After doing this, I can successfully run the SDK Manager by running android.bat, or from the Eclipse menu (but still not by running either of the SDK Manager.exe files directly).
I had this answer just this week and have determined what is causing it.
When Java updates it changes the path where the executable files are stored. This means that when the SDK manager goes to look up javaw.exe it cannot find it and instantly closes.
Therefore re-installing the Android SDK will NOT solve the problem.
Neither will re-installing JAVA.
The only way to solve this problem is to correctly point to the location where JAVA is stored.
Windows has a way of doing this called an Environmental Variable.
There is a variable called PATH which stores all the directories where Windows will look for executable files.
Thus you have to to modify that PATH variable to include a path to JAVA.
By default JDK 7 has the following path:
C:\Program Files\Java\jdk1.7.0_10\bin
To edit your Environmental Variables do the following.
From the Start Menu right click on Computer and select "Properties"
This will take you to the Control Panel System Menu
On the left column look for the option "Advanced System Settings"
This will open a System Properties window
One of the tabs is named Advanced
In that there is a button that says Environmental Variables
If you search your System Variables you will see one called "Path"
Edit that variable and add the path above to include the latest Java Path.
Once you are done the SDK Manager should immediately be able to open up and you can continue updating to the latest revision of the Android SDK.
Once the updates complete don't forget to make sure your IDE (ie Eclipse) is pointing to the correct location where the SDK is stored so that it reads the latest Android SDK files. To access this setting in Eclipse, go to Window -> Preferences -> Android
This will allow you to manually set the path where the SDK is stored.
The only thing that helped me was reinstalling java into a path that did not contain any spaces, so instead of C:/Program Files to C:/Java and change the Path variable to the new value.
Hope this helps.
I had the same issue and it's most likely caused by spaces in the path names. It's known that spaces in path names and batch files don't combine well together.
You can verify that by opening a command line prompt, changing the location to %SDK%\tools\lib and running find_java.bat. You will get an batch error like
'C:\PROGRA~2\Android\Android' is not recognized as an internal or external command,
operable program or batch file.
Just install the SDK into C:\Android\SDK and the NDK into C:\Android\NDK and it will work.
This is how I finally fix it
open tools/android.bat
set java_exe=
call lib\find_java.bat
if not defined java_exe goto :EOF
replace it with your java path
set java_exe="c:\PROGRA~1\Java\jdk1.7.0\bin\java.exe"
Note:
Do not use C:\Program Files\Something it throw an error because of the space
use the short name notation C:\PROGRA~1\Something
and it will work like charm
Same issue for me SDK Manager.exe just stopping with no error message or windows event.
I fixed this with a hybrid of the already provided answers (I'm running on Win 8.1). The problem appears to be that the java.exe targeted by find_java was out-of-step with the recently installed JDK version.
for me:
<sdk> was C:\Users\Simon\AppData\Local\Android\sdk
<jdk> was C:\PROGRA~1\Java\jdk1.7.0_80\bin
I added my JDK install path to the PATH environment variable e.g. ...;C:\PROGRA~1\Java\jdk1.7.0_80\bin;...
After opening a new command window and running find_java.bat in the <sdk>\tools\lib\ folder I noticed that the java_exe env variable was set was to C:\Windows\System32\java.exe which was not what I expected.
I deleted (well renamed) the java.exe in C:\Windows\System32
I ran find_java.bat again and now the java_exe env variable was set to java_exe=<jdk>\java.exe as expected.
Then in <sdk> I could run SDK Manager.exe successfully.
Changing the JAVA_HOME from existing pointing to a JDK path to a JRE path works for me.

android' is not recognized as an internal or external command

I'm trying to get the new GCM service to work for me, so I've been following the demo as described here: http://developer.android.com/guide/google/gcm/demo.html
So far, everything works well. However, I'm supposed to build the ant files using the command line now, and that's where things stop working.
For some reason, this command $ android update project --name GCMDemo -p . --target android-16 gives me a very nice
'android' is not recognized as an internal or external command,
operable program or batch file.
Normally this can be fixed easily with a quick Google search, but I haven't found a single other user with this problem. Could someone tell me what the problem is?
My educated guess is that I need to add the Android tools folder to my PATH, but I'd rather be sure first.
Your guess is correct, just add the folder containing android.bat(tools folder) to the PATH. Otherwise the system will not be able to find the program.
Other possibility is change directory (using cd) to the tools folder, and execute the command from there. Since the current directory (whatever it is) is usually in the PATH, the system will find it. But this is not handy, because you frequently want to execute this command being in a different directory.
Find android.bat on your system. On mine (win 8 x64) it's under C:\Users\{username}\AppData\Local\Android\sdk\tools\android.bat
Open a command console, and use the 'doskey' command:
doskey android=C:\Users\{username}\AppData\Local\Android\sdk\tools\android.bat $*
This will continue to work in the open command console. To make it permanent is more difficult: http://darkforge.blogspot.com/2010/08/permanent-windows-command-line-aliases.html
You can also try adding it to your PATH as another poster suggested, but that didn't work for me. I recommend an easy gui for doing it, such as https://patheditor2.codeplex.com/
In Windows 7, navigate to
Control Panel\System and Security\System > advance system settings > environment variables
and update the path to include the following:
<android-root>\android-sdk-windows\tools
Use semicolons to separate paths if more than one exist.
On Windows 10, add both:
C:\Users\Parag Jain\AppData\Local\Android\sdk\tools
C:\Users\Parag Jain\AppData\Local\Android\sdk\build-tools
to the PATH environment variable of System and User. Make sure that you close your command prompt and restart a new prompt and then try the command.
Compiling previous answers I did the following to get Android SDK and gradle working (You need gradle working anyway to compile your Android project):
Prerequisites. You have Java jdk, Android SDK and gradle installed in the folders like I found on my computer. Please, check it:
C:\Program Files\Java\jdk1.X.X_XX\
C:\Users{username}\AppData\Local\Android\sdk\
C:\Program Files\Android\Android Studio\gradle\gradle-X.X\
Set up three new system variable (Control Panel\System and Security\System Advance system ->settings->environment variables-system variables). Do not forget to change java and gradle versions.
JAVA_HOME C:\Program Files\Java\jdk1.X.X_XX
ANDROID_HOME C:\Users\{username}\AppData\Local\Android\sdk
GRADLE_HOME C:\Program Files\Android\Android Studio\gradle\gradle-X.X\
Add the following paths to system paths (Control Panel\System and Security\System Advance system ->settings->environment variables-system variables):
%JAVA_HOME%
%ANDROID_HOME%\tools\
%ANDROID_HOME%\platform-tools
%GRADLE_HOME%\bin
Close and open once again your Dos application (Cmd terminal, etc.). You might want to REBOOT your computer, to make sure, that the system sees the variables. If you do not want to reboot, you can use the advice of #wordsforthewise
doskey android=C:\Users\{username}\AppData\Local\Android\sdk\tools\android.bat $*
Check if Android SDK and gradle work properly with the terminal commands
$ java -version
$ android list target
$ gradle -v
What worked for me:
Setting up the ANDROID_HOME variable as a System variable instead of a user variable.
I am using Windows 10, not sure if that matters.
I resolved this issue permanently using the below steps.
OS version : windows 7 64 bit
Solution : Set environment variable for android sdk and gradle
Step 1: Create new "ANDROID_HOME" User Variable
Variable Name: ANDROID_HOME
Variable Value C:\Users{user_name}\AppData\Local\Android\sdk\
Step 2: Create new "GRADLE_HOME" User Variable
Variable Name: GRADLE_HOME
Variable Value C:\Program Files\Android\Android Studio\gradle\gradle-x.x\
*Do not forget to change and gradle versions.
Step 3: Create "ANDROID_HOME" System Variable
Variable Name: ANDROID_HOME
Variable Value C:\Users{user_name}\AppData\Local\Android\sdk\
Step 4: Create new "GRADLE_HOME" System Variable
Variable Name: GRADLE_HOME
Variable Value C:\Program Files\Android\Android Studio\gradle\gradle-x.x\
*Do not forget to change and gradle versions.
Reopen the command prompt and confirm below command output :
1. gradle -v
2. android list target

Command Not Found when trying to use the "android" bash command?

I am trying to use the android command like this
:~ antonpug$ android list targets
But it doesn't work? I get "command not found". What am I doing wrong?
I installed the SDK. Using Mac OS X.
You need to add the android platform-tools and tools paths to your systems PATH variable. Modify your .profile or .bash_rc file to append the path to the directories in the root of your sdk folder.

Categories

Resources