Welcome, Guest
Username: Password: Remember me
CodeTyphon Cross-Build Development, discussions and problems
  • Page:
  • 1
  • 2

TOPIC:

App launches and then dies the moment you click 10 years 4 months ago #4631

  • trustfm
  • trustfm's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 9
  • Thank you received: 2
Hello .
I am currently using the following configuration
CodeTyphon 4.5
with
installer_r22.0.5-windows (sdk)
and the
android-ndk-r7c-windows version

I compile correctly the "androidlcl" demo . I can also generate the apk package but when i launch it on the virtual device
whenever i click on a control like a Tbutton the app crashes.

I have read the www.pilotlogic.com/sitejoom/index.php/93...ss-build-for-android
tutorial.

The hole "androidlcl" project can be found here :
dl.dropboxusercontent.com/u/28434419/androidlcl.zip


The logcat is here :
pastebin.com/An984GvW

Can someone help me ?
Thanks for your time !

Please Log in or Create an account to join the conversation.

Last edit: by trustfm.

App launches and then dies the moment you click 10 years 1 month ago #5108

  • sax
  • sax's Avatar
  • Offline
  • New Member
  • New Member
  • Posts: 10
  • Thank you received: 0
I'm currently using CodeTyphon 4.7, android-ndk-r9b-windows-x86, sdk installer_r22.3-windows,jdk1.6.0_38.
In CodeTyphon I'm using Library: C:\Android\ndk\platforms\android-8\arch-arm\usr\lib\ and in apk buil script I'm using:
SET PATH=C:\Android\sdk\tools;C:\Android\sdk\platform-tools\;C:\Android\sdk\build-tools\19.0.1\;C:\Progra~1\Java\jdk1.6.0_38\bin
SET APP_NAME=androidlcltest
SET ANDROID_HOME=C:\Android\sdk
SET APK_SDK_PLATFORM=C:\Android\sdk\platforms\android-8
SET APK_PROJECT_PATH=.
My Android virtual device is:
Android 2.3.3 and API level is 10, CPU is ARM(armeabi).
Application starts on virtual device and when I cklick on form crashes!
Does anyone know what could be wrong?

Please Log in or Create an account to join the conversation.

App launches and then dies the moment you click 10 years 1 month ago #5109

  • sam
  • sam's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 20
  • Thank you received: 2
Hi,

looks like the same problem here: ( see the end of the thread)
Thread in Lazarus Android Forum

If you find out, let us know.

Thank you.

Please Log in or Create an account to join the conversation.

App launches and then dies the moment you click 10 years 1 month ago #5113

  • Aleksandar
  • Aleksandar's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 150
  • Thank you received: 31

sax wrote: I'm currently using CodeTyphon 4.7, android-ndk-r9b-windows-x86, sdk installer_r22.3-windows,jdk1.6.0_38.
In CodeTyphon I'm using Library: C:\Android\ndk\platforms\android-8\arch-arm\usr\lib\ and in apk buil script I'm using:
SET PATH=C:\Android\sdk\tools;C:\Android\sdk\platform-tools\;C:\Android\sdk\build-tools\19.0.1\;C:\Progra~1\Java\jdk1.6.0_38\bin
SET APP_NAME=androidlcltest
SET ANDROID_HOME=C:\Android\sdk
SET APK_SDK_PLATFORM=C:\Android\sdk\platforms\android-8
SET APK_PROJECT_PATH=.
My Android virtual device is:
Android 2.3.3 and API level is 10, CPU is ARM(armeabi).
Application starts on virtual device and when I cklick on form crashes!
Does anyone know what could be wrong?


EDIT:
Included script for making .apk is not good anymore. It needs to be changed, since apkbuilder tool is removed from SDK. "Aapt add" can be used to add classes.dex to unisigned.apk.

You can compile java part and make apk with ANT too.

Java part of project needs to be checked.

I removed some of my comments since I realized that they are not useful.

Same crash here with CT 4.70 and JDK 7u51. I will try few more things tomorrow.

Please Log in or Create an account to join the conversation.

Last edit: by Aleksandar.

App launches and then dies the moment you click 10 years 1 month ago #5127

  • Aleksandar
  • Aleksandar's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 150
  • Thank you received: 31

sam wrote: Hi,

looks like the same problem here: ( see the end of the thread)
Thread in Lazarus Android Forum

If you find out, let us know.

Thank you.


Looks like some change in latest versions of FPC is cause of all those crashes.

I managed to make working android application using some files from older FPC.

I put archive with used files on dropbox . Use them only as temporary solution until someone find how to solve this properly.

