Lazarus

Programming => Operating Systems => Android => Topic started by: truetom on August 01, 2015, 08:44:55 am

Title: laz4android update!
Post by: truetom on August 01, 2015, 08:44:55 am
Hello all,

I have updated laz4android to new version.

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-07-25
FPC: 3.1.1 trunk svn 31226 win32/arm-android/i386-android/jvm-android
Lazarus:1.5 trunk svn 49563
Android NDK: r10c (arm-linux-androideabi-4.6 + x86-4.6)

=========================================================
Update history:
2014-04-05:
1.Fixed Android application crash problem,thanks DelphiFreak and Leslie.
---------------------------------------------------------
2014-10-18:
FPC: 2.7.1 trunk svn 28863 win32/arm-android/i386-android/jvm-android
Lazarus:1.3 trunk svn 46592
Android NDK: r10c (arm-linux-androideabi-4.6 + x86-4.6)

1.Fixed examples\androidlcl,now it can compatible with this version.
2.Compatible with Jmpessoa's LazAndroidModuleWizard,thanks Jmpessoa and Simonsays,links:
  https://github.com/jmpessoa/lazandroidmodulewizard
  http://forum.lazarus.freepascal.org/index.php/topic,21919.0.html
---------------------------------------------------------
2015-02-25:
FPC: 3.1.1 trunk svn 29987 win32/arm-android/i386-android/jvm-android
Lazarus:1.5 trunk svn 47987
Android NDK: r10c (arm-linux-androideabi-4.6 + x86-4.6)

1.Fixed examples\androidlcl\build_debug_apk.bat,now it can use JDK1.7 or JDK1.8 to Signing the APK.
---------------------------------------------------------
2015-07-25:
FPC: 3.1.1 trunk svn 31226 win32/arm-android/i386-android/jvm-android
Lazarus:1.5 trunk svn 49563
Android NDK: r10c (arm-linux-androideabi-4.6 + x86-4.6)

1.Update!

=========================================================
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
- Edit the file c:\laz4android\build.bat like this:

  SET FPC_BIN_PATH=c:\laz4android

Please run build.bat (double click it), it will compile and build lazarus.
=========================================================

Thanks and best regards!
Title: Re: laz4android update!
Post by: jmpessoa on August 05, 2015, 12:02:59 am

Hello TrueTom!

Thank you very much!
Title: Re: laz4android update!
Post by: truetom on August 05, 2015, 03:13:13 pm

Hello TrueTom!

Thank you very much!

Hello jmpessoa!

Thank you for your Lazarus Android Module Wizard (LAMW), your jobs is great!

I will introduce  your LAMW to  Chinese Lazarus  forum!

Best regards!
Title: Re: laz4android update!
Post by: jmpessoa on August 05, 2015, 03:45:31 pm
Hello TrueTom!

I updated the tutorials:

"readme_get_start.txt"
"install_tutorial.txt"
"install_tutorial_eclipse_users.txt"

and for Linux there is:

"new_how_to_install_by_renabor.txt"   [folder "..\linux"]

Thank you!
Title: Re: laz4android update!
Post by: m4u_hoahoctro on August 06, 2015, 01:39:39 pm
Hi truetom
I am needing using unit fphttpclient for my android app, but when add it's name to uses clause and compile
laz4android show error message

Code: [Select]
Fatal: Cannot find unit fphttpclient used by unit1 of the Project Inspector.
I don't know how to add it
Please help
Thanks much  :)
Title: Re: laz4android update!
Post by: truetom on August 06, 2015, 02:51:16 pm
Hello m4u_hoahoctro!

I think you can try do like this, please see the attachememts.

Thanks and best regards!
Title: Re: laz4android update!
Post by: m4u_hoahoctro on August 06, 2015, 03:05:08 pm
Hello m4u_hoahoctro!

I think you can try do like this, please see the attachememts.

Thanks and best regards!

hi truetom, thanks very much :)

my friend said I also use jhttpclient in lamw :)
with fphttpclient i can use this code to get infomations about site's header

Code: [Select]
try
http1.HTTPMethod('GET','http://v3.mp3.zing.vn/download/vip/song/ZW6F97CU',stream1,code);
for i:=0 to http1.ResponseHeaders.Count-1 do
begin
s:=http1.ResponseHeaders.Strings[i];   

