Sunday, March 29, 2015

Using ant to build Android sample code

It used to be so easy to build Android's code, now with Android Studio and gradle it become so complicated.

Let me put it down how to use ant to build before Google swipe everything away.  and this is the only way to build their sample code now since many sample codes are not migrated to Android Studio and gradle/gradlew yet.

  • go to sample code root directory.  android-21 is the target API, the command will generate build.xml for build process
    $ android update project --target android-21 --path .
  • build the debug apk
    $ ant debug
  • use find . -name *.apk to locate the apk file.  use adb to install apk to your phone
    $ adb install ./bin/NewsReaderActivity-debug.apk

Summary:
  1. $ android update project --target android-21 --path .
  2. $ ant debug
  3. $ adb install ./bin/NewsReaderActivity-debug.apk
Simple as that!