1.Backup c:\codetyphon\fpc\bin and c:\codetyphon\fpc\units folders
2. Replace ppcrossarm.exe in c:\codetyphon\fpc\bin\i386-win32 with the one from archive
3. Remove c:\codetyphon\fpc\units\arm-android and replace it with the one from the archive
4. Delete folder c:\codetyphon\typhon\lcl\units\arm-android - it will be recreated on first compile of lcl app for android

Be sure that you set Target file name to android\libs\armeabi\liblclapp.so, that you added correct path to Android NDK in Labraries and that you set Target OS to Android and Target CPU to ARM.

Build project and check if you have liblclapp.so in c:\codetyphon\CodeOcean\2_Basics\samples\androidlcl\android\libs\armeabi

When you finish with this, you have working .so library and you are ready to follow the steps for making APK that I post earlier today.
The following user(s) said Thank You: sax

Please Log in or Create an account to join the conversation.

Last edit: by Aleksandar.

App launches and then dies the moment you click 10 years 3 weeks ago #5130

  • sax
  • sax's Avatar
  • Offline
  • New Member
  • New Member
  • Posts: 10
  • Thank you received: 0
THX viking.
I finally managed to have working .apk on emulator! :)
Only problem was that I have using jdk1.7.0_51, because in JDK 7, default signing algorithim has changed, requiring you to specify the signature and digest algorithims (-sigalg and -digestalg) when you sign an APK.
When I install .apk on emulator I got error
Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES]
Then I have to change JDK 7 to JDK 6 and is install correctly (or add "I think" -sigalg and -digestalg in jarsigner command, sigalg="MD5withRSA" digestalg="SHA1").

Please Log in or Create an account to join the conversation.

App launches and then dies the moment you click 10 years 3 weeks ago #5132

  • Aleksandar
  • Aleksandar's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 150
  • Thank you received: 31
It works just fine with 7u51. Just delete your already generated key and crate new one with JDK 7. :)

EDIT: I forgot to ask one important question. Have you used files from my archive or you managed to get working .so library with default files from CT 4.7?

Please Log in or Create an account to join the conversation.

Last edit: by Aleksandar.

App launches and then dies the moment you click 10 years 3 weeks ago #5137

  • sax
  • sax's Avatar
  • Offline
  • New Member
  • New Member
  • Posts: 10
  • Thank you received: 0
I use files from your archive.

If I generate .apk file with this settings, JDK 1.6 (build_debug_apk.bat)
SET JAVA_HOME="C:\Program Files\Java\jdk1.6.0_38"
...
REM Generating on the fly a debug key
keytool -genkey -v -keystore bin\LCLDebugKey.keystore -alias LCLDebugKey -keyalg RSA -validity 10000 -dname "CN=Jonh Doe" -storepass senhas -keypass senhas
...
REM Signing the APK with a debug key
del bin\%APP_NAME%-unaligned.apk
jarsigner -verbose -keystore bin\LCLDebugKey.keystore -keypass senhas -storepass senhas -signedjar bin\%APP_NAME%-unaligned.apk bin\%APP_NAME%-unsigned.apk LCLDebugKey

then I can successfully install .apk
C:\codetyphon\Projects\New_Empty\android>adb install bin\androidlcltest.apk
102 KB/s (740483 bytes in 7.056s)
        pkg: /data/local/tmp/androidlcltest.apk
Success

If I change JDK version to 1.7, like this (leave the rest of the code the same)
SET JAVA_HOME="C:\Program Files\Java\jdk1.7.0_51"
....
REM Generating on the fly a debug key
keytool -genkey -v -keystore bin\LCLDebugKey.keystore -alias LCLDebugKey -keyalg RSA -validity 10000 -dname "CN=Jonh Doe" -storepass senhas -keypass senhas
....
REM Signing the APK with a debug key
del bin\%APP_NAME%-unaligned.apk
jarsigner -verbose -keystore bin\LCLDebugKey.keystore -keypass senhas -storepass senhas -signedjar bin\%APP_NAME%-unaligned.apk bin\%APP_NAME%-unsigned.apk LCLDebugKey

then I get installer error
C:\codetyphon\Projects\New_Empty\android>adb install bin\androidlcltest.apk
237 KB/s (740687 bytes in 3.049s)
        pkg: /data/local/tmp/androidlcltest.apk
Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES]

and if I now change jarsigner to
jarsigner -verbose -sigalg MD5withRSA -digestalg SHA1 -keystore bin\LCLDebugKey.keystore -keypass senhas -storepass senhas -signedjar bin\%APP_NAME%-unaligned.apk bin\%APP_NAME%-unsigned.apk LCLDebugKey

then .apk installs correctly.

Please Log in or Create an account to join the conversation.

Last edit: by sax.

App launches and then dies the moment you click 10 years 3 weeks ago #5144

  • Aleksandar
  • Aleksandar's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 150
  • Thank you received: 31

sax wrote: If I change JDK version to 1.7, like this (leave the rest of the code the same)

