« Previous -
Version 5/7
(diff) -
Next » -
Current version
Jos van den Oever, 06/11/2012 11:00 am
Building WebODF for Android¶
WebODF comes with a version for Android. It supports Android from version 1.6 and up. The application is a viewer for ODF files.
Building WebODF for Android is very easy. To create WebODF.apk, a few tools are needed:
- Git is a needed to obtain the development version of WebODF. http://git-scm.com/
- Android SDK Download android-sdk_r11-windows.zip, android-sdk_r11-mac_x86.zip or android-sdk_r11-linux_x86.tgz from http://developer.android.com/sdk/.
- ant is the build system that is used for building WebODF.apk. http://ant.apache.org/
- JDK or Java Development Kit contains the java compiler and tools for signing the apk file: keytool and jarsigner.
Obtain the code¶
Check out WebODF from gitorious:
git clone git://gitorious.org/odfkit/webodf.git
Build the debug version¶
Run with ant. The directory in which the required jar files are placed is defined as sdk.dir. Three jar files should be placed relative to that directory: tools/lib/anttasks.jar, tools/lib/sdklib.jar, tools/lib/androidprefs.jar.
cd webodf/programs/android ant -Dsdk.dir=/home/user/android/android-sdk-linux_x86 debug
This will create an apk file at bin/WebODF-debug.apk which can be copied onto a device or emulator and installed via the UI on the device.
Install to the device¶
The command for directly installing to the device is very similar. For this command to work you need to have a default emulator or device configured. If an android device is connected and has is in development mode, ant will install to that device. If you do not have an android device in development mode attached, you can configure an emulated by running tools/android.
cd webodf/programs/android ant -Dsdk.dir=/home/user/android/android-sdk-linux_x86 debug
Build a signed version for release¶
To release a version, the apk file has to be signed. More information about signing can be gotten from the Android website: http://developer.android.com/guide/publishing/app-signing.html.
First create a key with keytool:
keytool -genkey -validity 10000 -keyalg RSA -keysize 2048 \ -dname "CN=Jos van den Oever, OU=WebODF, O=KO GmbH, L=Magdeburg, ST=Sachsen-Anhalt" \ -keypass webodf -keystore KO.keystore -storepass webodf \ -alias KO
Sign the apk file:
jarsigner -digestalg SHA1 -sigalg MD5withRSA -verbose -keystore KO.keystore -storepass webodf -signedjar \ bin/WebODF-unaligned.apk bin/WebODF-unsigned.apk KO
And align the files inside the document for faster performance:
$sdkdir/tools/zipalign -v 4 bin/WebODF-unaligned.apk bin/WebODF.apk
Now you can install WebODF by transferring WebODF.apk to the device and installing via the UI or by issuing this command:
$sdkdir/platform-tools/adb install bin/WebODF.apk
The application can be uninstalled with
$sdkdir/platform-tools/adb uninstall org.webodf
Make sure to always test the final signed and aligned apk on a device, because the Google Play store does not verify the validity of the signature.