Compile and execute project via command line

6

I have an Android application developed in Eclipse. I know I can compile and run a project from the console , however I do not know how to do this.

The basic steps for compiling a program JAVA is to save with the same class name followed by .java and execute the following command:

#javac HelloWordConsole.java

But I want to run this process to create .apk and install it directly to the device via USB. How can I do this using Windows CMD for both the Eclipse IDE and Android Studio?

    
asked by anonymous 16.09.2016 / 21:27

2 answers

3

Android applications use Gradle for compile automation. So to compile the code just run the command in the folder where you have the file build.gradle .

To compile a debug APK, open the CMD and navigate to the root of the project directory - in Android Studio, select% with%. To start a debug build, call the task View > Tool Windows > Terminal :

gradle.bat assembleDebug

The command in MacOS and Linix is:

$ chmod +x gradle
$ ./gradle assembleDebug

PS: It is necessary to have the gradle installed.

Reference: link

    
01.11.2016 / 21:20
1

Android uses the Ant building system. So you can create a build.xml and build.properties file for your project.

You will need to create the build.xml file first however:

android update project -p.

This will generate a build.xml file.

You should probably customize the building steps and goals for your project. A good idea in your case would be to have the build.properties file generated by your IDE for the particular build. Then include it through the build.xml file.

In particular, you need to specify in the build.properties file, where the signature keys are, and the password is:

Build.Properties:

key.store=keystore.dat
key.alias=signing_key
key.store.password=password123
key.alias.password=password123

The build using ant process also allows you to do variable overrides in Java files, which may be another idea. It would allow you to customize the build process still on a client by client basis.

By default, compilation is driven by:

ant clean
ant release
    
16.09.2016 / 21:38