SET JAVA_HOME="C:\Program Files\Java\jdk1.7.0_51"

then I get installer error
C:\codetyphon\Projects\New_Empty\android>adb install bin\androidlcltest.apk
237 KB/s (740687 bytes in 3.049s)
        pkg: /data/local/tmp/androidlcltest.apk
Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES]


It is very simple.

If you already have keystore, then this line will fail with message like this:
c:\codetyphon\CodeOcean\2_Basics\samples\androidlcl\android>keytool -genkey -v -
keystore bin\LCLDebugKey.keystore -alias LCLDebugKey -keyalg RSA -validity 10000
 -dname "CN=Jonh Doe" -storepass senhas -keypass senhas
keytool error: java.lang.Exception: Key pair not generated, alias <LCLDebugKey>
already exists

Just delete c:\codetyphon\CodeOcean\2_Basics\samples\androidlcl\android\bin\LCLDebugKey.keystore that you generated with 1.6 first and then new one with be created with 1.7 if you have that line uncommented.

Then you will get something like this:
c:\codetyphon\CodeOcean\2_Basics\samples\androidlcl\android>keytool -genkey -v -
keystore bin\LCLDebugKey.keystore -alias LCLDebugKey -keyalg RSA -validity 10000
 -dname "CN=Jonh Doe" -storepass senhas -keypass senhas
Generating 2,048 bit RSA key pair and self-signed certificate (SHA256withRSA) wi
th a validity of 10,000 days
        for: CN=Jonh Doe
[Storing bin\LCLDebugKey.keystore]

and then
c:\codetyphon\CodeOcean\2_Basics\samples\androidlcl\android>jarsigner -verbose -
keystore bin\LCLDebugKey.keystore -keypass senhas -storepass senhas -signedjar b
in\androidlcltest-unaligned.apk bin\androidlcltest-unsigned.apk LCLDebugKey
   adding: META-INF/MANIFEST.MF
   adding: META-INF/LCLDEBUG.SF
   adding: META-INF/LCLDEBUG.RSA
  signing: lib/armeabi/liblclapp.so
  signing: AndroidManifest.xml
  signing: resources.arsc
  signing: res/drawable-hdpi/icon.png
  signing: res/drawable-ldpi/icon.png
  signing: res/drawable-mdpi/icon.png
  signing: classes.dex
jar signed.

p.s. Yes, I could add
del bin\LCLDebugKey.keystore

but I didn't want to be blamed if someone lost his properly created key because of that.

Please Log in or Create an account to join the conversation.

App launches and then dies the moment you click 10 years 1 week ago #5199

  • Leslie
  • Leslie's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 66
  • Thank you received: 4
Hi,

I have a fresh install of CT 4.70. Replaced everything as suggested above. Compilation fails with the following error:

PPU Loading C:\codetyphon\typhon\components\lazutils\lib\arm-android\lazlogger.ppu
PPU Invalid Version 164
lclproc.pas(32,28) Fatal: Can not find LazLogger used by LCLProc, ppu=..\components\lazutils\lib\arm-android\lazlogger.ppu, package LazUtils


Any idea where could I be going wrong?

Cheers,
Leslie
The following user(s) said Thank You: sam

Please Log in or Create an account to join the conversation.

App launches and then dies the moment you click 9 years 11 months ago #5259

  • Leslie
  • Leslie's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 66
  • Thank you received: 4
Hi,

After compiling the crosscompiler from the latest SVN source and rebuilding all involved FPC&CT units, the problem remains the same. My understanding was that this has ben fixed in FPC SVN. Is this working with he lab version of CT? (By the way, is there an approximate release date?)

Cheers,
Leslie

Please Log in or Create an account to join the conversation.

App launches and then dies the moment you click 9 years 11 months ago #5260

  • Leslie
  • Leslie's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 66
  • Thank you received: 4
As I understand there is a not too old FPC revision which is known to be able to create a working android test application. Anyone remembers wich revision is it?

Please Log in or Create an account to join the conversation.

Last edit: by Leslie.

App launches and then dies the moment you click 9 years 11 months ago #5263

  • Aleksandar
  • Aleksandar's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 150
  • Thank you received: 31

Leslie wrote: My understanding was that this has ben fixed in FPC SVN. Is this working with he lab version of CT?


Where did you get that info?

Bug report submitted by our friend Sam is still open.

Based on Maciej's comment and the fact that Simon's Native Android Controls work without any problem, it is 99% LCL or even JAVA bug.

Leslie wrote: As I understand there is a not too old FPC revision which is known to be able to create a working android test application. Anyone remembers wich revision is it?


I posted older FPC version in this post as temp workaround.
The following user(s) said Thank You: Leslie

Please Log in or Create an account to join the conversation.

Last edit: by Aleksandar.

App launches and then dies the moment you click 9 years 11 months ago #5264

  • Leslie
  • Leslie's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 66
  • Thank you received: 4
Hi Viking,

I obviously misunderstood something. :unsure:

The first thing I have tried was your suggestion. But I got stucked with the problem you can see in post #5199

If you can share the FPC revision the files you have provided had been compiled with, I might be able to get it working.

Cheers,
Leslie

Please Log in or Create an account to join the conversation.

Last edit: by Leslie.

App launches and then dies the moment you click 9 years 11 months ago #5269

  • Aleksandar
  • Aleksandar's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 150
  • Thank you received: 31

Leslie wrote: Hi Viking,

I obviously misunderstood something. :unsure:

The first thing I have tried was your suggestion. But I got stucked with the problem you can see in post #5199

If you can share the FPC revision the files you have provided had been compiled with, I might be able to get it working.

Cheers,
Leslie


It worked for me with files that I posted.

Since sax successfully compiled apk, that only means that my instructions might not be clear enough.

I really do not have time to experiment and to try to find what could be reason for your problem.

And regarding the FPC version, any versions around 2013-5-12 should be fine.

Please Log in or Create an account to join the conversation.

App launches and then dies the moment you click 9 years 11 months ago #5272

  • Leslie
  • Leslie's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 66
  • Thank you received: 4
Viking,

I am not expecting you to solve this problem. Though I appreciate any help/info I can get. If you do not have the time feel free to stay out of the topic. :)

What I have discovered so far:

Handling the touch event invalidates the display. As a result a redraw takes place and the crush occurs whithin Java_com_pascal_lclproject_LCLActivity_LCLDrawToBitmap. I would try to investigate further, but could not find a way to debug the pascal part when running on android. If someone could help with this - if it is possible at all- that would be great.

Cheers,
Leslie

Please Log in or Create an account to join the conversation.

Last edit: by Leslie.

App launches and then dies the moment you click 9 years 11 months ago #5347

  • sam
  • sam's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 20
  • Thank you received: 2
I still try to find the problem on this issue. But I need your help.
See my last question on this bug.
Bug Tracker #25686

In short:

1.) I have two fpc-folders.
2.) Compile with fpc-folder A creates an working android app.
3.) Compile with fpc-folder B creates an non-working android app. ( problem as decribed in this thread)

My attempt to find the differences between fpc-folder A and fpc-folder B.

1.) I took a folder-compare program that shows about 4000 differences. (compare all files)
My questions:
A) Which files are files are temporary files only (.ppu,.o) and can be delete before the folder compare is done?
B) If I delete all .ppu files first and then try to compile my app again, lazarus complains about missing system.ppu. What to do? Some how recompile fpc?

Thank you for your answers.

Please Log in or Create an account to join the conversation.

App launches and then dies the moment you click 9 years 11 months ago #5348

  • Leslie
  • Leslie's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 66
  • Thank you received: 4
Finally I had some time to investigate this problem. The problem was NOT caused by the compiler. The faulty code is in customdrawnproc.RenderWinControl:

ACanvas.ClipRegion := ACDWinControl.Region;

In this line a reference is stored to an other objects property. Which did not cause a problem until FPC r24555, when a memory leak caused by not freeing TFPCustomCanvas.FClipRegion in TFPCustomCanvas destructor was fixed. From this point destroying the canvas object destroyed ACDWinControl.Region.

The solution is to create a separate object:

function RenderWinControl(var AImage: TLazIntfImage; var ACanvas: TLazCanvas;
ACDWinControl: TCDWinControl; ACDForm: TCDForm): Boolean;
var
...
lRegion : TLazRegionWithChilds; <-- add a local variable
...
// --> replace the faulty line above with this

lRegion := TLazRegionWithChilds.Create;
lRegion.Assign(ACDWinControl.Region);
ACanvas.ClipRegion := lRegion;

"c:\codetyphon\typhon\lcl\units\arm-android\customdrawn\" probably needs to be cleared before rebuilding the test application with "Clean up and build ..." .

Cheers,
Leslie

Please Log in or Create an account to join the conversation.

Last edit: by Leslie.

App launches and then dies the moment you click 9 years 11 months ago #5349

  • sam
  • sam's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 20
  • Thank you received: 2
Well done leslie, you fixed the problem.

Great. Thanks.

Please Log in or Create an account to join the conversation.

App launches and then dies the moment you click 9 years 11 months ago #5350

  • Dinko
  • Dinko's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 91
  • Thank you received: 5
Thank you very much.
I can confirm that this solution is OK.
I made a test with CT 4.7 Win32

Location of customdrawnproc.pas file is in
c:\codetyphon\typhon\lcl\interfaces\customdrawn\ directory

Best Regards, Dinko

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
  • 2