Build Android Application without Eclipse
Posted on Sunday November 09, 2014 by Eric Potvin
Eclipse can be useful to build Android apps, specially the layout. So do not remove it yet.
I still prefer using VIM for development and if you like running everything in command line, this article is for you.
Download sample app
you can get our default android app (or what we can call a start app) on our gituhb account.
Create the build.xml
In order to use the command line compiler, you need to update the current project by adding the
First, let's find out which target we have:
android list targets
To create the build.xml, simply run this command:
cd ~/path-of-my-android-project/ android update project --target 1 --path ./
This will create the following output:
Updated project.properties Updated local.properties No project name specified, using Activity name 'MainActivity'. If you wish to change it, edit the first line of build.xml. Added file ./build.xml Updated file ./proguard-project.txt
Time to code!
Now that the build.xml is created, you can compile it.
Build the project
In order to build the project, you will need to use
ant. This tool allow you to compile your project and create the
.apk you need.
ant clean ; ant debug
This will output a lot of stuff. The most important thing is the last 2 lines. You should see something like this:
// ... debug: BUILD SUCCESSFUL Total time: 3 seconds
This creates the
bin/MainActivity-debug.apk. This is the application!
Run the application in the emulator
To run the emulator, you can simply run:
@MyAndroid will be the name of your android emulator. To see the list you can run: android avd
You can also use different configuration without alter or creating multiple instance of your emulator.
emulator @MyAndroid -force-32bit -partition-size 1024 -no-audio -no-boot-anim -no-boot-anim -qemu -icount auto -cpu-delay 0
emulator @MyAndroid -no-boot-anim -qemu -icount auto -cpu-delay 0
emulator @MyAndroid -wipe-data
Install/Uninstall the App
Now let's install the app. From the root of your application folder.
Install the app
To install the app, simply run:
adb install bin/MainActivity-debug.apk
This should output:
1162 KB/s (44504 bytes in 0.037s) pkg: /data/local/tmp/MainActivity-debug.apk Success
Now you can open the application in emulator.
Uninstall the app
adb shell pm uninstall -k com.bookofzeus.app
This should output:
Debugging your app
Unless you are the absolute grand Jedi in Android Development, you will have errors at some point. The
is there to hlep you figure out what is wrong with your app if your application suddenly stopped or if something just does not work.
To see the log, simply run this command: