-3

How can i compile and run android application using a batch file and not any other IDE? is it possible to do? and if it is possible, can you teach me how to make a batch file? I don't have any idea to it, I only know how to run id using eclipse ide. thank you.

duderbear
  • 101
  • 3
  • 16

1 Answers1

2

From android doc, i'll just add debug mode:

Debug mode

For immediate application testing and debugging, you can build your application in debug mode and immediately install it on an emulator. In debug mode, the build tools automatically sign your application with a debug key and optimize the package with zipalign.

To build in debug mode:

Open a command-line and navigate to the root of your project directory.

Use Ant to compile your project in debug mode: ant debug This creates your debug .apk file inside the project bin/ directory, named -debug.apk. The file is already signed with the debug key and has been aligned with zipalign. Each time you change a source file or resource, you must run Ant again in order to package up the latest version of the application.

To install and run your application on an emulator, see the following section about Running on the Emulator.

How to run

Before you can run your application on a device, you must perform some basic setup for your device:

Enable USB debugging on your device. On most devices running Android 3.2 or older, you can find the option under Settings > Applications > Development. On Android 4.0 and newer, it's in Settings > Developer options.

Note: On Android 4.2 and newer, Developer options is hidden by default.

To make it available, go to Settings > About phone and tap Build number seven times. Return to the previous screen to find Developer options.

Ensure that your development computer can detect your device when connected via USB Read Setting up a Device for Development for more information.

Once your device is set up and connected via USB, navigate to your SDK's platform-tools/ directory and install the .apk on the device:

adb -d install path/to/your/app.apk

The -d flag specifies that you want to use the attached device (in case you also have an emulator running).

A simple batch for debug mode could be:

set PROJECT_ROOT="Your_project_root"
set ADB_LOCATION="Your ADB Location"
set PROJECT_NAME="Your project name"
cd %PROJECT_ROOT%
ant debug
cd %ADB_LOCATION%
adb -d install %PROJECT_ROOT%/bin/%PROJECT_NAME%-debug.apk

Compile in release mode is a bit more longer, so i would say read the documentation.

Marco Acierno
  • 14,682
  • 8
  • 43
  • 53