Recent

Author Topic: laz4android update!  (Read 27322 times)

Handoko

  • Hero Member
  • *****
  • Posts: 3198
  • My goal: build my own game engine using Lazarus
Re: laz4android update!
« Reply #30 on: October 18, 2015, 08:44:27 am »
Thanks all for the helps and suggestions. But unfortunately, the result is same: "Unfortunately, Project1 has stopped."

Although, I'm still not able to produce correct APK for Android Intel 64-bit, here I post all the things I found. Hope it would be useful for someone who is willing to try and for LazForApk/laz4Android future improvement.

Quote
1. Extract the apk and see if the file structure is correct. Under the unzipped directory, there is a "lib" folder and there should be 2 sub-folders(armeabi & x86) in "lib". Check if the files in those 2 sub folders correspond to the CPU structure.

I now able to produce x86 only and fat binaries (armeabi & x86). But the code just won't run on my phone. It make me think that the problem wasn't my failure to create x86 lib in the apk file.

On my previous attempts, I failed to build x86 lib in the apk file because of 2 reasons:

1. On the Lazarus - Project Settings, I didn't notice that I have to change "android\libs\armeabi\liblclapp" to "android\libs\x86\liblclapp" on the Path > Target File Name setting. It caused the result file (x86 code) to be saved in the folder named armeabi.

2. The script file "build_debug_apk.bat" generated by LazForApk contain hardcoded text "armeabi" but without "x86". So I have to manually added the text "x86".

Quote
2. Write a simplest "Hello World" test app to see whether it works. If it works, maybe there's something wrong in your code?

I didn't write my own code for the tests. But I used the default test project generated by LazForApk. So it makes me think that perhaps the default test project generated by LazForApk or the Custom Drawn package might ever call any function that is only for arm machines, which is not compatible with Intel 64-bit.

Quote
Library Path:
$(LazarusDir)\Android_NDK\platforms\android-9\arch-x86\usr\lib;
$(LazarusDir)\Android_NDK\toolchains\x86-4.8\prebuilt\windows\lib\gcc\i686-linux-android\4.8

and no Custom Options.

Maybe you missed my second library path.

I have tested with the second library path added + with/without custom options. I also have tried with:
- ...\platforms\android-9\...
- ...\platforms\android-16\...
- ...\toolchains\x86-4.8\...\i686-linux-android\4.8
- ...\toolchains\x86-4.8\...\i686-linux-android\4.9

Quote
I think it's not laz4android problems , laz4android is support android x86 compiled ok.
I think maybe when the Laztoapk build the APK file, it's not include x86 folder into the android APK file.
please try use the attachments(build_debug_apk_new.bat) to build the APK file.

Thank you truetom for the new script file. It can't run, but I managed to fix it by changing the paths to mine. Also there was one missing file on this line:

Code: Pascal  [Select]
  1. REM Convert the java bytecode to dalvik bytecode
  2. call java -Djava.ext.dirs=%ANDROID_HOME%\platform-tools\lib\ -jar %ANDROID_HOME%\platform-tools\lib\dx.jar --dex --verbose --output=%APK_PROJECT_PATH%\bin\classes.dex %APK_PROJECT_PATH%\bin\classes

The code above (in build_debug_apk_new.bat) need to be changed to:

Code: Pascal  [Select]
  1. REM DX to convert the java bytecode to dalvik bytecode
  2. call java -Djava.ext.dirs=%ANDROID_HOME%\platform-tools\lib\ -jar %ANDROID_HOME%\build-tools\%SDK_BUILDTOOLS%\lib\dx.jar --dex --verbose --output=%APK_PROJECT_PATH%\bin\classes.dex %APK_PROJECT_PATH%\bin\classes

The difference is the file "..\lib\dx.jar" should not be be located under "...\platform-tools" because there no such file in that location. It works if I changed it to "...\build-tools\%SDK_BUILDTOOLS%\lib\dx.jar"

Now the new script file is able to run correctly.

Quote
did you look at the sourcecode of laztoapk?
You try to use laztoapk to build x86 android apps. This is not supported by laztoapk.
I would need to change things in laztoapk.
If you look at the code
http://sourceforge.net/p/laztoapk/svn/HEAD/tree/trunk/source/apkmanagermain.pas#l965
and search for "CopyNDKFilesToFPC" you will see that laztoapk copies only arm -stuff from the ndk folder into the  laz4android folder.

Yep, I had already noticed it and tested to copy the x86 version of NDK files before you told me. But I just re-performed the test again with combining all the suggestions (as I mentioned above), but still got the same error.

Can anyone tell me, my phone is Intel Atom 64-bit, is it able to run code that compiled by Lazarus with Intel I386 setting? Or must I change the Lazarus Target CPU Family setting to x86_64? I tried to change it to x86_64, but it can't because it hasn't cross compile to that target.

Those above are what I found so far, hope it can be useful for others.

truetom

  • Jr. Member
  • **
  • Posts: 72
    • http://sourceforge.net/projects/laz4android/
Re: laz4android update!
« Reply #31 on: October 29, 2015, 01:49:56 pm »
Hello all,

New version laz4android1.4.4-FPC3.0.0RC2 released.

You can download from here:
http://sourceforge.net/projects/laz4android/

Laz4Android is a Lazarus for Android Package.
Thanks the FreePascal team and the Lazarus team.
Now Laz4Android is only run on Windows. Sorry for this!

---------------------------------------------------------
Last update:2015-10-29
FPC: 3.0.0 rc2 (win32/arm-android/i386-android/jvm-android)
Lazarus:1.4.4
Android NDK: r10e (arm-linux-androideabi-4.9 + x86-4.9)

1.Lazarus 1.4.4 source + some fixed(for laz4android) + FPC 3.0.0 rc2,   I think this is a good combination.
We can release a laz4android stable edition .

=========================================================
How to install Laz4Android?

1.You can download a installer file from here:
http://sourceforge.net/projects/laz4android/files/?source=navbar
- Double click the installer file
- Next , Next to finished.

---------------------------------------------------------
2.You can download a 7z compressed file from here:
http://sourceforge.net/projects/laz4android/files/?source=navbar
- Unzip 7z file to e.g.  c:\laz4android
- Please run build.bat (double click it), it will compile and build laz4android.

=========================================================

Thanks and best regards!
laz4android : a Lazarus for Android Package.
http://sourceforge.net/projects/laz4android/

chenyuchih

  • Jr. Member
  • **
  • Posts: 73
Re: laz4android update!
« Reply #32 on: October 30, 2015, 02:32:34 am »
Excuse me....

Did somebody encounter library problem with latest 3 versions of Laz4Android?

The following code works fine with previous version, but with recent 3 versions it compiles but crashs when running on Android 2.3.3(API10).

Did FPC changes something with JNI  rule?

-- FPC code --
library testjni;

{$mode objfpc}{$H+}

uses
  JNI;

Function MyAdd(Env: pJNIEnv;this:JObject;a,b:JDouble):JDouble;Cdecl;
begin
Result:=a+b;
end;

Function JNI_OnLoad(VM: PJavaVM;Reserved: Pointer):JInt;Cdecl;
begin
Result:=JNI_VERSION_1_4;
end;

Procedure JNI_OnUnload(VM: PJavaVM;Reserved: Pointer);Cdecl;
begin
end;

Exports

MyAdd name 'Java_Test_TestJNI_MyAdd',

JNI_OnLoad,
JNI_OnUnLoad;

begin
end.

-- Java code --
package Test;
public class TestJNI {
        static
        {
                System.loadLibrary("testjni");               
        }
               
        public static native double MyAdd(double a, double b);
}
--
Project Options:
Libraries path setup
$(LazarusDir)\Android_NDK\platforms\android-8\arch-arm\usr\lib

Android / arm / ARMV6
--
Do I miss anything?

Thanks for your kindly help.

Best Regards,
ChenYuChih

jmpessoa

  • Hero Member
  • *****
  • Posts: 1470
Re: laz4android update!
« Reply #33 on: October 30, 2015, 02:49:31 am »

Hello chenyuchih!

recent 3 laz4android versions is for "Android NDK: r10e"  <<-----"e"
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

chenyuchih

  • Jr. Member
  • **
  • Posts: 73
Re: laz4android update!
« Reply #34 on: October 30, 2015, 03:18:18 am »

Hello chenyuchih!

recent 3 laz4android versions is for "Android NDK: r10e"  <<-----"e"

Yes, the NDK version I use is r10e. And I tried several different platforms (Android-8,12,19,21) but got the same result.(compile ok, run crash)

truetom

  • Jr. Member
  • **
  • Posts: 72
    • http://sourceforge.net/projects/laz4android/
Re: laz4android update!
« Reply #35 on: October 30, 2015, 04:11:25 pm »
Yes, the NDK version I use is r10e. And I tried several different platforms (Android-8,12,19,21) but got the same result.(compile ok, run crash)

Hello chenyuchih,

I had test your code ,and create a demo to test , it's run ok ,please see the attachments .

EDIT:OK,I found this bug , yes it's run crash on android 2.2.But the FPC trunk likes already fixed this bug.

Thanks and best regards!
« Last Edit: October 31, 2015, 01:43:13 am by truetom »
laz4android : a Lazarus for Android Package.
http://sourceforge.net/projects/laz4android/

jmpessoa

  • Hero Member
  • *****
  • Posts: 1470
Re: laz4android update!
« Reply #36 on: October 30, 2015, 10:08:24 pm »
Hello TrueTom!

I installed the LAMW in the new release "laz4android1.4.4-FPC3.0.0RC2"
and build a new "Lamw GUI" project ...but when I tried to compile[build], I got the error:

Quote
Compiling package FCL 1.0.1: Access violation
  $00A9E160  TFPCMSGFILEPOOLITEM__GETMSG,  line 1030 of etfpcmsgparser.pas
  $00A9E881  ADDPATTERNITEM,  line 1131 of etfpcmsgparser.pas
  $00A9E809  TIDEFPCPARSER__INITREADING,  line 1142 of etfpcmsgparser.pas
  $006FA7C1  TEXTERNALTOOL__PROCESSRUNNING,  line 376 of exttools.pas
  $006FE6D1  TEXTERNALTOOLTHREAD__EXECUTE,  line 1461 of exttools.pas
  $0047E225
  $00412D1E
  $7683337A
  $77269882
  $77269855
, Errors: 11
Panic: internal error: Access violation
Panic: internal error:   $00A9E160  TFPCMSGFILEPOOLITEM__GETMSG,  line 1030 of etfpcmsgparser.pas
Panic: internal error:   $00A9E881  ADDPATTERNITEM,  line 1131 of etfpcmsgparser.pas
Panic: internal error:   $00A9E809  TIDEFPCPARSER__INITREADING,  line 1142 of etfpcmsgparser.pas
Panic: internal error:   $006FA7C1  TEXTERNALTOOL__PROCESSRUNNING,  line 376 of exttools.pas
Panic: internal error:   $006FE6D1  TEXTERNALTOOLTHREAD__EXECUTE,  line 1461 of exttools.pas
Panic: internal error:   $0047E225
Panic: internal error:   $00412D1E
Panic: internal error:   $7683337A
Panic: internal error:   $77269882
Panic: internal error:   $77269855

Well, if I close and reopen again Lazarus everything is ok....

Note:

laz4android1.5-50093-FPC3.1.1 also had the same error/problem

laz4android1.5-49903-FPC3.1.1 ... works fine!

Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

chenyuchih

  • Jr. Member
  • **
  • Posts: 73
Re: laz4android update!
« Reply #37 on: October 31, 2015, 01:28:32 am »
Yes, the NDK version I use is r10e. And I tried several different platforms (Android-8,12,19,21) but got the same result.(compile ok, run crash)

Hello chenyuchih,

I had test your code ,and create a demo to test , it's run ok ,please see the attachments .

Thanks and best regards!

OKay, I found where the problem is. I use another computer(my laptop is too old to run modern Android) to run the simulator of Android 4.3.1(API 18, armeabi-v7a) and everything become so smooth. The previous test I did is with Android 2.3.3.(API10, armeabi)

But here comes another big question mark. Will the later FPC no longer support old Android version(2.X) or armeabi architecture? For my app, some users still hold a smartphone over 5 years!(such like moto defy) If those old versions will be unsupported, it really could be a big issue for me. Maybe temporarily I would still use the Laz4Android released in July, 2015.

Thanks truetom! I appreciate your kindly help. :)

Best Regards,
ChenYuChih

truetom

  • Jr. Member
  • **
  • Posts: 72
    • http://sourceforge.net/projects/laz4android/
Re: laz4android update!
« Reply #38 on: October 31, 2015, 02:01:13 am »
Hello TrueTom!

I installed the LAMW in the new release "laz4android1.4.4-FPC3.0.0RC2"
and build a new "Lamw GUI" project ...but when I tried to compile[build], I got the error:

