Recent

Author Topic: LAMW error with Android NDK revision 22  (Read 11562 times)

WayneSherman

  • Full Member
  • ***
  • Posts: 243
Re: LAMW error with Android NDK revision 22
« Reply #15 on: June 12, 2021, 02:11:59 am »
RE: Set paths using LAMW Paths/Settings dialog box not working

Around here I can't fix this error.....my LAMW installation works normally in Win64...

To get it to happen, I have to start Lazarus with both paths empty (delete PathToAndroidSDK and PathToAndroidNDK from LAMW.ini).
Then when running Lazarus, if it opens an existing project, don't set the SDK or NDK paths when it asks. (cancel all the "Path Missing" pop-ups)

Then go to the Tools | LAMW Android Module Wizard | Paths Settings and try to set the NDK and SDK paths using the "..." buttons.
« Last Edit: June 12, 2021, 02:16:39 am by WayneSherman »

jmpessoa

  • Hero Member
  • *****
  • Posts: 2297
Re: LAMW error with Android NDK revision 22
« Reply #16 on: June 12, 2021, 02:36:47 am »
Quote
But when opening an existing LAMW project, there is no way to change the NDK API level so even though the Target SDK is set to 29, the API level 22 libraries are still being used...

Yes,  this is an old issue....  and need be improved.... [at the moment, the Api 22 is used by default
to alleviate incompatibilities with old devices using Android 4.x and 5.x]

What is relevant is SDK api target, not NDK api target ....
« Last Edit: June 12, 2021, 02:43:27 am by jmpessoa »
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

WayneSherman

  • Full Member
  • ***
  • Posts: 243
Re: LAMW error with Android NDK revision 22
« Reply #17 on: June 12, 2021, 03:12:35 am »
But the $HOME/android/fpc-lazarus/cross/bin folder is required or it doesn't build:
lazaruspackageintf.pas(104,0) Error: Assembler arm-linux-androideabi-as not found, switching to external assembling
So it appears that it is not using the toolchain from the NDK and using the one that FPCUPdeluxe installed instead.

Did more testing.  If I remove access to the FPCUPdeluxe build tools, I get compile errors for missing tools.  But I can get it to build again if I add the correct NDK build tool path.

So it looks like LAMW is using the wrong toolchain folder in the custom compile options (Project | Project Options | Compiler Options | Custom Options)

LAMW uses this:
Code: Text  [Select][+][-]
  1. -FD/home/wsherman/android/sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin
which give error:
lazaruspackageintf.pas(104,0) Error: Assembler arm-linux-androideabi-as not found, switching to external assembling

If I add this it works:
Code: Text  [Select][+][-]
  1. -FD/home/wsherman/android/sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin
Compile Project, OS: android, CPU: arm, Target: /home/wsherman/android/projects/AppLAMWProject5/libs/armeabi-v7a/libcontrols.so: Success, Hints: 2

EDIT:  I can't tell if it needs both paths or just the llvm/prebuilt one.  It is hard for me to test since LAMW adds the first path as a compile option and I can't remove it.
« Last Edit: June 12, 2021, 04:20:45 am by WayneSherman »

jmpessoa

  • Hero Member
  • *****
  • Posts: 2297
Re: LAMW error with Android NDK revision 22
« Reply #18 on: June 12, 2021, 04:08:32 am »

Ok. I will do some tests replacing the old

Quote
-FD/home/wsherman/android/sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin

by the new:
Quote
-FD/home/wsherman/android/sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

WayneSherman

  • Full Member
  • ***
  • Posts: 243
Re: LAMW error with Android NDK revision 22
« Reply #19 on: June 12, 2021, 04:21:59 am »

Ok. I will do some tests replacing the old

Quote
-FD/home/wsherman/android/sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin

by the new:
Quote
-FD/home/wsherman/android/sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin

Ok, thanks.  I can't tell if it needs both paths or just the llvm/prebuilt one.  It is hard for me to test since LAMW adds the first path as a compile option and I can't remove it.

jmpessoa

  • Hero Member
  • *****
  • Posts: 2297
Re: LAMW error with Android NDK revision 22
« Reply #20 on: June 12, 2021, 04:32:58 am »

Quote
I can't tell if it needs both paths or just the llvm/prebuilt one....

