Recent

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

WayneSherman

  • Sr. Member
  • ****
  • Posts: 250
LAMW error with Android NDK revision 22
« on: June 04, 2021, 07:56:11 pm »
When installing the latest stable android NDK (revision 22):

./sdkmanager "platforms;android-29" "build-tools;29.0.3" "tools" "ndk-bundle" "extras;android;m2repository"

It creates the ./sdk/ndk-bundle directory with the NDK files correctly, but I get an error when creating a new LAMW project in Lazarus:  "Fail! Folder /home/user/android/sdk/ndk-bundle/platforms is empty!"

Error Reference in code:
https://github.com/jmpessoa/lazandroidmodulewizard/blob/master/android_wizard/uformworkspace.pas#L255

According to the NDK changelog:
https://github.com/android/ndk/wiki/Changelog-r22
Quote
"The deprecated <NDK>/platforms and <NDK>/sysroot directories have been removed. These directories were merged and relocated into the toolchain during r19. The location of these contents should not be relevant to anyone, including build systems, since the toolchain handles them implicitly. If you are using a build system that hasn't adapted to the changes introduced in NDK r19, file a bug with your build system maintainer. See the Build System Maintainers Guide for information on using the NDK in your own build system."

So, if LAMW needs the NDK revision number...
EDIT:  LAMW is looking here for the NDK supported API levels, not the NDK revision number.
« Last Edit: June 05, 2021, 06:25:30 pm by WayneSherman »

DonAlfredo

  • Hero Member
  • *****
  • Posts: 1781
Re: LAMW error with Android NDK revision 22
« Reply #1 on: June 05, 2021, 01:47:10 pm »
I have just tried to fix this issue. Please test.
Also fixed: LAMW will now build with Lazarus trunk.

WayneSherman

  • Sr. Member
  • ****
  • Posts: 250
Re: LAMW error with Android NDK revision 22
« Reply #2 on: June 05, 2021, 04:32:42 pm »
I have just tried to fix this issue. Please test.
Also fixed: LAMW will now build with Lazarus trunk.

Yes, it works now without any work-arounds.  Thank you much.

(Will test trunk builds and report back)

WayneSherman

  • Sr. Member
  • ****
  • Posts: 250
Re: LAMW error with Android NDK revision 22
« Reply #3 on: June 05, 2021, 07:02:15 pm »
Yes, trunk works with LAMW.  I installed a development environment and can build an APK without errors using FPC trunk/Lazarus trunk.  (Xubuntu 20.04 64-bit + FPCUPdeluxe 1.8.2u + latest LAMW + trunk FPC + trunk Lazarus)

(test project with Andriod SDK 29, Target API 29, and NDK r22 API level 26)

Thank you

WayneSherman

  • Sr. Member
  • ****
  • Posts: 250
Re: LAMW error with Android NDK revision 22
« Reply #4 on: June 05, 2021, 07:15:30 pm »
I have just tried to fix this issue. Please test.
Also fixed: LAMW will now build with Lazarus trunk.

Question about NDK API levels.  There are two different lists for ARM and AArch64:

For ARM, the NDK has folders from 16 to 30 (missing 20, 25)
$HOME/android/sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/arm-linux-androideabi/

For AArch64, the NDK has folders from 21 to 30 (missing 25)
$HOME/android/sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/

But the LAMW new project wizard lists NDK API levels:  16, 17, 18, 19, 21, 22, 23, 24, 26

Why is the new project wizard missing levels 27, 28, 29, 30?

EDIT:  This is fixed.  See here: https://github.com/jmpessoa/lazandroidmodulewizard/issues/383
« Last Edit: June 13, 2021, 12:06:33 am by WayneSherman »

WayneSherman

  • Sr. Member
  • ****
  • Posts: 250

WayneSherman

  • Sr. Member
  • ****
  • Posts: 250
Re: LAMW error with Android NDK revision 22
« Reply #6 on: June 08, 2021, 05:59:08 pm »
Same issue with NDK rev 21.4.7075529.  New project wizard is missing 27, 28, 29 and 30 NDK API platforms.

Screenshot attached.


jmpessoa

  • Hero Member
  • *****
  • Posts: 2317
Re: LAMW error with Android NDK revision 22
« Reply #7 on: June 08, 2021, 06:44:49 pm »
Quote
Why is the new project wizard missing levels 27, 28, 29, 30?

Please, change here and do some tests.... [Maybe in the past FPC didn't like that.....]

unit "uformworkspace.pas"  line  244  [LAMW folder "........\android_wizard"]

Code: Pascal  [Select][+][-]
  1.            if (intAux > 13) and (intAux < 27)  then
  2.            begin
  3.               ListBoxNdkPlatform.Items.Add(auxStr);
  4.               count:= count + 1;
  5.            end;
  6.  

But remember:
if you set NDK Api > 22 your app will not run on old Android 4.xxxx [and maybe 5.xxx]
« Last Edit: June 09, 2021, 12:01:49 am by jmpessoa »
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

WayneSherman

  • Sr. Member
  • ****
  • Posts: 250
Re: LAMW error with Android NDK revision 22
« Reply #8 on: June 09, 2021, 02:49:47 am »
Please, change here and do some tests.... [Maybe in the past FPC didn't like that.....]
unit "uformworkspace.pas"  line  244  [LAMW folder "........\android_wizard"]
Code: Pascal  [Select][+][-]
  1. if (intAux > 13) and (intAux < 27)  then

Changed line to:

Code: Pascal  [Select][+][-]
  1. if (intAux > 13) and (intAux <= 30)  then

Yes, it works.  Tested simple "hello world" project built with with NDK API 29 and NDK API 30, with both AARCH64 and ARMv7a+VFPv3.  Builds and runs correctly.  Tested on Pixel 4 Android 11.

Questions:
1) Is the limit for the NDK api level needed anymore, or better to remove it and populate the list with every API found in the selected NDK?

2) How does one change the NDK API level for an existing project (like AppDemo1) ?  The "NDK API" level is shown in the wizard for a new LAMW project, but for an existing project I don't see how to change it.  The Project | Project Options | LAMW Android Project Options, does not have NDK API level, only "Target SDK Version".
« Last Edit: June 09, 2021, 02:51:50 am by WayneSherman »

jmpessoa

  • Hero Member
  • *****
  • Posts: 2317
Re: LAMW error with Android NDK revision 22
« Reply #9 on: June 09, 2021, 03:27:31 am »
Quote
1) Is the limit for the NDK api level needed anymore, or better to remove it and populate the list with every API found in the selected NDK?

Ok, I will remove the limit....

Quote
2) How does one change the NDK API level for an existing project (like AppDemo1) ?

Ok. Will try improve the project options....

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

jmpessoa

  • Hero Member
  • *****
  • Posts: 2317
Re: LAMW error with Android NDK revision 22
« Reply #10 on: June 11, 2021, 11:11:54 pm »

Done!!!

Now LAMW can handle [transparently] NDK >= 22!

I thank everyone!
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

WayneSherman

  • Sr. Member
  • ****
  • Posts: 250
Re: LAMW error with Android NDK revision 22
« Reply #11 on: June 12, 2021, 12:50:21 am »
Done!!!  Now LAMW can handle [transparently] NDK >= 22!

Thank you for your work on this. :-)

I tested it and it does build and allow me to run AppDemo1 on a Pixel4 (Android 11).  I tested the following combinations:

NDK r21 ARMv7a + VFPv3 = OK
NDK r21 Aarch64 = OK
NDK r22 ARMv7a + VFPv3 = OK
NDK r22 Aarch64 = OK

Dev Environment:
    Xubuntu 20.04 64-bit w/ latest updates installed
    Android Command-Line Tools build 7302050
    OpenJDK 11
    Android SDK/API Level 29 (Android 10)
    Gradle 6.8.3 (installed automatically by FPCUPdeluxe)
    FPCUPdeluxe ver 1.8.2u
    FPC stable v3.2.2
    Lazarus stable v2.0.12
    32-bit CPU Target: ARMv7a + VFPv3
    64-bit CPU Target: Aarch64
    LAMW git from 2021-Jun-11
    Android NDK revision 22 (installed to sdk/ndk-bundle)
    Android NDK revision 21 (installed to sdk/ndk/21.4.7075529/)

NOTE about FPCUPdeluxe:
I renamed $HOME/android/fpc-lazarus/cross/lib/ to lib-BAK so those libraries don't get used.
(the current version of FPCUPdeluxe created that folder)

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.

There are some issues and concerns.  Will put those in next message.

WayneSherman

  • Sr. Member
  • ****
  • Posts: 250
Re: LAMW error with Android NDK revision 22
« Reply #12 on: June 12, 2021, 12:56:17 am »
With latest LAMW changes the following minor issue still exists:

Set paths using LAMW Paths/Settings dialog box not working

After setting the "Path to Android NDK", the edit box gets cleared when setting the Android SDK path using the "..." browse button.
After setting the "Path to Android SDK", the edit box gets cleared when setting the Android NDK path using the "..." browse button.

If I paste the paths to the NDK and SDK, then it works.

jmpessoa

  • Hero Member
  • *****
  • Posts: 2317
Re: LAMW error with Android NDK revision 22
« Reply #13 on: June 12, 2021, 01:10:00 am »

Quote
With latest LAMW changes the following minor issue still exists....

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"]?
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

WayneSherman

  • Sr. Member
  • ****
  • Posts: 250
Re: LAMW error with Android NDK revision 22
« Reply #14 on: June 12, 2021, 01:55:46 am »
Regarding the latest LAMW changes, the wrong library files are being used for building when opening an existing project.

When creating a new LAMW Project, it works correctly.  For example, the NDK Api is set to 29, and the Target SDK version set to 29 (i.e. API Level 29), and my path has the correct API level 29 libraries:

/home/wsherman/android/sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/arm-linux-androideabi/29/
or
/home/wsherman/android/sdk/ndk/21.4.7075529/platforms/android-29/arch-arm/usr/lib/

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:

(after opening AppDemo1 and changing the Target SDK version to 29 in Project Options)
/home/wsherman/android/sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/arm-linux-androideabi/22/
or
/home/wsherman/android/sdk/ndk/21.4.7075529/platforms/android-22/arch-arm/usr/lib/
« Last Edit: June 12, 2021, 01:59:30 am by WayneSherman »

 

TinyPortal © 2005-2018