Hi all.
I followed the instructions in
http://wiki.lazarus.freepascal.org/Android_tutorial and, after a few try-and-correct work, finally I got my apk. Installed in the emulator, launched the app. The (emulator) screen goes blank, stays blank, and only after "touching" screen and/or "back button" the app crashes.
Using ADB LOGCAT I see:
I/ActivityManager( 58): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.pascal.lcltest/.LCLActivity }
I/ActivityManager( 58): Start proc com.pascal.lcltest for activity com.pascal.lcltest/.LCLActivity: pid=240 uid=10036 gids={3003, 1015}
I/ARMAssembler( 58): generated scanline__00000077:03545404_00000004_00000000 [ 47 ipp] (67 ins) at [0x2a12a8:0x2a13b4] in 390838 ns
I/lclapp ( 240): Trying to load liblclapp.so
D/dalvikvm( 240): Trying to load lib /data/data/com.pascal.lcltest/lib/liblclapp.so 0x4a20c248
W/ActivityManager( 58): Launch timeout has expired, giving up wake lock!
W/ActivityManager( 58): Activity idle timeout for HistoryRecord{4a1d8d28 com.pascal.lcltest/.LCLActivity}
From that log, it seems that the generated liblclapp.so has something wrong.
From
http://forum.lazarus.freepascal.org/index.php?topic=21314.0 I downloaded a ready-made APK which works. ADB LOGCAT shows:
I/ActivityManager( 58): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.pascal.lcltest/.LCLActivity }
I/ActivityManager( 58): Start proc com.pascal.lcltest for activity com.pascal.lcltest/.LCLActivity: pid=312 uid=10036 gids={3003,1015}
I/lclapp ( 312): Trying to load liblclapp.so
D/dalvikvm( 312): Trying to load lib /data/data/com.pascal.lcltest/lib/liblclapp.so 0x4a20c248
D/dalvikvm( 312): Added shared lib /data/data/com.pascal.lcltest/lib/liblclapp.so 0x4a20c248
I/lclapp ( 312): JNI_OnLoad called
I/lclapp ( 312): Reading our Activity Class
I/lclapp ( 312): JNI_OnLoad finished
I/lclapp ( 312): LCLOnCreate called by LCLActivity.onCreate
I/lclapp ( 312): [TCDWidgetSet.CreateTimer] Result=44074840
I see the difference in the log, after "trying to load ... liblclapp.so" there is "added shared lib ...".
I tried to rebuild liblclapp several times, changing options, changing toolchain and so on, but the result is always the same: the output is formally correct, but the shared object doesn't load - and no errors are generated.
So I analyzed the two objects, the working one and the self-built one. Apart from the difference in size, 4Mib for the working one and about 2Mib for the wrong one, I noticed another difference: the symbols of the libraries are quite different. The working one:
arm-androideabi-gcc-nm.exe -aD liblclapp-working.so
00473120 d .data
000e059c t .text
U __android_log_write
U __cxa_atexit
U __cxa_finalize
U AndroidBitmap_lockPixels
U AndroidBitmap_unlockPixels
U environ
U exit
000e061c T JNI_OnLoad
000e0620 T JNI_OnUnload
The non-working library instead:
arm-androideabi-gcc-nm.exe -aD liblclapp-nonworking.so
0026c148 d .data
00074e30 t .text
U __android_log_write
U __cxa_atexit
U __cxa_finalize
U AndroidBitmap_lockPixels
U AndroidBitmap_unlockPixels
U dlclose <- is it extraneous?
U dlopen <- is it extraneous?
U dlsym <- is it extraneous?
U environ
U exit
00074ed4 T JNI_OnLoad
00074ed8 T JNI_OnUnload
The difference in unresolved symbols may have no meaning, but I find it strange that dlXXX symbols are there, while in the .ppu files they are not.
Can somebody help me in addressing my problem? After trying this tutorial, I also tried "laz2apk": I removed all from the disk, and launched laz2apk. Again some problem (it didn't download laz4android), but finally I managed to make it work. Again, exactly the same thing: result formally correct, but ADB LOGCAT shows that the shared object has something wrong, but no errors.
Thanks in advance for your help.