"ant" is not recognized as command in Windows

This is my first time developing Android applications. I'm developing an Android app on Eclipse on Windows 7. I would like to run the Android app from the Windows 7 command line interface. I have my Android device connected to the PC.

The workspace directory that I use to store the Android project is

C:\Users\Guest\Desktop\Software Applications Development\Java\Android Moblie Applications Projects\Eclipse Indigo for Java EE x64-bit\project workspace

I opened the command line interface and I changed the working directory to the Android workspace directory.

cd C:\Users\Guest\Desktop\Software Applications Development\Java\Android Moblie Applications Projects\Eclipse Indigo for Java EE x64-bit\project workspace

I included Android sdk platform tools directory into the PATH environment variable.

c:\Users\admin\Android-sdks\platform-tools

Then I entered this into the Windows 7 command line interface:

ant debug

I have this error message on the cmd:

ant is not recognised as an internal or external command, operatable program or batch file.

What is the solution to this problem?

3

4 Answers

ant is not a part of standard Android SDK setup. You'll have to install it.

  • Download the latest ant zip file from The Apache Ant Project.
  • Extract the zip file to a folder, say c:\ant\
  • Add c:\ant to your path environment variable

Once these are done, you'll be able to run ant from the command line

6

To assist with the above. verify from your Java installation directory that You have tools.jar; if not go and download . after installation, you should see tools.jar in the lib subdirectory(i.e path_to_installation/java/jdkx.x.x/lib). After that; you need to add the path to this new installation with : variable_name: JAVA_HOME and variable_value= path_to_installation/java/jdkx.x.x

Ant should not give you the JDK error again. If you already have the tools.jar, then just add the JAVA_HOME to point to the directory as mentioned above "path_to_installation/java/jdkx.x.x"-this assumes that tools.jar is some where in the jdkx.x.x directory You may encounter issues with build.xml, check out this link:

Note: x.x.x represents the version Number of your installation

1

Navigate to the .android folder in your home directory ~/.android (Linux,Mac OS) or C:\Documents and Settings[User Name].android in Windows XP or C:\Users.android in Windows Vista or Windows 7, and delete the debug.keystore file. Then go to eclipse and clean the project, this will create a new debug.keystore file with default validity period 365 days.

For Linux user: Delete your debug certificate (debug.keystore and ddms.cfg) under ~/.android/debug.keystore

For Windows user: Delete your debug certificate (debug.keystore and ddms.cfg) under C:\Documents and Settings\Administrator.android

First, you have to download ANT. Here is the link .

Then extract your downloaded file in C:\Program Files\Ant Folder where Ant Folder is the folder name where I have extracted.

Now you have to set environment variables.
Right click on This PC > Properties > Advanced system settings > Environment Variables > User variables > New > Variable name:ANT_HOME & for Variable value:C:\Program Files\Ant Files\apache-ant-1.10.5 > OK.

Now goto System variables to add bin path.
System variables > double click on Path >New > C:\Program Files\Ant Files\apache-ant-1.10.5\bin > OK.

Now let's check whether it is installed correctly or not.
goto Command Prompt > and type ant -version.
That's it. Let me know if still getting any difficulties.

0

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like