Quote
Compiling package FCL 1.0.1: Access violation
  $00A9E160  TFPCMSGFILEPOOLITEM__GETMSG,  line 1030 of etfpcmsgparser.pas
  $00A9E881  ADDPATTERNITEM,  line 1131 of etfpcmsgparser.pas
  $00A9E809  TIDEFPCPARSER__INITREADING,  line 1142 of etfpcmsgparser.pas
  $006FA7C1  TEXTERNALTOOL__PROCESSRUNNING,  line 376 of exttools.pas
  $006FE6D1  TEXTERNALTOOLTHREAD__EXECUTE,  line 1461 of exttools.pas
  $0047E225
  $00412D1E
  $7683337A
  $77269882
  $77269855
, Errors: 11
Panic: internal error: Access violation
Panic: internal error:   $00A9E160  TFPCMSGFILEPOOLITEM__GETMSG,  line 1030 of etfpcmsgparser.pas
Panic: internal error:   $00A9E881  ADDPATTERNITEM,  line 1131 of etfpcmsgparser.pas
Panic: internal error:   $00A9E809  TIDEFPCPARSER__INITREADING,  line 1142 of etfpcmsgparser.pas
Panic: internal error:   $006FA7C1  TEXTERNALTOOL__PROCESSRUNNING,  line 376 of exttools.pas
Panic: internal error:   $006FE6D1  TEXTERNALTOOLTHREAD__EXECUTE,  line 1461 of exttools.pas
Panic: internal error:   $0047E225
Panic: internal error:   $00412D1E
Panic: internal error:   $7683337A
Panic: internal error:   $77269882
Panic: internal error:   $77269855

Well, if I close and reopen again Lazarus everything is ok....

Note:

laz4android1.5-50093-FPC3.1.1 also had the same error/problem

laz4android1.5-49903-FPC3.1.1 ... works fine!

Hello jmpessoa!

I think this is a Lazaurs bug , you can report this bug to Lazarus Bugtracker.

Thanks and best regards!
laz4android : a Lazarus for Android Package.
http://sourceforge.net/projects/laz4android/

truetom

  • Jr. Member
  • **
  • Posts: 72
    • http://sourceforge.net/projects/laz4android/
Re: laz4android update!
« Reply #39 on: October 31, 2015, 05:52:32 am »

OKay, I found where the problem is. I use another computer(my laptop is too old to run modern Android) to run the simulator of Android 4.3.1(API 18, armeabi-v7a) and everything become so smooth. The previous test I did is with Android 2.3.3.(API10, armeabi)

But here comes another big question mark. Will the later FPC no longer support old Android version(2.X) or armeabi architecture? For my app, some users still hold a smartphone over 5 years!(such like moto defy) If those old versions will be unsupported, it really could be a big issue for me. Maybe temporarily I would still use the Laz4Android released in July, 2015.

Thanks truetom! I appreciate your kindly help. :)

Best Regards,
ChenYuChih

Hello ChenYuChih,
OK , now I build a FPC 4in1 rapid update package:
http://sourceforge.net/projects/laz4android/files/FreePascal/

I think it's fixed your problem.

For an explanation of FPC 4in1 updates:
This update package is used to replace the FPC of laz4android entire folders, rapid upgrade FPC compiler, so don't need to download and install the laz4android again, in order to achieve the purpose of rapid upgrade laz4android.
Note that after replacement, please execute the batch file create-fpc.cfg.bat.

Thanks and best regards!
« Last Edit: October 31, 2015, 05:54:40 am by truetom »
laz4android : a Lazarus for Android Package.
http://sourceforge.net/projects/laz4android/

DelphiFreak

  • Full Member
  • ***
  • Posts: 246
    • Fresh sound.
Re: laz4android update!
« Reply #40 on: October 31, 2015, 06:42:37 am »
Hello truetom,

thank you for fixing / maintaining laz4android!

I am preparing a new bundle of laztoapk.
The installer of laztoapk downloads the latest laz4android from sourceforge.net  http://sourceforge.net/p/laztoapk/svn/HEAD/tree/trunk/install/laztoapk.iss

Now you created a "FPC 4in1 rapid update package" for laz4android.
Question: Will you integrate this into RC3 or do I need to change my install script and download both files?

Regards,
Sam
Linux Mint 19.1, Lazarus 2.0, Windows 7&10, Delphi 7, Delphi 10.3 Rio

truetom

  • Jr. Member
  • **
  • Posts: 72
    • http://sourceforge.net/projects/laz4android/
