Compiling aSmack
gga
#2013-05-14
For a recent mobile project we used XMPP. It worked really well and I’m keen to use it again. But, in the process I learnt quite a lot about it. To start with, getting a working Android client was… interesting.
Android is a fascinating and interesting development environment. It may say Java on the tin, but it ain’t Java inside. And due to this, the otherwise great XMPP library Smack doesn’t work on Android. Instead you have to use the aSmack library. Which is actually a collection of patches and a build script. Compiled output is not to be found on the Internet. Additionally, the build script doesn’t work on Mac OS X. I built it on an Ubuntu Vagrant box. Here’s how.
- Install Vagrant and VirtualBox.
mkdir asmack && cd asmack
vagrant box add lucid32 http://files.vagrantup.com/lucid32.box
vagrant init lucid32
vagrant ssh
sudo apt-get update
sudo apt-get install git-core openjdk-6-jdk curl vim subversion ant advancecomp
curl -O http://dl.google.com/android/android-sdk_r21.1-linux.tgz
tar -xzvf android-sdk_r21.1-linux.tgz
cd android-sdk-linux/
tools/android update sdk --no-ui
cd ..
git clone https://github.com/Flowdalic/asmack.git
cd asmack/
echo "sdk-location=/home/vagrant/android-sdk-linux" > local.properties
- Edit
build.xml
. Remove thecheck-android-exists
dependency from thecompile-android
target. ./build.bash
cp build/asmack-android-17.jar /vagrant
exit
And you will now have asmack-android-17.jar
sitting in your current
directory.