Building WebODF for Android
Version 5 (Jos van den Oever, 06/11/2012 11:00 am) → Version 6/7 (Jos van den Oever, 06/11/2012 11:04 am)
h1. 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_.
h2. Obtain the code
Check out WebODF from gitorious:
<pre>
git clone git://gitorious.org/odfkit/webodf.git
</pre>
h2. 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_.
<pre>
cd webodf/programs/android
ant -Dsdk.dir=/home/user/android/android-sdk-linux_x86 debug
</pre>
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.
h2. 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_.
<pre>
cd webodf/programs/android
ant -Dsdk.dir=/home/user/android/android-sdk-linux_x86 debug
</pre>
h2. 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:
<pre>
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
</pre>
Sign the apk file:
<pre>
jarsigner -digestalg SHA1 -sigalg MD5withRSA -verbose -keystore KO.keystore -storepass webodf -signedjar \
bin/WebODF-unaligned.apk bin/WebODF-unsigned.apk KO
</pre>
And align the files inside the document for faster performance:
<pre>
$sdkdir/tools/zipalign -v 4 bin/WebODF-unaligned.apk bin/WebODF.apk
</pre>
Now you can install WebODF by transferring _WebODF.apk_ to the device and installing via the UI or by issuing this command:
<pre>
$sdkdir/platform-tools/adb install bin/WebODF.apk
</pre>
The application can be uninstalled with
<pre>
$sdkdir/platform-tools/adb uninstall org.webodf
</pre>
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.
Alternatively, one can use ant to create a signed and aligned apk. This can be done with a file ant.properties:
<pre>key.store=/path/to/KO.keystore
key.alias=KO
key.store.password=webodf
key.alias.password=webodf</pre>
next to build.xml and then running 'ant release'.
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_.
h2. Obtain the code
Check out WebODF from gitorious:
<pre>
git clone git://gitorious.org/odfkit/webodf.git
</pre>
h2. 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_.
<pre>
cd webodf/programs/android
ant -Dsdk.dir=/home/user/android/android-sdk-linux_x86 debug
</pre>
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.
h2. 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_.
<pre>
cd webodf/programs/android
ant -Dsdk.dir=/home/user/android/android-sdk-linux_x86 debug
</pre>
h2. 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:
<pre>
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
</pre>
Sign the apk file:
<pre>
jarsigner -digestalg SHA1 -sigalg MD5withRSA -verbose -keystore KO.keystore -storepass webodf -signedjar \
bin/WebODF-unaligned.apk bin/WebODF-unsigned.apk KO
</pre>
And align the files inside the document for faster performance:
<pre>
$sdkdir/tools/zipalign -v 4 bin/WebODF-unaligned.apk bin/WebODF.apk
</pre>
Now you can install WebODF by transferring _WebODF.apk_ to the device and installing via the UI or by issuing this command:
<pre>
$sdkdir/platform-tools/adb install bin/WebODF.apk
</pre>
The application can be uninstalled with
<pre>
$sdkdir/platform-tools/adb uninstall org.webodf
</pre>
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.
Alternatively, one can use ant to create a signed and aligned apk. This can be done with a file ant.properties:
<pre>key.store=/path/to/KO.keystore
key.alias=KO
key.store.password=webodf
key.alias.password=webodf</pre>
next to build.xml and then running 'ant release'.