Re: laz4android update!
« Reply #41 on: October 31, 2015, 08:56:40 am »
Hello DelphiFreak,

Sure , I will continue update laz4android installer and 7z file.
When the FPC 3.0.0 rc3 or FPC 3.0.0 official version is release , I will test it and update laz4android too.
But now I think release a rapid upgrade package for laz4andorid which can save more time and quick response.

about laztoapk ,  I think we can wait FPC 3.0.0 rc3 or official release .
I am waiting too.

Thanks and best regards!
laz4android : a Lazarus for Android Package.
http://sourceforge.net/projects/laz4android/

truetom

  • Jr. Member
  • **
  • Posts: 72
    • http://sourceforge.net/projects/laz4android/
Re: laz4android update!
« Reply #42 on: November 29, 2015, 09:29:52 am »
Hello all,

New version laz4android1.4.4-FPC3.0.0 released.
I hope this is a laz4android stable edition.

You can download from here:
http://sourceforge.net/projects/laz4android/

Laz4Android is a Lazarus for Android Package.
Thanks the FreePascal team and the Lazarus team.
Now Laz4Android is only run on Windows.Sorry for this!

---------------------------------------------------------
Last update:2015-11-29
FPC: 3.0.0 "Pestering Peacock" (win32/arm-android/i386-android/jvm-android)
Lazarus:1.4.4
Android NDK: r10e (arm-linux-androideabi-4.9 + x86-4.9)

1.Update to FPC 3.0.0 "Pestering Peacock", a laz4android stable edition.

=========================================================
How to install Laz4Android?

1.You can download a installer file from here:
http://sourceforge.net/projects/laz4android/files/?source=navbar
- Double click the installer file
- Next , Next to finished.

---------------------------------------------------------
2.You can download a 7z compressed file from here:
http://sourceforge.net/projects/laz4android/files/?source=navbar
- Unzip 7z file to e.g.  c:\laz4android
- Please run build.bat (double click it), it will compile and build laz4android.

=========================================================

Thanks and best regards!
laz4android : a Lazarus for Android Package.
http://sourceforge.net/projects/laz4android/

jmpessoa

  • Hero Member
  • *****
  • Posts: 1470
Re: laz4android update!
« Reply #43 on: November 29, 2015, 04:53:01 pm »
Hello TrueTom

[about new release]

I got this error when try cross-compile a "Lamw/Android Module Wizard" project:

Quote
Compiling package FCL 1.0.1: Access violation
  $00A9E160  TFPCMSGFILEPOOLITEM__GETMSG,  line 1030 of etfpcmsgparser.pas
  $00A9E881  ADDPATTERNITEM,  line 1131 of etfpcmsgparser.pas
  $00A9E809  TIDEFPCPARSER__INITREADING,  line 1142 of etfpcmsgparser.pas
  $006FA7C1  TEXTERNALTOOL__PROCESSRUNNING,  line 376 of exttools.pas
  $006FE6D1  TEXTERNALTOOLTHREAD__EXECUTE,  line 1461 of exttools.pas
  $0047E225
  $00412D1E
  $74D038F4
  $77B35663
  $77B3562E
, Errors: 11
Panic: internal error: Access violation
Panic: internal error:   $00A9E160  TFPCMSGFILEPOOLITEM__GETMSG,  line 1030 of etfpcmsgparser.pas
Panic: internal error:   $00A9E881  ADDPATTERNITEM,  line 1131 of etfpcmsgparser.pas
Panic: internal error:   $00A9E809  TIDEFPCPARSER__INITREADING,  line 1142 of etfpcmsgparser.pas
Panic: internal error:   $006FA7C1  TEXTERNALTOOL__PROCESSRUNNING,  line 376 of exttools.pas
Panic: internal error:   $006FE6D1  TEXTERNALTOOLTHREAD__EXECUTE,  line 1461 of exttools.pas
Panic: internal error:   $0047E225
Panic: internal error:   $00412D1E
Panic: internal error:   $74D038F4
Panic: internal error:   $77B35663
Panic: internal error:   $77B3562E
« Last Edit: November 29, 2015, 04:54:50 pm by jmpessoa »
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

jmpessoa

  • Hero Member
  • *****
  • Posts: 1470
Re: laz4android update!
« Reply #44 on: November 30, 2015, 05:31:57 pm »

Hello TrueTom!

after a re-install and point  "startlazarus.exe"  to  "C:\laz4android"
not  to ".\"  the problem was solved!

Thank you!
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard