Recent

Author Topic: laz4android update!  (Read 33977 times)

chenyuchih

  • Jr. Member
  • **
  • Posts: 81
Re: laz4android update!
« Reply #15 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.

Handoko

  • Hero Member
  • *****
  • Posts: 5154
  • My goal: build my own game engine using Lazarus
Re: laz4android update!
« Reply #16 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.

chenyuchih

  • Jr. Member
  • **
  • Posts: 81
Re: laz4android update!
« Reply #17 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

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: laz4android update!
« Reply #18 on: October 04, 2015, 11:55:27 am »
Have you checked what `adb logcat` says? It's an essential debugging tool for Android.

Handoko

  • Hero Member
  • *****
  • Posts: 5154
  • My goal: build my own game engine using Lazarus
Re: laz4android update!
« Reply #19 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:
« Last Edit: October 04, 2015, 05:53:39 pm by Handoko »

Handoko

  • Hero Member
  • *****
  • Posts: 5154
  • My goal: build my own game engine using Lazarus
Re: laz4android update!
« Reply #20 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.

Handoko

  • Hero Member
  • *****
  • Posts: 5154
  • My goal: build my own game engine using Lazarus
Re: laz4android update!
« Reply #21 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.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: laz4android update!
« Reply #22 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).

Handoko

  • Hero Member
  • *****
  • Posts: 5154
  • My goal: build my own game engine using Lazarus
Re: laz4android update!
« Reply #23 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.

jmpessoa

  • Hero Member
  • *****
  • Posts: 2301
Re: laz4android update!
« Reply #24 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)

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

Handoko

  • Hero Member
  • *****
  • Posts: 5154
  • My goal: build my own game engine using Lazarus
Re: laz4android update!
« Reply #25 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.

truetom

  • Jr. Member
  • **
  • Posts: 73
    • http://sourceforge.net/projects/laz4android/
Re: laz4android update!
« Reply #26 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!
laz4android : a Lazarus for Android Package.
http://sourceforge.net/projects/laz4android/

truetom

  • Jr. Member
  • **
  • Posts: 73
    • http://sourceforge.net/projects/laz4android/
Re: laz4android update!
« Reply #27 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!
laz4android : a Lazarus for Android Package.
http://sourceforge.net/projects/laz4android/

DelphiFreak

  • Sr. Member
  • ****
  • Posts: 255
    • Fresh sound.
Re: laz4android update!
« Reply #28 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
and search for "CopyNDKFilesToFPC" you will see that laztoapk copies only arm -stuff from the ndk folder into the  laz4android folder.

Sam
« Last Edit: October 17, 2015, 10:17:36 pm by DelphiFreak »
Linux Mint 20.3, Lazarus 2.3, Windows 10, Delphi 10.3 Rio, Delphi 11.1 Alexandria

DelphiFreak

  • Sr. Member
  • ****
  • Posts: 255
    • Fresh sound.
Re: laz4android update!
« Reply #29 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
Linux Mint 20.3, Lazarus 2.3, Windows 10, Delphi 10.3 Rio, Delphi 11.1 Alexandria

 

TinyPortal © 2005-2018