Just one ....  the llvm is the new way to go....
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

WayneSherman

  • Full Member
  • ***
  • Posts: 243
Re: LAMW error with Android NDK revision 22
« Reply #21 on: June 12, 2021, 04:46:23 am »
Just one ....  the llvm is the new way to go....

I am also trying to test which libraries paths are needed.  On my test system, LAMW adds two library paths:

Code: Bash  [Select][+][-]
  1. /home/wsherman/android/sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/arm-linux-androideabi/29/
  2. /home/wsherman/android/sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/

But if I rename the "lib" folder in the second path like this so it cannot be found
Code: Bash  [Select][+][-]
  1. /home/wsherman/android/sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib-BAK/gcc/arm-linux-androideabi/4.9.x/

I can still successfully compile and build. (tested with a simple LAMW "hello world" gui program)

According to the Build System Maintainers Guide
https://android.googlesource.com/platform/ndk/+/master/docs/BuildSystemMaintainers.md#Sysroot
Quote
The Android sysroot is installed to <NDK>/toolchains/llvm/prebuilt/<host-tag>/sysroot and contains the headers, libraries, and CRT object files for each Android target.

Libraries are found in the usr/lib/<triple> directory of the sysroot. Version-specific libraries are installed to usr/lib/<triple>/<API-level>. As with the header files, when using Clang it is not necessary to include these directories explicitly; the sysroot will be automatically selected. If using a compiler other than Clang, ensure that the version-specific library directory takes precedence over the version-generic directory.

So it sounds like both paths should be added to the libraries with the API version first like this:
Code: Bash  [Select][+][-]
  1. /home/wsherman/android/sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/arm-linux-androideabi/29/
  2. /home/wsherman/android/sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/arm-linux-androideabi/

« Last Edit: June 12, 2021, 05:24:07 am by WayneSherman »

jmpessoa

  • Hero Member
  • *****
  • Posts: 2297
Re: LAMW error with Android NDK revision 22
« Reply #22 on: June 12, 2021, 05:03:39 am »

Yes, there is a mix in LAMW....  the ideal for NDK>=22 is the pure llvm way....
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

rsu333

  • Full Member
  • ***
  • Posts: 110
Re: LAMW error with Android NDK revision 22
« Reply #23 on: June 12, 2021, 08:59:24 am »
Good work and effort from both of you.

WayneSherman

  • Full Member
  • ***
  • Posts: 243
Re: LAMW error with Android NDK revision 22
« Reply #24 on: June 12, 2021, 05:58:00 pm »
Around here I can't fix this error.....my LAMW installation works normally in Win64...
Please,  can you try  some  investigation in  "uformsettingspaths.pas" [LAMW folder "ide_tools"]?

I think I found the problem:
https://github.com/jmpessoa/lazandroidmodulewizard/blob/master/ide_tools/uformsettingspaths.pas#L345

Code: Pascal  [Select][+][-]
  1. procedure TFormSettingsPaths.FormActivate(Sender: TObject);
  2. begin
  3. ...
  4. end;

On Linux it looks like this code runs when the SDK or NDK path speedbuttons "..." are clicked.  It calls TFormSettingsPaths.LoadSettings which clears the NDK and SDK edit boxes since the settings are not set yet.

I think the code here should run in the OnShow event, not OnActivate:

Code: Pascal  [Select][+][-]
  1. procedure TFormSettingsPaths.FormShow(Sender: TObject);
  2. begin
  3. ...(put the code here)
  4. end;



jmpessoa

  • Hero Member
  • *****
  • Posts: 2297
Re: LAMW error with Android NDK revision 22
« Reply #25 on: June 12, 2021, 08:54:36 pm »
Quote
I think the code here should run in the OnShow event, not OnActivate:

OK. I will fix LAMW!

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

WayneSherman

  • Full Member
  • ***
  • Posts: 243
Re: LAMW error with Android NDK revision 22
« Reply #26 on: June 12, 2021, 11:43:46 pm »
Quote
I think the code here should run in the OnShow event, not OnActivate:

OK. I will fix LAMW!

Thank you!

yup, yup that fixed it.  The form now works correctly.  Thanks :-)


 

TinyPortal © 2005-2018