infomations about site's header can get by command ReponseHeaders ( as above ),
but I couldn't find anything same as it in list of commands of jhttpclient :(

Title: Re: laz4android update!
Post by: Ñuño_Martínez on August 17, 2015, 07:27:50 pm
Didn't know it exists. I should take a look as we will need it in a future. Unfortunatelly I haven't a Windows computer right now.  :(
Title: Re: laz4android update!
Post by: jmpessoa on August 17, 2015, 08:09:26 pm

@m4u_hoahoctro

Quote
...infomations about site's header can get by command ReponseHeaders ( as above ),
but I couldn't find anything same as it in list of commands of jhttpclient

Ok, I will improve header support in [Lamw] "jhttpclient "!

Thank you!
Title: Re: laz4android update!
Post by: truetom on September 24, 2015, 03:43:15 pm
Hello all,

I have updated laz4android to new version.

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-09-24
FPC: 3.1.1 trunk svn 31778 win32/arm-android/i386-android/jvm-android
Lazarus:1.5 trunk svn 49869
Android NDK: r10e (arm-linux-androideabi-4.9 + x86-4.9)

=========================================================
Update history:
2014-04-05:
1.Fixed Android application crash problem,thanks DelphiFreak and Leslie.
---------------------------------------------------------
2014-10-18:
FPC: 2.7.1 trunk svn 28863 win32/arm-android/i386-android/jvm-android
Lazarus:1.3 trunk svn 46592
Android NDK: r10c (arm-linux-androideabi-4.6 + x86-4.6)

1.Fixed examples\androidlcl,now it can compatible with this version.
2.Compatible with Jmpessoa's LazAndroidModuleWizard,thanks Jmpessoa and Simonsays,links:
  https://github.com/jmpessoa/lazandroidmodulewizard
  http://forum.lazarus.freepascal.org/index.php/topic,21919.0.html
---------------------------------------------------------
2015-02-25:
FPC: 3.1.1 trunk svn 29987 win32/arm-android/i386-android/jvm-android
Lazarus:1.5 trunk svn 47987
Android NDK: r10c (arm-linux-androideabi-4.6 + x86-4.6)

1.Fixed examples\androidlcl\build_debug_apk.bat,now it can use JDK1.7 or JDK1.8 to Signing the APK.
---------------------------------------------------------
2015-07-25:
FPC: 3.1.1 trunk svn 31226 win32/arm-android/i386-android/jvm-android
Lazarus:1.5 trunk svn 49563
Android NDK: r10c (arm-linux-androideabi-4.6 + x86-4.6)

1.Update!
---------------------------------------------------------
2015-09-24:
FPC: 3.1.1 trunk svn 31778 win32/arm-android/i386-android/jvm-android
Lazarus:1.5 trunk svn 49869
Android NDK: r10e (arm-linux-androideabi-4.9 + x86-4.9)

1.Now FPC supports Android 6.0(SDK API=23).Thanks Yury Sidorov and Simonsays.
2.Update the batch file laz4android\build.bat,now it don't need adjust the path,
  just double click it.Thanks Chenyuchih.

=========================================================
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!
Title: Re: laz4android update!
Post by: jmpessoa on September 24, 2015, 07:33:43 pm

Hello TrueTom!

Thank you very much!
Title: Re: laz4android update!
Post by: truetom on October 02, 2015, 04:28:09 pm
Hello all,

New version laz4android 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-02
FPC: 3.1.1 trunk svn 31903 win32/arm-android/i386-android/jvm-android
Lazarus:1.5 trunk svn 49903
Android NDK: r10e (arm-linux-androideabi-4.9 + x86-4.9)

1.Fixed can't compiled customdrawn.lpk problem.
2.Fixed examples\androidlcl\sqlitejniandroid.pas,compiled ok.

=========================================================
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!
Title: Re: laz4android update!
Post by: Handoko on October 02, 2015, 07:55:23 pm
Thanks for the new release.

I tested this svn 49903 + LazToAPK 0.9.0.32 but unfortunately the generated i386-android code can't run on my Asus Zenfone 2 Intel Atom Quad Core smart phone. The generated APK file can be installed without problem. But if I run it, this error message will show up:
"Unfortunately, Project1 has stopped."

For your information, I'm using:
- NDK 4.1.2 (API 16)
- SDK 22.0.1
- WinXP sp 3


Things changed for generate the code:
- Target CPU Family: i386
- Library Path: ..\..\downloads\android-ndk-r10d\platforms\android-16\arch-x86\usr\lib
- Custom Options: -dANDROID -Xd

Are those settings above not correct for generate x86 code? Or is there anything I missed? Has anybody here ever succeed to create program for Intel-based Android?

Please help.
Title: Re: laz4android update!
Post by: DelphiFreak on October 02, 2015, 08:39:58 pm
Hello Handoko, I have never tried to build an i386 android app. And I think that laz4android is for arm only. So you are experimenting alone on this task. Let me know if you get it working.
Title: Re: laz4android update!
Post by: Handoko on October 03, 2015, 10:03:30 am
I'm alone.  :'(

Can you please help me or at least share more information where should I put the APP_ABI := x86 parameter?

I googled the web and found that to build i386 android app, we have to use APP_ABI := x86 parameter. Here are the sources:

https://software.intel.com/en-us/android/articles/android-ndk-for-intel-architecture
http://stackoverflow.com/questions/10098049/android-ndk-build-ignoring-app-abi-x86
http://www.codeproject.com/Articles/867762/Creating-an-x-and-ARM-APK-using-the-Intel-Compil

Here I quote the information so you don't have to read the whole articles:

Quote
In the NDK for Intel Architecture, use "APP_ABI := x86 " command line parameter. This generates the shared library under $PROJECT/libs/x86/ $NDK/ndk-build "APP_ABI := x86 "

Quote
Add target compile platform to it:
    APP_ABI := x86

Quote
Use the command below to build the application binary with Intel compiler for x86 architecture:
$ ndk-build APP_ABI=x86 V=1 NDK_TOOLCHAIN=x86-icc NDK_APP.local.cleaned_binaries=true

What I guess is laz4andoid actually generated the proper code for i386, but unfortunately it didn't pass the "APP_ABI := x86" parameter when calling NDK (or SDK), so the final code isn't generated correctly.

Can you please let me know in which file I should add the parameter?
Title: Re: laz4android update!
Post by: chenyuchih on October 03, 2015, 06:47:49 pm
To Handoko,

I can successfully compile for x86-Android and my project option setup are as follows,

Target OS:
Android

Target CPU family:
i386

Target processor:
(Default)

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.
Title: Re: laz4android update!
Post by: Handoko on October 03, 2015, 08:57:14 pm
Thanks chenyuchih, but unfortunately it's no help. The result is the same as my previous builds. The compilation and linking processes were smooth without error. And the APK file can be installed without problem. But if I run the app, it will say "Unfortunately, Project1 has stopped."

I have tried different compilation options and reinstalled laztoapk several times, but still can't find the correct way to make it works on my phone. I'm thinking it might be something wrong in my phone. But it seems working correctly, I can use it to browse Internet and running other apps. Or maybe because it is an Intel 64-bit so it required different option for the compilation process.
Title: Re: laz4android update!
Post by: chenyuchih on October 04, 2015, 03:47:13 am
Well, it's so bad that I helped nothing at all...

Actually, I just use Laz4Android for making shared object(*.so) files, not the whole complete apk. My GUI still write in Java and use JNI to call my native core functions. It works well for me under armeabi/x86 CPUs. I am not sure that why it's not okay for you because the basic concept should be the same.

Maybe you can give the following simple checks a try:

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.

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

Just for your reference.

Regards,
ChenYuChih
Title: Re: laz4android update!
Post by: Leledumbo on October 04, 2015, 11:55:27 am
Have you checked what `adb logcat` says? It's an essential debugging tool for Android.
Title: Re: laz4android update!
Post by: Handoko on October 04, 2015, 05:49:54 pm
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.

There is only 1 folder under the lib folder: armeabi. And it contain 1 file: liblclapp.so.

Have you checked what `adb logcat` says? It's an essential debugging tool for Android.

I can't use adb logcat. Because to test my apk file I have to run it directly on my phone. LazToApk is installed in a VirtualBox on my Linux computer, so I can't install Intel HAXM which is required by Android AVD to emulate Intel Atom x86. If I run the AVD to emulate x86, an error will show up and say "Please ensure Intel HAXM is properly installed and usable."

FYI, if I use the Laz4Android default settings to build ARM apk, the result can be run correctly on AVD ARM. But the ARM-version apk can't run on my phone. Below is the picture of ARM-version apk running AVD:
Title: Re: laz4android update!
Post by: Handoko on October 04, 2015, 05:58:17 pm
As suggested by chenyuchih, I have changed the Library Path and empty the Custom Options. For the Library Path, I have tried both android-9 and android-16.
Title: Re: laz4android update!
Post by: Handoko on October 04, 2015, 06:10:07 pm
Am I allowed to attach the apk files here? So somebody may check and test them on ARM/x86 phones. I only have one Intel-based phone.
Title: Re: laz4android update!
Post by: Leledumbo on October 04, 2015, 08:42:17 pm
There is only 1 folder under the lib folder: armeabi. And it contain 1 file: liblclapp.so.
This is certainly your problem. Your app is not built for x86 android, only arm.
I can't use adb logcat. Because to test my apk file I have to run it directly on my phone.
adb runs on both emulator and phone, run it on the phone (use -d instead of -e).
Title: Re: laz4android update!
Post by: Handoko on October 05, 2015, 01:24:54 pm
There is only 1 folder under the lib folder: armeabi. And it contain 1 file: liblclapp.so.
This is certainly your problem. Your app is not built for x86 android, only arm.

Okay, so now we found the problem. Can you please check my steps and see where I did it wrong?

The steps I used to produce the apk file:
1. Start VirtualBox and run the WinXP sp 3 machine
2. Empty project1 folder (remove all files created from previous attempts)
3. Start LazToApk and click the "manual" tab
4. Click "Step 1: Select/Create Project Folder" and point it to project1 folder
5. Set the password: 123456
6. Start Lazarus and open "project1android.lpi" in the project1 folder
7. Add "..\..\downloads\android-ndk-r10d\platforms\android-16\arch-x86\usr\lib" to the Library Path
8. Add "..\..\downloads\android-ndk-r10d\toolchains\x86-4.8\prebuilt\windows\lib\gcc\i686-linux-android\4.8" to the Library Path
9. Move the ARM item to the lowest in the search path
10. Set Config and Target to Android, i386, (Default)
11. Empty the Custom Options (remove -dANDROID -Xd -CpARMV6)
12. Press the "Save All" button to update all the changes in Lazarus
13. Close Lazarus, so now back to LazToApk
14. Click "Step 2: Build Project"
15. Wait until it said "145 lines compiled, 8.0 sec. 2 warning(s) issued. 10 hint(s) issued"
16. Click "Step 3: Create Android Key" and answer the questions
17. Click "Step 4: Create APK File"
18. The APK file is generated

Additional information you may need to know:
- Computer: Intel Core 2 Quad with Ubuntu 15.04 64-bit + MATE Desktop 1.8.2
- Phone: Asus Zenfone 2 Intel Atom Quad Core 64-bit with Android 5.0
- Oracle VirtualBox 4.3.26 with WinXP sp3 virtual machine
- LazToApk version 0.9.0.32
- Laz4Android version 1.5-49903-FPC3.1.1
- Lazarus version 1.5 SVN 49563 with FPC 3.1.1
- SDK Build-Tool version 22.0.1
- NDK-Platform version 4.1.2 (API 16)
- Java JDK version 1.8.0_51
- Project1 path: C:\laztoapk\projects\project1
- APK file and path: C:\laztoapk\projects\project1\android\bin\project1.apk
- Items in Library Path:
C:\laztoapk\downloads\android-ndk-r10d\platforms\android-16\arch-x86\usr\lib
C:\laztoapk\downloads\android-ndk-r10d\toolchains\x86-4.8\prebuilt\windows\lib\gcc\i686-linux-android\4.8
C:\laztoapk\downloads\android-ndk-r10d\platforms\android-16\arch-arm\usr\lib

I checked the steps again and again. I can't find anything wrong. Did I missed something?

I can't use adb logcat. Because to test my apk file I have to run it directly on my phone.
adb runs on both emulator and phone, run it on the phone (use -d instead of -e).

I'm not familiar with adb, did you mean the file adb_logcat.bat that can be found in the ...\projectpath\android? I run it, but it said "waiting for device" and then nothing happened even I plugged usb cable to my phone. I think it won't able to connect to my phone because it was running in VirtualBox. Actually it works, but only if I run in emulator mode.

Do you think I should have a real Windows environment to run LazToApk and the AVD (not using VirtualBox)? I own a licensed Windows, but I'm reluctant to make my computer multi-boot.
Title: Re: laz4android update!
Post by: jmpessoa on October 05, 2015, 02:44:28 pm
Hello Handoko!

1. There is a updated Laz4Android by TrueTom [some fixed!]

    ref. http://sourceforge.net/projects/laz4android/

Last update:2015-10-02
FPC: 3.1.1 trunk svn 31903 win32/arm-android/i386-android/jvm-android
Lazarus:1.5 trunk svn 49903
Android NDK: r10e (arm-linux-androideabi-4.9 + x86-4.9)

--->Fixed can't compiled customdrawn.lpk problem.
--->Fixed examples\androidlcl\sqlitejniandroid.pas,compiled ok.

2. Note:    -->> Android NDK: r10e (arm-linux-androideabi-4.9 + x86-4.9)

Title: Re: laz4android update!
Post by: Handoko on October 05, 2015, 08:45:31 pm
Thanks jmpessoa. Actually I've already used the latest update of Laz4Android you mentioned (Laz4Android version 1.5-49903). The thing I didn't pay attention was the NDK version 10e (x86-4.9).

So I downloaded Android NDK r10e, unzipped it to C:\laztoapk\downloads\android-ndk-r10e and set my Library Path to:
C:\laztoapk\downloads\android-ndk-r10e\platforms\android-16\arch-x86\usr\lib
C:\laztoapk\downloads\android-ndk-r10e\toolchains\x86-4.9\prebuilt\windows\lib\gcc\i686-linux-android\4.9

Everything seemed okay so I saved the project file, rebuild the project and create the APK again. Unfortunately the result was the same.

Also, as chenyuchih and Leledumbo said, I should have an x86 folder under ..\lib inside the apk file. I don't know why I only get an armeabi folder. After some attempts, I found that if I rename the folder before the generation of apk file I will get the file under the folder "x86". Even now I can generate fat binaries, the code still can't run on my phone. It can be installed, but an error message "Unfortunately, Project1 has stopped." will show up if I run it.
Title: Re: laz4android update!
Post by: truetom on October 17, 2015, 02:04:45 pm
Thanks jmpessoa. Actually I've already used the latest update of Laz4Android you mentioned (Laz4Android version 1.5-49903). The thing I didn't pay attention was the NDK version 10e (x86-4.9).

So I downloaded Android NDK r10e, unzipped it to C:\laztoapk\downloads\android-ndk-r10e and set my Library Path to:
C:\laztoapk\downloads\android-ndk-r10e\platforms\android-16\arch-x86\usr\lib
C:\laztoapk\downloads\android-ndk-r10e\toolchains\x86-4.9\prebuilt\windows\lib\gcc\i686-linux-android\4.9

Everything seemed okay so I saved the project file, rebuild the project and create the APK again. Unfortunately the result was the same.

Also, as chenyuchih and Leledumbo said, I should have an x86 folder under ..\lib inside the apk file. I don't know why I only get an armeabi folder. After some attempts, I found that if I rename the folder before the generation of apk file I will get the file under the folder "x86". Even now I can generate fat binaries, the code still can't run on my phone. It can be installed, but an error message "Unfortunately, Project1 has stopped." will show up if I run it.

Hello Handoko,

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.

Best regards!
Title: Re: laz4android update!
Post by: truetom on October 17, 2015, 02:06:13 pm
Hello all,

New version laz4android 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-17
FPC: 3.1.1 trunk svn 31903 win32/arm-android/i386-android/jvm-android
Lazarus:1.5 trunk svn 50093
Android NDK: r10e (arm-linux-androideabi-4.9 + x86-4.9)

1.Since the Lazarus trunk fixed some IDE bugs,we updated too.
  But the FPC same as the previous release of laz4android1.5-49903.

=========================================================
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!
Title: Re: laz4android update!
Post by: DelphiFreak on October 17, 2015, 10:12:51 pm
Hello Handoko,

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 (http://sourceforge.net/p/laztoapk/svn/HEAD/tree/trunk/source/apkmanagermain.pas#l948)
and search for "CopyNDKFilesToFPC" you will see that laztoapk copies only arm -stuff from the ndk folder into the  laz4android folder.

Sam
Title: Re: laz4android update!
Post by: DelphiFreak on October 17, 2015, 10:20:04 pm
Hello truetom,
thanks for you effort with laz4android.

Could you please add the package "CustomDrawn" to laz4android?

Thank you,
Sam
Title: Re: laz4android update!
Post by: Handoko 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.
Title: Re: laz4android update!
Post by: truetom 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!
Title: Re: laz4android update!
Post by: chenyuchih 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
Title: Re: laz4android update!
Post by: jmpessoa on October 30, 2015, 02:49:31 am

Hello chenyuchih!

recent 3 laz4android versions is for "Android NDK: r10e"  <<-----"e"
Title: Re: laz4android update!
Post by: chenyuchih 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)
Title: Re: laz4android update!
Post by: truetom 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!
Title: Re: laz4android update!
Post by: jmpessoa 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!

Title: Re: laz4android update!
Post by: chenyuchih 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
Title: Re: laz4android update!
Post by: truetom 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!
Title: Re: laz4android update!
Post by: truetom 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!
Title: Re: laz4android update!
Post by: DelphiFreak 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 (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
Title: Re: laz4android update!
Post by: truetom 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!
Title: Re: laz4android update!
Post by: truetom 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!
Title: Re: laz4android update!
Post by: jmpessoa 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
Title: Re: laz4android update!
Post by: jmpessoa 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!
Title: Re: laz4android update!
Post by: truetom on February 21, 2016, 01:27:57 pm
Hello all,

New version laz4android1.6.0-FPC3.0.0 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:2016-02-21
FPC: 3.0.0 (win32/arm-android/i386-android/jvm-android)
Lazarus:1.6.0
Android NDK: r10e (arm-linux-androideabi-4.9 + x86-4.9)

=========================================================
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!
Title: Re: laz4android update!
Post by: koloth on February 22, 2016, 10:36:45 am
Hi all,

I just installed laz4andoird on a windows 7 64bit machine,

It installed fine but i cannot start lazarus,

i keep getting a "There is no disk in the drive. Please insert a disk into drive \Device\Harddisk\DR1"

Any ideas?
Title: Re: laz4android update!
Post by: DelphiFreak on February 24, 2016, 06:17:40 am
Hi all,

did someone get an app running on Android 5.0 ?

I tried to do it but the application does not start.

Sam

Here is my apk-file: https://www.dropbox.com/s/88msjcm278xbgwe/project2.apk?dl=0 (https://www.dropbox.com/s/88msjcm278xbgwe/project2.apk?dl=0)
Title: Re: laz4android update!
Post by: DelphiFreak on February 26, 2016, 08:38:56 pm
Hi,
I just want to let you know ...
I played around for some time now to see if I get an app running on Android 5, but had no success.
After removing all CustomDrawn components and units from my example project, it worked.

So there must be a problem with CustomDrawn and Android 5.

Sam
Title: Re: laz4android update!
Post by: tomkemp on February 26, 2016, 09:13:54 pm
@DelphiFreak thanks for an update. I was mansion about that issue around 2 months ago. Now after your post it is time to find where is the problem.

Maybe somebody has proper solution for that ?
Title: Re: laz4android update!
Post by: Ñuño_Martínez on March 17, 2016, 06:02:16 pm
Nice to see the project is still alive.

I must find time to test this and enter in the Android world.  Cordova looks too much big and JavaScript isn't a nice language.  Sart Mobile Studio seems nice since it allows both mobile and web apps, but I didn't like how it works when I tested it (didn't test version 2.0 though).
TinyPortal © 2005-2018