Trac is being migrated to new services! Issues can be found in our new YouTrack instance and WIKI pages can be found on our website.

Compiling libpurple on Android

There are build scripts in the repository that build the libraries on which libpurple depends automatically. But you need to set up your host programms, mainly Eclipse and the Android SDK/NDK.

Follow these steps to set up a new Development platform. I recommend that even if you already have Eclipse or the SDK/NDK installed, you should download everything and start from scratch.

I gess you will need about one hour to set up your IDE, and afterwards another hour for the automated build.

Install required developer tools

Make sure you have the following things installed (the list may or may not be complete ;-)): a current JDK, patch, autoconf, pkg-config, gtk-doc-tools, GNU make and xzip

get the source

Open the file ~/.hgrc and add the subrepository mapping:

[subpaths]
(ssh|http)://hg.pidgin.im/soc/2012/michael/manuk/jpurple-dependencies/build/pidgin = \1://hg.pidgin.im/soc/2012/michael/android/

Then, create a new, empty working directory where you want your workspace to be. Clone the manuk-Repository there:

hg clone http://hg.pidgin.im/soc/2012/michael/manuk/ .

This repository contains the java projects required to build the Android application and also contains the repository containing libpurple as subrepo.

Eclipse

You need Eclipse IDE with C and Java Support. For this, I recommend you download Eclipse Classic or Eclipse IDE for Java developers. Files can be found at http://www.eclipse.org/downloads/. Eclipse does not need an installation, just extract the archive somewhere.

Start it:
The executeable is in the Eclipse directory you just downloaded. It will prompt you for a workspace. You can choose the directory you cloned the repository to, or any other directory you like. The workspace appears to be empty because eclipse does not know that there are already projects in it.

Install C:
Go to Help → Install new Software. Select the update site for your Eclipse version. Then install "Programming languages" → "C/C++ Development tools"

Install Ant contrib
Download ant-contrib, extract the archive somewhere. Go to Window → preferences → Ant → Runtime. In the Classpath tab, select Global Entries from the list and click on "Add external JARs". Select the ant-contrib-*.jar you just downloaded.

Set ant contrib properties
In the same dialog (Window → preferences → Ant → Runtime), you go to the Properties tab. Add a property named "ndk.root" which has the value "${ndk.root}", and one named "ndk.host" with the value "${ndk.host}"

Add the projects:
To tell Eclipse that the projects exist, add them to Eclipse: File → Import... → Existing projects into Workspace. Select the repository root directory as root directory and then all projects Eclipse automatically finds. There may be errors in the projects, because you first need to install the Android plugin.

Android Tools

Download

Download Android SDK + extract (recommended: r18) http://developer.android.com/sdk/index.html

Download Android NDK + extract (recommended: r8) http://developer.android.com/sdk/ndk/index.html

Install Eclipse plugin

If you encounter problems here, this page covers the issue with more details: http://developer.android.com/sdk/eclipse-adt.html#installing

In Eclipse, Go to Help → Install new Software.
Select the Android update site: https://dl-ssl.google.com/android/eclipse/
Select everything
Click on "next", "next", "accept", "finish"
Restart Eclipse when the plugin is installed.

Configure Android SDK

Click on Window → Preferences, Select Android from the left panel. Enter the directory where you downloaded the SDK. Apply.

Open the SDK Manager (if Eclipse has not prompted you to do it: Window → Android SDK Manager). Select "Tools" and "Android 2.3.3 (API 10)" and install. Android should have created an AVD for you.

Configure Android NDK

Create a custom toolchain: Execute the following command in the ndk directory. Remember the install directory.

build/tools/make-standalone-toolchain.sh --platform=android-9 --install-dir=<some-new-dir>

Enter the root directory of that toolchain (not the sysroot directory) in Eclipse in Preferences → String Substitution as ndk.root and add a new substitution "ndk.host" with the value arm-linux-androideabi

Currently, only arm is supported.

Build it

Disable Project → Build automatically. Then go to Project → Clean Projects... and clean all projects.

Select the im.pidgin.libpurple.build project and click on Project → Build Project. This will take a while.

Then select the testclient and click on Project → Build Project. This will also build the jni bindings.

You can now re-enable auto builds, they work in both im.pidgin.libpurple and im.pidgin.libpurple.testclient.

You are done.

If you want to build a single library again, right-click on the library and click Run As → Ant Script.

Build order

The following build order is used by Eclipse:

  • libiconv
  • libffi
  • gettext
  • libxml2
  • d-bus
  • glib
  • libpurple

Explore the Workspace

There is an extra page on the project structure of the android projects.

Problems

glib-compile-resources not found

Update glib on your host.

Problems with undefined pthread types, e.g. pthread_rwlock_t

Use the android-9 toolchain or newer.

Headers/Files? generated by build scripts are not marked as derived.

This is not possible in Eclipse. See Eclipse bug 150578 and 30440

Build failed with "bad substitution" / Build uses normal gcc instead of the Android one.

Be sure to have ndk.root and ndk.host set to the right values.

Last modified 11 years ago Last modified on Jun 25, 2013, 6:06:28 PM
All information, including names and email addresses, entered onto this website or sent to mailing lists affiliated with this website will be public. Do not post confidential information, especially passwords!