] by
chw
2016-09-30 08:14:41.
D 2016-09-30T08:14:41.623
L Build\scustom\sAndrowish
P 409ee4fc3fc878107f16ba9d1d6dabb36b31040e
U chw
W 14486
<h2>Starting point</h2>
Starting point is the description by Christian at [http://www.androwish.org/index.html/wiki?name=Building+AndroWish] and the following quote from wiki page [http://wiki.tcl.tk/41282|Androwish]:
<hr/>
Please fetch the sources (the big .tar.bz2), unpack it, have Android SDK and NDK installed, don't use Eclipse, adapt local.properties to where you've installed Android SDK, have your PATH properly set so that ndk-build can do its job, then invoke "ant debug", be patient, and you'll finally will have bin/AndroWish-debug.apk ready to be installed onto your device. I have never verified the build process in combination with Eclipse. Once upon a time, I did my very first steps using the tips from the SDL documentation regarding Android.
When you want to wrap your own app written as Tcl code, you should add it below assets/app, have the launching script as main.tcl, fiddle the toplevel AndroidManifest.xml to have your app/class name in, remove that AndroWishScript/Launcher stuff from the manifest (since not needed for a standalone app), derive your app main class (yes, some Java required) from src/tk/tcl/wish/AndroWish.java, e.g.
<verbatim>
import tk.tcl.wish.AndroWish;
public class TclTkRules extends AndroWish {}
</verbatim>
fiddle the res directory with a new really kooool icon and title for your app.
<hr/>
<h2>Build Androwish</h2>
<h3>Get Source</h3>
A release source is on the web site.
If an intermediate version should be used, one may clone the fossil repository and check out the latest checkin on trunk:
<verbatim>
fossil clone http://anonymous:F4DC0163@www.androwish.org androwish.fossil
mkdir androwish
cd androwish
fossil open ../androwish.fossil
rm .fslckout
</verbatim>
<h3>Try on Windows</h3>
Windows build stopped with ndk-build with a "command line to long" error.
I tried cmd.exe and cygwin shell, same result.
This should be fixed since check-in [52a07071b99fa88a] and was verified on Windows 8.1 32 bit using Android NDK r12b and Android SDK 24.4.1.
<h3>Try on OSX</h3>
NDK: I downloaded android-ndk-r10e-darwin-x86_64.bin - then chmod +x, execute it, and move extracted files to /usr/local/android-ndk
Added this to ~/.bash_profile:
<verbatim>export NDK_PROJECT_PATH=/usr/local/android-ndk
export ANDROID_HOME=~/Library/Android/sdk
export PATH=${PATH}:~/android-sdk-mac/tools:/usr/local/android-ndk
</verbatim>
edited "project.properties" to update the android target number.
<verbatim># Project target.
target=android-21</verbatim>
To build:
<verbatim>cd ~/Documents/androwish
export NDK_PROJECT_PATH=`pwd`
ant debug
</verbatim>
"ant debug" runs for about 30 minutes, and ends with
<verbatim>BUILD SUCCESSFUL</verbatim>
<h3>Try on CentOS 6</h3>
Failed for me due to a to old clib.
Christian: remarked that he is using CentOS 6 or Ubuntu 12.04 LTS with Andriod NDK 9d.
So this failure might be due to the fact, that I tried Android NDK 10d.
<h3>OpenSuSE 13.2 64 bit</h3>
I installed VirtualBox on my Windows 8.1 and OpenSuSE 13.2 64 bit with 100GB HarDisk and 4GB Ram.
* Added series: java development
* Added packages: java-1_7_0-openjdk-devel, xerces-j2-xml-apis
Activate Java 7 (e.g. 1.7):
<verbatim>
update-alternatives --config java
-> 1.7
update-alternatives --config javac
-> 1.7
update-alternatives --config xml-commons-apis
-> xerces-j2-xml-apis.jar
</verbatim>
Set up Android build system:
<verbatim>
cd ~
mkdir android
cd android
mkdir download
</verbatim>
Downloaded in ~/android/download:
* android-sdk_r24.1.2-linux.tgz
* android-ndk-r9d-linux-x86_64.tar.gz
* androwish-e2aee3ea2ea718e7.tar.gz (Pi Day Release, also tested with following Don Quixote Release)
Christian: suggested to use the 9d release of the ndk instead of the current 10d due to the following reasons:
* still supports Android 2.3.3, like AndroWish
* tiff library does not compile with 10d
The download link is:
* Linux 64 bit: [https://dl.google.com/android/ndk/android-ndk-r9d-linux-x86_64.tar.bz2]
* Linux 32 bit: [https://dl.google.com/android/ndk/android-ndk-r9d-linux-x86.tar.bz2]
Unpack and install, androwish in folder "androwish" for easier access
<verbatim>
cd ~/android
tar xvzf download/android-sdk_r24.1.2-linux.tgz
bzip2 -d download/android-ndk-r9d-linux-x86_64.tar.bz2
tar xvf download/android-ndk-r9d-linux-x86_64.tar
tar xvf download/androwish-e2aee3ea2ea718e7.tar.gz
mv androwish-e2aee3ea2ea718e7 androwish
</verbatim>
(start side note)
<hr/>
<h4>ndk 10d install instructions (if 9d is not used as above)</h4>
<verbatim>
cd ~/android
chmod +x download/android-ndk-r10d-linux-x86_64.bin
download/android-ndk-r10d-linux-x86_64.bin
</verbatim>
<hr/>
(end side note)
Open Android SDK manager:
<verbatim>
~/android/android-sdk-linux/tools/android sdk
-> Select Google APIs ARM EABI v7a System Image
-> Unselect all other system images
</verbatim>
Prepare build and let "android" create "local.properties":
<verbatim>
export PATH=$PATH:~/android/android-sdk-linux/tools:~/android/android-ndk-r9d
cd androwish
android update project -p . --target 1
</verbatim>
(the export command may be copied to ~/.bashrc to be active for each shell start)
(start of side note)
<hr/>
<h4> Error with ndk 10d and not with 9d (e.g. only when 10d is used)</h4>
On "ant debug", I had the following build error I could not solve:
<verbatim>
[exec] [armeabi] Compile thumb : tiff_tkimg <= tif_predict.c
[exec] /tmp/ccTUdnr3.s: Assembler messages:
[exec] /tmp/ccTUdnr3.s: Error: unaligned opcodes detected in executable segment
[exec] make: [obj/local/armeabi/objs/tiff_tkimg/libtiff/tif_predict.o] Error 1
</verbatim>
This is in jni/tiff.
So I deleted the tkimg and jni/tiff folders:
<verbatim>
rm -rf jni/tkimg jni/tiff
</verbatim>
The build error most likely is caused by a compiler problem. This issue is fixed in an [AndroWish] check-in on 2015-06-30 by compiling libtiff to ARM instead of Thumb code. The x86 version of the compiler does not cause build errors.
<hr/>
(end side note)
Now, an "ant debug" succeeds for me.
The result is in "androwish/bin/AndroWish-debug.apk
Great, thank you, Cristian !
<h2>Customizing Androwish</h2>
This is a customisation for the application called "HIBIScan" for the company url "elmicron.de".
You should replace those names by your own ones.
<h3>Delete not required packages</h3>
It is perhaps me, but I always try to get small packages with as less as possible included.
So I deleted packages I know and I don't need in this project:
<verbatim>
cd jni
rm -rf 3dcanvas blt curl expect itk jpeg libxml2 nsf TclCurl tclral tcludp tclx tclxml\
tdom tiff Tix tkimg tktable tktreectrl vu xotcl zint
cd jni/tcl-pkgs
rm -rf tdbcmysql1.0.3 tdbcsqlite3-1.0.3 itcl4.0.3 sqlite3.8.8.3 tdbcodbc1.0.3\
thread2.7.2 tdbc1.0.3 tdbcpostgres1.0.3
cd androwish
rm -rf tkchat
cd assets
rm -rf bin blt2.4 bwidget1.9.7 Canvas3d1.2.1 expect5.45.2 gridplus2.10 icons1.2 itcl4.0.3\
itk4.0.1 iwidgets4.1 nsf2.0.0 pdf4tcl08 ral0.11.2 ralutil0.11.2 sqlite3 TclCurl7.22.0\
tcllib1.16 tclsoap1.6.8 tclws2.3.8 tclx8.4.1 Tclxml3.2 tdbc1.0.3 tdbcsqlite3-1.0.3 tdom0.8\
thread2.7.2 tkimg1.4.3, tklib0.6, tksqlite0.5.11, tktable2.11 treectrl2.4.1 vu2.3
</verbatim>
This results in an androwish size of 17MB, so 6 MB less than the full package.
<h3>Remove target x86</h3>
For most Android phones, the target armeabi is sufficient.
So the target x86 might be deleted:
Remove "x86" in file jni/Application.mk to get:
<verbatim>
APP_ABI := armeabi
</verbatim>
This results in a final apk size of 10MB.
My phone says that it takes 19.7 MB, while AndroWish takes 39.3MB.
<h3>Include own script</h3>
Now, the script tree of the application is copied to assets/app and a main.tcl is there to be started:
<verbatim>
cd assets
mkdir app
cd app
cp <somewhere>/main.tcl .
cp -r <somewhere>/* .
</verbatim>
An "ant debug" results in a starkit-like apk file.
<h3>Remove permissions not required for the app</h3>
In "./AndroidManifest.xml", you may delete any permission, but:
<verbatim>
<uses-permission android:name="android.permission.INTERNET" />
</verbatim>
Application will directly terminate if not present.
<h3>Change package name</h3>
In "./AndroidManifest.xml", you should change the package name to be different to androwish.
Otherwise, the applications may not be installed together.
In "./AndroidManifest.xml"
<verbatim>
package="de.elmicron.hibiscan"
</verbatim>
where "de.elmicron.hibiscan" is my internet domain and the application name as last component.
This should be adopted on request.
Add into "src/tk/tcl/wish/AndroWish.java" at the end of the include list:
<verbatim>
import de.elmicron.hibiscan.R;
</verbatim>
to avoid error:
<verbatim>none
[javac] /home/oehhar/android/androwish-hibiscan/src/tk/tcl/wish/AndroWish.java:1519: error: package R does not exist
[javac] R.drawable.wish);
</verbatim>
This error only happens after an
<verbatim>
ant clean
</verbatim>
Otherwise, the old class definition of "tk.tcl.wish.R" is still present in the gen source tree.
Add a derived class in "src/de/elmicron/hibiscan/HIBIScan.java".
The file path is composed of "src" and the package name, dots replaced by "/".
The file name is the class name, where I used the application name.
File contents:
<verbatim>
package de.elmicron.hibiscan;
import tk.tcl.wish.*;
public class HIBIScan extends AndroWish { }
</verbatim>
(Christian: by private email) Then, each usage in "<activity...>" of "tk.tcl.wish.AndroWish" in "AndroidManifest.xml" should be replaced by "de.elmicron.hibiscan.HibiScan".
Here, this is done in the next step.
<hr/>
Remark: the usage of a derived class did not make any difference to me.
I could stay with the class "tk.tcl.wish.AndroWish".
Nevertheless, Christian: recommends it.
Comments welcome...
<h3>Start script directly</h3>
Loose translation of E-Mail from Christian::
<hr/>
The file "AndroidManifest.xml" for own applications should bette be structured similar to ".../hellotcltk/AndroidManifest.xml".
The own application should not be started by the activity "AndroWishLauncher", but better directly, using the remaining intent filter:
<verbatim>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</verbatim>
<hr/>
So, within the "AndroidManifest.xml" file, there are the following changes:
* Use only one activity with the new class and the proposed intent-filter.
* I changed the product version and class to 6.0 and numeric 600, as this is the port of an existing program, which has version number 6.
and the following changes already in other sections:
* Use package name "de.elmicron.hibiscan"
* Use class "de.elmicron.hibiscan.HIBIScan" instead "tk.tcl.wish.AndroWish"
* Only minimal permissions
The resulting file looks like that:
<verbatim>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.elmicron.hibiscan"
android:installLocation="auto"
android:versionCode="600"
android:versionName="6.0">
<application android:label="@string/app_name"
android:icon="@drawable/androwish"
android:allowBackup="true"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:hardwareAccelerated="true">
<activity android:name="de.elmicron.hibiscan.HIBIScan"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|mnc|mcc|locale|fontScale|uiMode"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<!-- Android 2.3.3 -->
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="14" />
<!-- OpenGL ES 2.0 -->
<uses-feature android:glEsVersion="0x00020000" />
<!-- USB support -->
<uses-feature android:name="android.hardware.usb.host" />
<!-- Disable screen compatibility modes -->
<supports-screens android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true" />
<!-- Allow writing to external storage etc. -->
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
</verbatim>
<h3>Resources</h3>
Change the AppName in res/values/strings.xml
Change the Androwish icons in res/drawable-*/androwish.png
(Resolutions: 72x72, 48x48, 96x96, 144x144).
<h3>Remove fonts</h3>
Christian: suggestion via E-Mail:
2 additional MB's may be economized by not including the font folder ".../jni/sdl2tk/library/fonts" as follows:
<verbatim>
cd jni/sdl2tk
mv library/fonts .
</verbatim>
In this case, the buildin Droid* fonts are used as fallback which are included in Android firmware.
They don't look so much less attractive...
This results in a package file size of 7.8MB
On Android 5, this requires Don Quixote release (2015-04) of Androwish to run.
Otherwise, Androwish does not start on Android 5.
<h3>Release signing</h3>
Create a release key by (replace "elmicron" by your own name):
<verbatim>
cd ~/android
keytool -genkey -v -keystore android_elmicron.keystore -alias android_elmicron -keyalg RSA -keysize 2048 -validity 10000
</verbatim>
You get promted to a keystore password and the key values.
I only filled common name and Organisation.
Then you get prompted to a key password.
This generates the file "~/android/android_elmicron.keystore".
Then add those lines to "~/android/androwish/ant.properties":
<verbatim>
key.store=../android_elmicron.keystore
key.alias=android_elmicron
key.store.password=<mypw1>
key.alias.password=<mypw2>
</verbatim>
and do
<verbatim>
ant release
</verbatim>
The final apk is in "bin/AndroWish-release.apk".
<hr/>
2015-06-04 Harald Oehlmann
Z f70e2f3b15a4b84e37b0c052edfd0867