Develop App on Android with Android SDK

I run Debian on Android. (armhf version)

First, install Oracle 7 JDK jdk-7u60-linux-arm-vfp-hflt.tar.gz into /opt/java/

1     sudo update-alternatives --install /usr/bin/java java /opt/java/jdk1.7.0_60/bin/java 2000
2 sudo update-alternatives --install /usr/bin/javac javac /opt/java/jdk1.7.0_60/bin/javac 2000

Second, download Android SDK tools android-sdk_r22.6.2-linux.tgz and unpack into /opt/java
Also, we need to install swt libs and link it to /opt/java/android-sdk-linux/tools/lib/arm/swt.jar.

1     sudo apt-get install libswt-gtk-3-java libswt-cairo-gtk-3-jni
2 cd /opt/java/android-sdk-linux/tools/lib
3 mkdir arm
4 cd arm
5 ln -s /usr/lib/java/swt-gtk-3.8.2.jar swt.jar

Now, one can launch the android tool /opt/java/android-sdk-linux/tools/android to download the Android SDK.

Because the Android SDK does not support ARM, so most of the tools will not run. (They are not ARM binaries)

I have compiled a few essential SDK tools so as to make it possible to build apk on ARM. See Building Android SDK build tools: aapt for Debian Arm

Use git clone

The compiled tools: aapt, aidl, zipalign are in the folder android-build-tools-for-arm/out/host/linux-arm/bin

I copy the tools to /opt/bin , then remove the original binaries from the SDK and replace them with the ones in /opt/bin :

1     cd /opt/java/android-sdk-linux/tools
2 rm zipalign
3 ln -s /opt/bin/zipalign zipalign
4 cd /opt/java/android-sdk-linux/build-tools/19.0.3
5 rm aapt
6 ln -s /opt/bin/aapt aapt
7 rm aidl
8 ln -s /opt/bin/aidl aidl

The Android SDK is usable now.

As an example, to build systemtrigger with ant:

1     git clone
2 cd systemtrigger
3 echo "sdk.dir=/opt/java/android-sdk-linux" >
4 ant debug

ant debug will produce bin/systemtrigger-debug.apk

ant release will produce bin/systemtrigger-release.apk

Optionally, to install the apk on the device using adb, you need first to restart adbd in TCP mode. Refer to Using the adb on the Android device

adb install bin/systemtrigger-release.apk

If you had used the Java IDE IntelliJ IDEA before and like it, it works with the above Android SDK.

With systemtrigger as an example, you can import project (existing source), and build the module systemtrigger. By default, if the build is successful, it will produce out/production/systemtrigger/systemtrigger.apk


blog comments powered by Disqus