Recent

Author Topic: Lazarus 1.8.0RC5 + LAMW  (Read 19823 times)

Handoko

  • Hero Member
  • *****
  • Posts: 5153
  • My goal: build my own game engine using Lazarus
Lazarus 1.8.0RC5 + LAMW
« on: October 31, 2017, 06:29:05 pm »
-edit-:
This installation tutorial no longer works with the latest version of NDK/SDK.
Please use this new installation guide: http://forum.lazarus.freepascal.org/index.php?topic=42527




Hello, I'm back for Android programming.
Today I tried to install LAMW on Lazarus 1.8.0RC5 and it succeed! :D

So I write this tutorial, maybe someone will find it useful.

Before You Start

Remember, you should do proper backup before you start.

Linux users can use this script:
https://github.com/jmpessoa/lazandroidmodulewizard/tree/master/docs/linux
I tested the script but I prefer my way to install because I don't want multiple versions of Lazarus/FPC put on my computer.

More documentations can be found here:
https://github.com/jmpessoa/lazandroidmodulewizard/tree/master/docs

=== Environment ===

This tutorial should work on other environments with no or some changes but I only tested on:
- Ubuntu Mate 17.10 64-bit
- Intel x64
- Lazarus 1.8.0RC5 FPC 3.0.4 x86_64-linux-gtk2


This tutorial assume you're using NDK revision 11c. If you're not using this version, you have to change all the texts "4.9" below accordingly.

=== Install Necessary Libraries & Tools ===

On my system I only need to use Terminal to install these:
01. sudo apt-get install subversion
02. sudo apt-get install android-tools-adb ant openjdk-8-jdk


I saw on other tutorials, they said you may also need to install:
03. sudo apt-get install freeglut3 freeglut3-dev libwxgtk3.0-0v5
04. sudo apt-get install libgtk2-gladexml-perl libgtk2.0-bin libgtk2.0-cil
05. sudo apt-get install make build-essential libncurses5-dev libtinfo-dev
06. sudo apt-get install libcairo2-dev libpango1.0-dev libatk1.0-dev libghc-x11-dev
07. sudo apt-get install libgtk2.0-dev libgdk-pixbuf2.0-dev libgpm-dev fakeroot


=== Prepare Android NDK & SDK ===

08. mkdir ~/Android
09. Extract Android NDK https://developer.android.com/ndk/downloads to ~/Android
10. ln -sf ~/Android/android-ndk-r11c ~/Android/ndk
11. cd /usr/bin
12. sudo ln -sf ~/Android/ndk/toolchains/arm-linux-androideabi-
4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-as arm-linux-androideabi-as
13. sudo ln -sf ~/Android/ndk/toolchains/arm-linux-androideabi-
4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld arm-linux-androideabi-ld
14. sudo ln -sf /usr/bin/arm-linux-androideabi-as arm-linux-as
15. sudo ln -sf /usr/bin/arm-linux-androideabi-ld arm-linux-ld
16. Extract Android SDK https://developer.android.com/sdk to ~/Android
17. ln -sf ~/Android/android-sdk-linux ~/Android/sdk
18. Install SDK Packages by running ~/Android/sdk/tools/android

Note:
The "android" tool has been deprecated by newer version of Android SDK, read more:
http://forum.lazarus.freepascal.org/index.php/topic,38777.msg281267.html#msg281267

19. Use a text editor to open ~/.bashrc and add this text below:
export PATH=$PATH:~/Android/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin

Note for #18:
I only enable Android 4.4.2 (API 19), you can try other version if you want.

=== Cross Compile Android ARM ===

20. cd /usr/share/fpcsrc/3.0.4
21. sudo make clean crossall OS_TARGET=android CPU_TARGET=arm
22. sudo make crossinstall OS_TARGET=android CPU_TARGET=arm INSTALL_PREFIX=/usr
23. sudo ln -sf /usr/lib/fpc/3.0.4/ppcrossarm /usr/bin/ppcrossarm
24. sudo ln -sf /usr/bin/ppcrossarm /usr/bin/ppcarm
25. Add these blue lines below to /etc/fpc.cfg:

#IFDEF ANDROID
#IFDEF CPUARM
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/*
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/rtl
#ENDIF
#ENDIF


=== Cross Compile Android i386 ===

You can skip this section if you do not need to target Android Intel CPU.

26. cd /usr/bin
27. sudo ln -sf ~/Android/ndk/toolchains/x86-
4.9/prebuilt/linux-x86_64/bin/i686-linux-android-as i686-linux-android-as
28. sudo ln -sf ~/Android/ndk/toolchains/x86-
4.9/prebuilt/linux-x86_64/bin/i686-linux-android-ld i686-linux-android-ld
29. sudo ln -sf /usr/bin/i686-linux-android-as i686-linux-as
30. sudo ln -sf /usr/bin/i686-linux-android-ld i686-linux-ld
31. cd /usr/share/fpcsrc/3.0.4
32. sudo make clean crossall OS_TARGET=android CPU_TARGET=i386
33. sudo make crossinstall OS_TARGET=android CPU_TARGET=i386 INSTALL_PREFIX=/usr
34. sudo ln -sf /usr/lib/fpc/3.0.4/ppcross386 /usr/bin/ppcross386


=== Lazarus Android Module Wizard Installation ===

35. cd ~/Android
36. svn co https://github.com/jmpessoa/lazandroidmodulewizard.git
37. ln -sf ~/Android/lazandroidmodulewizard.git ~/Android/lazandroidmodulewizard
38. Start Lazarus IDE
39. menu > Package > Open Package (.lpk) > "tfpandroidbride_pack.lpk"
40. Compile, then and Use > Install
41. menu > Package > Open Package (.lpk) > "lazandroidwizardpack.lpk"
42. Compile, then and Use > Install
43. menu > Package > Open Package (.lpk) > "amw_ide_tools.lpk"
44. Compile, then and Use > Install
45. menu > Tools > [Lamw] Android Module Wizard > Paths Settings: [Jdk, Sdk, Ndk, ...]:

Path to Java JDK: /usr/lib/jvm/java-8-openjdk-amd64
Path to Ant bin: /usr/bin
Path to Android SDK: /home/[handoko]/Android/sdk
Path to Android NDK: /home/[handoko]/Android/ndk
NDK Version: 11c


Note for #39, #41, #43:
Those lpk files can be found inside "lazandroidmodulewizard.git" folder.

Note for #45:
You should change the name "[handoko]" to the user name on your computer.

=== How To Start A LAMW Project ===

Lazarus main menu > New > Project > choose one of these:
- Android [NoGUI] JNI Module [Lamw]
- Android [GUI] JNI Module [Lamw]
- Android Console App [Lamw]

The components you can use in LAMW Projects are limited on the those inside "Android Bridges" and "Android Bridges Extras" tabs only.

The pascal source code will be saved in: [projectname]\jni.
The compiled binary (*.so) will be saved in: [projectname]\libs (inside armeabi or x86)
The Android binary (*.apk) will be saved in: [projectname]\bin

To produce the apk file (from *.so), you need to run "build-debug.sh" or "build-release.sh", which can be found on the project folder. Alternatively, you can you use LATE (Lazarus Apk Expert Tools):
Lazarus main menu > Tools > [Lamw] Android Module Wizard > LATE: Apk Expert Tools [Build, Install, ...]


Below I provided an apk sample compiled to target ARMV7A, it should run correctly on Intel CPU too. It shows some moving rectangles drawn using OpenGL ES 2 (jCanvasES2). The source code can be downloaded here:
http://forum.lazarus.freepascal.org/index.php/topic,38777.msg264878.html#msg264878

Note:
LATE does not work correctly on Linux.

=== Setting For Android i386 Target ===

You need to make some changes if you want to target on Android i386.

46. Lazarus main menu > Project > Project Options > Paths > Libraries (-Fl):
/home/[handoko]/Android/ndk/platforms/android-21/arch-x86/usr/lib/
47. Lazarus main menu > Project > Project Options > Paths > Target file name (-o):
../libs/x86/libcontrols
48. Lazarus main menu > Project > Project Options > Config and Target > Target file name (-P):
i386
49. Lazarus main menu > Project > Project Options > Custom Options:
-Xd -XPi686-linux-android- -FD/home/[handoko]/Android/ndk/toolchains/x86-4.9/prebuilt/linux-x86_64/bin

Note:
To make fat binary (https://en.wikipedia.org/wiki/Fat_binary), compile as much target as you want before running that build debug/release script. To cancel fat binary producing, delete all things inside [projectname]\libs folder before compiling.


---Edited---
04-Nov-17:  Cross Compile Android i386 section, sample-apk.zip and screenshot.
31-Mar-18:  Step #18 - info about depreciation of "android" tool.
« Last Edit: September 12, 2018, 03:42:50 am by Handoko »

mai

  • Full Member
  • ***
  • Posts: 133
  • truther
Re: Lazarus 1.8.0RC5 + LAMW
« Reply #1 on: October 31, 2017, 08:13:36 pm »
what the heck is LAMW?

Handoko

  • Hero Member
  • *****
  • Posts: 5153
  • My goal: build my own game engine using Lazarus
Re: Lazarus 1.8.0RC5 + LAMW
« Reply #2 on: October 31, 2017, 08:21:37 pm »
LAMW (Lazarus Android Module Wizard) is one of the way to create Android app using Lazarus. So far, there are several ways to do Android programming in Lazarus, LAMW is the easiest I think.

There other options are:

- FPC JVM
http://wiki.lazarus.freepascal.org/FPC_JVM_Android_Development

- Laz4Android
This package uses Custom Drawn Interface.
https://sourceforge.net/projects/laz4android/

- LazToApk
This tool will help you automatically download Laz4Android, Android SDK & NDK, configure and perform cross compiling.
https://sourceforge.net/projects/laztoapk/

- LazSDL2Design Package
Similar to LAMW, it has its own Form Designer and components.
http://forum.lazarus.freepascal.org/index.php/topic,33008.0.html

jmpessoa

  • Hero Member
  • *****
  • Posts: 2301
Re: Lazarus 1.8.0RC5 + LAMW
« Reply #3 on: October 31, 2017, 11:16:46 pm »
Quote
So I write this tutorial, maybe someone will find it useful.

Hello Handoko!
Great! I wil add your tutorial to LAMW repo...

Laz4Android + LAMW  is good, too!

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

Mike.Cornflake

  • Hero Member
  • *****
  • Posts: 1260
Lazarus Trunk/FPC Trunk on Windows [7, 10]
  Have you tried searching this forum or the wiki?:   http://wiki.lazarus.freepascal.org/Alternative_Main_Page
  BOOKS! (Free and otherwise): http://wiki.lazarus.freepascal.org/Pascal_and_Lazarus_Books_and_Magazines

mai

  • Full Member
  • ***
  • Posts: 133
  • truther
Re: Lazarus 1.8.0RC5 + LAMW
« Reply #5 on: November 01, 2017, 11:38:35 am »
what the heck is LAMW?

http://wiki.lazarus.freepascal.org/LAMW

But what the heck does a complete Adroid app then look like? Most important screenshot is missing from your link !

DonAlfredo

  • Hero Member
  • *****
  • Posts: 1739
Re: Lazarus 1.8.0RC5 + LAMW
« Reply #6 on: November 01, 2017, 11:55:16 am »
For your info, I have included two screenshots of a simple Android app that I am currently working at.

It scans barcodes and stored them in a mORMot database (local and remote).

jmpessoa

  • Hero Member
  • *****
  • Posts: 2301
Re: Lazarus 1.8.0RC5 + LAMW
« Reply #7 on: November 02, 2017, 01:00:55 am »
Quote
But what the heck does a complete Adroid app then look like?

LAMW "maps" allmost all native Android GUI controls APIs.
So, the "look" will depend on the design skills...
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

Handoko

  • Hero Member
  • *****
  • Posts: 5153
  • My goal: build my own game engine using Lazarus
Re: Lazarus 1.8.0RC5 + LAMW
« Reply #8 on: November 03, 2017, 09:30:12 pm »
I added Cross Compile Android i386 section,  sample-apk.zip and screenshot on the first post.

jmpessoa

  • Hero Member
  • *****
  • Posts: 2301
Re: Lazarus 1.8.0RC5 + LAMW
« Reply #9 on: November 03, 2017, 09:40:33 pm »
Ok. I will update github repo...

[Can you post hole project, so I will put in demos folder!]

Thank you!

« Last Edit: November 03, 2017, 09:43:51 pm by jmpessoa »
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

Handoko

  • Hero Member
  • *****
  • Posts: 5153
  • My goal: build my own game engine using Lazarus
Re: Lazarus 1.8.0RC5 + LAMW
« Reply #10 on: November 04, 2017, 03:42:07 pm »
I modified the code a bit, adding more rectangles and change the background color when jButton2 clicked.

I wrote the code originally to test jCanvasES2 can or not to handle deep test (glEnable(GL_DEPTH_TEST)) because I found some things not working correctly.

The big rectangle will slowly move to the back, it starts at its z position above the small rectangles and when it reached the middle of the screen, the big rectangles will be behind the small rectangles.

I don't need this code anymore. It is free, I put it in CC0. You can do anything you like with the code.

Code: Pascal  [Select][+][-]
  1. {Hint: save all files to location: /home/handoko/Projects/Project Software/Android Test/glTest1/jni }
  2. unit unit1;
  3.  
  4. {$mode delphi}
  5.  
  6. interface
  7.  
  8. uses
  9.   Classes, SysUtils, AndroidWidget, Laz_And_Controls, Laz_And_GLESv2_Canvas,
  10.   Laz_And_GLESv2_Canvas_h;
  11.  
  12. type
  13.  
  14.   { TAndroidModule1 }
  15.  
  16.   TAndroidModule1 = class(jForm)
  17.     jButton1: jButton;
  18.     jButton2: jButton;
  19.     jButton3: jButton;
  20.     jCanvasES2_1: jCanvasES2;
  21.     jTimer1: jTimer;
  22.     procedure AndroidModule1JNIPrompt(Sender: TObject);
  23.     procedure jButton1Click(Sender: TObject);
  24.     procedure jButton2Click(Sender: TObject);
  25.     procedure jButton3Click(Sender: TObject);
  26.     procedure jCanvasES2_1GLCreate(Sender: TObject);
  27.     procedure jCanvasES2_1GLDown(Sender: TObject; Touch: TMouch);
  28.     procedure jCanvasES2_1GLDraw(Sender: TObject);
  29.     procedure jTimer1Timer(Sender: TObject);
  30.   private
  31.     ResHalfX, ResHalfY, ResHalfZ, ResScaleX, ResScaleY, ResScaleZ: Single;
  32.     ColorFill, ColorBorder: TRGBA;
  33.     procedure SetColorBorderRGBA(const R, G, B: single; const A: Single = 1);
  34.     procedure SetColorFillRGBA(const R, G, B: single; const A: Single = 1);
  35.     procedure DrawRectHV(const X, Y, sX, sY, W: Single; const Z: Single = 0);
  36.   end;
  37.  
  38. var
  39.   AndroidModule1: TAndroidModule1;
  40.  
  41. implementation
  42.  
  43. {$R *.lfm}
  44.  
  45. const
  46.   Total               = 100;
  47.   ButtonClicked: Byte = 1;
  48.  
  49. var
  50.   Xpos:   array[1..Total] of Single;
  51.   Ypos:   array[1..Total] of Single;
  52.   Xspeed: array[1..Total] of Single;
  53.   Yspeed: array[1..Total] of Single;
  54.  
  55. { TAndroidModule1 }
  56.  
  57. procedure TAndroidModule1.AndroidModule1JNIPrompt(Sender: TObject);
  58. const
  59.   SizeX = 910;
  60.   SizeY = 1358;
  61.   SizeZ = 1000;
  62. var
  63.   i: Integer;
  64. begin
  65.   // Setup screen
  66.   SetScreenOrientationStyle(ssPortrait);
  67.   ResHalfX := SizeX * 0.5;
  68.   ResHalfY := SizeY * 0.5;
  69.   ResHalfZ := SizeZ * 0.5;
  70.   ResScaleX := 1/ResHalfX;
  71.   ResScaleY := 1/ResHalfY;
  72.   ResScaleZ := 1/ResHalfZ;
  73.   jCanvasES2_1.Screen_Setup(jCanvasES2_1.Width, jCanvasES2_1.Height, xp2D);
  74.   SetColorBorderRGBA(0, 0, 0);
  75.   // Setup rectangles
  76.   for i := 1 to Total do begin
  77.     Xpos[i] := Random(770)-385;
  78.     Ypos[i] := Random(1000)-500;
  79.     Xspeed[i] := Random(7)-3;
  80.     Yspeed[i] := Random(7)-3;
  81.     if (Xspeed[i] = 0) then Xspeed[i] := 1;
  82.     if (Yspeed[i] = 0) then Yspeed[i] := 1;
  83.     Xspeed[i] := 3;
  84.   end;
  85.   // Start timer
  86.   jTimer1.Enabled := True;
  87. end;
  88.  
  89. procedure TAndroidModule1.jButton1Click(Sender: TObject);
  90. begin
  91.   ButtonClicked := 1;
  92. end;
  93.  
  94. procedure TAndroidModule1.jButton2Click(Sender: TObject);
  95. begin
  96.   ButtonClicked := 2;
  97. end;
  98.  
  99. procedure TAndroidModule1.jButton3Click(Sender: TObject);
  100. begin
  101.   ButtonClicked := 3;
  102. end;
  103.  
  104. procedure TAndroidModule1.jCanvasES2_1GLCreate(Sender: TObject);
  105. begin
  106. //  jCanvasES2_1.Texture_Load_All;
  107.   jCanvasES2_1.Shader_Compile('simon_Vert', 'simon_Frag');
  108.   jCanvasES2_1.Shader_Link;
  109. end;
  110.  
  111. procedure TAndroidModule1.jCanvasES2_1GLDown(Sender: TObject; Touch: TMouch);
  112. begin
  113.   // Show touched X, Y
  114.   ShowMessage(FormatFloat('0.00', Touch.Pt.X)+', '+FormatFloat('0.00', Touch.Pt.Y));
  115. end;
  116.  
  117. procedure TAndroidModule1.jCanvasES2_1GLDraw(Sender: TObject);
  118. const
  119.   Z: Integer = -500;
  120. var
  121.   XYs: TXYs;
  122.   i:   Integer;
  123. begin
  124.   glClear(GL_DEPTH_BUFFER_BIT);
  125.   glEnable(GL_DEPTH_TEST);
  126.   glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  127.   glEnable(GL_BLEND);
  128.   jCanvasES2_1.MVP:= cID4x4;
  129.   jCanvasES2_1.SetMVP(jCanvasES2_1.MVP);
  130.  
  131.   XYs.Cnt := 4;
  132.   XYs.Pt[0] := _XY(-1, -1);
  133.   XYs.Pt[1] := _XY(-1,  1);
  134.   XYs.Pt[2] := _XY( 1,  1);
  135.   XYs.Pt[3] := _XY( 1, -1);
  136.   jCanvasES2_1.DrawPolyFill(XYs, 0.9, _RGBA(0.5, 1, 0.8, 1), _RGBA(1, 0, 0, 1), 0.05);
  137.  
  138.   XYs.Pt[0] := _XY(-435*ResScaleX, -550*ResScaleY);
  139.   XYs.Pt[1] := _XY(-435*ResScaleX,  550*ResScaleY);
  140.   XYs.Pt[2] := _XY( 435*ResScaleX,  550*ResScaleY);
  141.   XYs.Pt[3] := _XY( 435*ResScaleX, -550*ResScaleY);
  142.   if (ButtonClicked = 2) then
  143.     jCanvasES2_1.DrawPolyFill(XYs, 0.8, _RGBA(0.5, 0.2, 1, 1), _RGBA(1, 0, 0, 1), 0)
  144.   else
  145.     jCanvasES2_1.DrawPolyFill(XYs, 0.8, _RGBA(0, 0, 0, 1), _RGBA(1, 0, 0, 1), 0);
  146.  
  147.   Inc(Z);
  148.   If (Z > 500) then Z := -500;
  149.   SetColorFillRGBA(0, 1, 0);
  150.   DrawRectHV(-100, Z, 200, 200, 30, Z);
  151.  
  152.   SetColorFillRGBA(1, 1, 0);
  153.   for i := 1 to Total do begin
  154.     Xpos[i] := Xpos[i] + Xspeed[i];
  155.     Ypos[i] := Ypos[i] + Yspeed[i];
  156.     if (Xpos[i] < -400) and (Xspeed[i] <= 0) then Xspeed[i] := 3;
  157.     if (Xpos[i] >  370) and (Xspeed[i] >= 0) then Xspeed[i] := -3;
  158.     if (Ypos[i] < -600) and (Yspeed[i] <= 0) then Yspeed[i] := Random(3)+1;
  159.     if (Ypos[i] >  550) and (Yspeed[i] >= 0) then Yspeed[i] := Random(3)-4;
  160.     case ButtonClicked of
  161.       1: begin
  162.            SetColorFillRGBA(1, 1, 0);
  163.            DrawRectHV(Xpos[i], Ypos[i], 50, 50, 5, 50);
  164.          end;
  165.       2: begin
  166.            SetColorFillRGBA(0, 0, 0);
  167.            DrawRectHV(Xpos[i], Ypos[i], 50, 50, 5, 50);
  168.          end;
  169.       3: begin
  170.           SetColorFillRGBA(0, 0, 1);
  171.           DrawRectHV(Xpos[i], Ypos[i], 50, 50, 5, -100);
  172.           end;
  173.     end;
  174.   end;
  175. end;
  176.  
  177. procedure TAndroidModule1.jTimer1Timer(Sender: TObject);
  178. begin
  179.   jCanvasES2_1.Refresh;
  180. end;
  181.  
  182. procedure TAndroidModule1.SetColorBorderRGBA(const R, G, B: single;
  183.   const A: Single);
  184. begin
  185.   ColorBorder.R := R;
  186.   ColorBorder.G := G;
  187.   ColorBorder.B := B;
  188.   ColorBorder.A := A;
  189. end;
  190.  
  191. procedure TAndroidModule1.SetColorFillRGBA(const R, G, B: single;
  192.   const A: Single);
  193. begin
  194.   ColorFill.R := R;
  195.   ColorFill.G := G;
  196.   ColorFill.B := B;
  197.   ColorFill.A := A;
  198. end;
  199.  
  200. procedure TAndroidModule1.DrawRectHV(const X, Y, sX, sY, W: Single;
  201.   const Z: Single);
  202. var
  203.   X1, Y1, X2, Y2, W2: Single;
  204.   X1small, Y1small, X2small, Y2small, X1big, Y1big, X2big, Y2big: Single;
  205.   XYs: TXYs;
  206. begin
  207.   // Make sure (X1, Y1) is the bottom leftmost, to produce clockwise winding
  208.   if (sX >= 0) and (sY >= 0) then begin
  209.     X1 := X;
  210.     Y1 := Y;
  211.     X2 := X+sX;
  212.     Y2 := Y+sY;
  213.   end else
  214.     if (sX < 0) and (sY >= 0) then begin
  215.       X1 := X+sX;
  216.       Y1 := Y;
  217.       X2 := X;
  218.       Y2 := Y+sY;
  219.     end else
  220.       if (sX < 0) and (sY < 0) then begin
  221.         X1 := X+sX;
  222.         Y1 := Y+sY;
  223.         X2 := X;
  224.         Y2 := Y;
  225.       end else
  226.         if (sX >= 0) and (sY < 0) then begin
  227.           X1 := X;
  228.           Y1 := Y+sY;
  229.           X2 := X+sX;
  230.           Y2 := Y;
  231.         end;
  232.   // Map the points
  233.   W2 := W * 0.5;
  234.   X1small := (X1-W2) * ResScaleX;
  235.   Y1small := (Y1-W2) * ResScaleY;
  236.   X2small := (X2-W2) * ResScaleX;
  237.   Y2small := (Y2-W2) * ResScaleY;
  238.   X1big := (X1+W2) * ResScaleX;
  239.   Y1big := (Y1+W2) * ResScaleY;
  240.   X2big := (X2+W2) * ResScaleX;
  241.   Y2big := (Y2+W2) * ResScaleY;
  242.   XYs.Cnt := 10;
  243.   XYs.Pt[0].X := X1big;   XYs.Pt[0].Y := Y1big;
  244.   XYs.Pt[1].X := X2small; XYs.Pt[1].Y := Y1big;
  245.   XYs.Pt[2].X := X2small; XYs.Pt[2].Y := Y2small;
  246.   XYs.Pt[3].X := X2big;   XYs.Pt[3].Y := Y2big;
  247.   XYs.Pt[4].X := X2big;   XYs.Pt[4].Y := Y1small;
  248.   XYs.Pt[5].X := X1small; XYs.Pt[5].Y := Y1small;
  249.   XYs.Pt[6].X := X1small; XYs.Pt[6].Y := Y2big;
  250.   XYs.Pt[7].X := X2big;   XYs.Pt[7].Y := Y2big;
  251.   XYs.Pt[8].X := X2small; XYs.Pt[8].Y := Y2small;
  252.   XYs.Pt[9].X := X1big;   XYs.Pt[9].Y := Y2small;
  253.   // Draw it
  254.   jCanvasES2_1.DrawPolyFill(XYs, Z*ResScaleZ, ColorFill, ColorBorder, 0);
  255. end;
  256.  
  257. end.

Although I set the compiling parameters to target ARM devices, it still working correctly on my Intel-based mobile phone. Some maybe interested to know, I done a massive benchmark on my Intel-based phone using this rectangle code (with some modifications) and this is the result:

Target CPU (-P)    Method 1     Method 2
i386               980 frames   984 frames
arm                740 frames   739 frames


It is 20-30% slower running ARM codes on Intel machine.

Below are the settings I used to compile the code:
Quote
NDK version: r11c
NDK API level: 21 (Android 5.0, 5.1)
SDK: Android 4.4.2 - API 19
Java: java-8-openjdk-amd64
Path to Workspace: /home/handoko/Projects/Project Software/Android Test
Libraries (-Fl): /home/handoko/Android/ndk/platforms/android-21/arch-arm/usr/lib/
Target file name (-o): ../libs/armeabi/libcontrols
Target OS (-T): Android
Target CPU family (-T): arm
Custom options: -Xd -CfSoft -CpARMV7A -XParm-linux-androideabi- -FD/home/handoko/Android/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86/bin
« Last Edit: November 04, 2017, 07:52:41 pm by Handoko »

WayneSherman

  • Full Member
  • ***
  • Posts: 243
Re: Lazarus 1.8.0RC5 + LAMW
« Reply #11 on: March 31, 2018, 03:34:24 am »
Thanks for the installation help.

Regarding step #18:
18. Install SDK Packages by running ~/Android/sdk/tools/android
Note for #18:  I only enable Android 4.4.2 (API 19), you can try other version if you want.

The "android" tool has been deprecated and instead this tool should be used:
~/android/sdk/android/bin/sdkmanager

BTW, I used this to get a list with full package names yet compact (from here):
./sdkmanager --list --verbose | grep -vP "^Info:|^\s|^$|^done$"

I have attached the list of packages.  Which packages do I need to install at a minimum? (platforms;android-19 ?)

Thank you.
« Last Edit: March 31, 2018, 04:08:13 am by Wayne »

Handoko

  • Hero Member
  • *****
  • Posts: 5153
  • My goal: build my own game engine using Lazarus
Re: Lazarus 1.8.0RC5 + LAMW
« Reply #12 on: March 31, 2018, 05:22:57 am »
I admit I'm lazy when things already work so I haven't updated my Android SDK/NDK for a long time.

Thank you for the information about the depreciation of "android" tool. I have added some note on the step #18.

jmpessoa

  • Hero Member
  • *****
  • Posts: 2301
Re: Lazarus 1.8.0RC5 + LAMW
« Reply #13 on: March 31, 2018, 05:36:13 am »

Quote
Which packages do I need to install at a minimum? (platforms;android-19 ?)

What about "Android-25" + "Buil-Tools" 25.0.3 + Gradle 4.1....  so, you can stay prepared to incoming LAMW 0.8 !!
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

WayneSherman

  • Full Member
  • ***
  • Posts: 243
Re: Lazarus 1.8.0RC5 + LAMW
« Reply #14 on: March 31, 2018, 06:45:50 am »
What about "Android-25" + "Buil-Tools" 25.0.3 + Gradle 4.1....  so, you can stay prepared to incoming LAMW 0.8 !!

Based on the list provided by "sdkmanager", installation would be like this:
./sdkmanager "platforms;android-25" "build-tools;25.0.3"

Some questions please:
1) sdkmanager doesn't list anything with "Gradle" in the name.  Is that installed with the build-tools package?
2) If I install android-25, will my compiled app still work on earlier versions of Android?
3) Does LAMW 0.7 work with android-25?

Thanks for your assistance
« Last Edit: March 31, 2018, 07:05:50 am by Wayne »

 

TinyPortal © 2005-2018