Errors during creation of package for Android

Errors during creation of package for Android

Hi,

I have Windows-64bit computer. I installed fpcupdeluxe according to Castle’s docs. FPC and Lazarus: stable.
I uninstalled cross platform tools via fpcupdeluxe.
I installed Castle by downloading zip from master of GitHub. And I compiled it with Lazarus. Compiled build tool.
Then I downloaded command line sdk manager. In fact I have MSYS2 thus I installed all needed Android tools with command (taken from docs) using the Unix-way:

sdkmanager --install \
  'platform-tools' \
  'platforms;android-28' \
  'extras;google;google_play_services' \
  'build-tools;28.0.3' \
  'extras;android;m2repository' \
  'ndk-bundle'

I added needed paths to PATH etc.

Then when packaging the examples using:
castle-engine package --os=android --cpu=arm

I am getting the message error listed below. It’s probably complaining about missing:
C:/Programs/adt-bundle-windows-x86/sdk/ndk-bundle/build//…/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe
but in fact in ndk-bundle/build/toolchains/ there is no llvm
So I added ${ANDROID_NDK_HOME}toolchains/llvm/prebuilt/windows/bin/:
to PATH (it was not in docs). But still the problem is the same.

Assembling test_bump_mapping
Linking E:\Dev\Delphi\castle-engine-master\examples\mobile\test_bump_mapping\castle-engine-output\android\libtest_bump_mapping_android.so
698196 lines compiled, 103.8 sec
44 warning(s) issued
223 note(s) issued
Compiled library for Android in castle-engine-output\android\libtest_bump_mapping_android_arm.so
Packaging project “test_bump_mapping” for OS / CPU “android / arm” (platform: Android).
castle-engine: Warning: Android: Information about the keys to sign release Android package not found, because “AndroidSigningProperties.txt” file does not exist. See wiki/Android for documentation how to create and use keys to sign release Android apk. Falling back to creating debug apk.
castle-engine: Warning: Icon: No icon in a format readable by our engine (for example, png or jpg) is specified in CastleEngineManifest.xml. Using default icon.
Generated CastleDataInformation.xml.
Project data contains 3 directories, 6 files, total (uncompressed) size 3.00 MB.
process_begin: CreateProcess(NULL, C:/Programs/adt-bundle-windows-x86/sdk/ndk-bundle/build//…/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe -print-resource-dir, …) failed.
[armeabi-v7a] "Prebuilt ": “libtest_bump_mapping_android.so <= jni/armeabi-v7a/”
[armeabi-v7a] "Install ": “libtest_bump_mapping_android.so => jniLibs/armeabi-v7a/libtest_bump_mapping_android.so”
process_begin: CreateProcess(NULL, C:/Programs/adt-bundle-windows-x86/sdk/ndk-bundle/build//…/toolchains/llvm/prebuilt/windows-x86_64/bin/arm-linux-androideabi-strip --strip-unneeded ./jniLibs/armeabi-v7a/libtest_bump_mapping_android.so, …) failed.
make (e=2): The system cannot find the file specified.
make: *** [jniLibs/armeabi-v7a/libtest_bump_mapping_android.so] Error 2
make: *** Deleting file `jniLibs/armeabi-v7a/libtest_bump_mapping_android.so’
Exception “Exception”:
Process “C:\Programs\adt-bundle-windows-x86\sdk\ndk-bundle\ndk-build.cmd” (absolute path “C:\Programs\adt-bundle-windows-x86\sdk\ndk-bundle\ndk-build.cmd”) failed with exit status 2

I am getting above’s error when packaging:
drawing_toy or test_bump_mapping. But when packaging simple_3d_demo I am getting the error about OpelAl:

Linking E:\Dev\Delphi\castle-engine-master\examples\mobile\simple_3d_demo\castle-engine-output\android\libsimple_3d_demo_android.so
699453 lines compiled, 100.3 sec
52 warning(s) issued
223 note(s) issued
Compiled library for Android in castle-engine-output\android\libsimple_3d_demo_android_arm.so
Packaging project “simple_3d_demo” for OS / CPU “android / arm” (platform: Android).
castle-engine: Warning: Android: Information about the keys to sign release Android package not found, because “AndroidSigningProperties.txt” file does not exist. See Android · castle-engine/castle-engine Wiki · GitHub for documentation how to create and use keys to sign release Android apk. Falling back to creating debug apk.
castle-engine: Warning: Icon: No icon in a format readable by our engine (for example, png or jpg) is specified in CastleEngineManifest.xml. Using default icon.
Generated CastleDataInformation.xml.
Project data contains 6 directories, 22 files, total (uncompressed) size 3.76 MB.
process_begin: CreateProcess(NULL, C:/Programs/adt-bundle-windows-x86/sdk/ndk-bundle/build//…/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe -print-resource-dir, …) failed.
[armeabi-v7a] "Prebuilt ": “libopenal.so <= jni/armeabi-v7a/”
[armeabi-v7a] "Install ": “libopenal.so => jniLibs/armeabi-v7a/libopenal.so”
process_begin: CreateProcess(NULL, C:/Programs/adt-bundle-windows-x86/sdk/ndk-bundle/build//…/toolchains/llvm/prebuilt/windows-x86_64/bin/arm-linux-androideabi-strip --strip-unneeded ./jniLibs/armeabi-v7a/libopenal.so, …) failed.
make (e=2): The system cannot find the file specified.
make: *** [jniLibs/armeabi-v7a/libopenal.so] Error 2
make: *** Deleting file `jniLibs/armeabi-v7a/libopenal.so’
Exception “Exception”:
Process “C:\Programs\adt-bundle-windows-x86\sdk\ndk-bundle\ndk-build.cmd” (absolute path “C:\Programs\adt-bundle-windows-x86\sdk\ndk-bundle\ndk-build.cmd”) failed with exit status 2

before doing it I did as it was advised in docs:

From android-ndk-XXX/platforms/android-16/arch-arm/usr/lib/ copy all the files to <fpcupdeluxe>/cross/lib/arm-android .

Here is the update:
I have notificed that my clang++ is really located on the
${ANDROID_NDK_HOME}toolchains/llvm/prebuilt/windows/bin/
thus I added this in PATH.
But on the error messages I see it’s trying to call clang++ from
/toolchains/llvm/prebuilt/windows-x86_64/bin/
But in prebuilt folder I only have windows folder
there is no windows-x86_64 folder.

So who is calling clang++ ? castle-engine or ndk-build.cmd?

Update:
I started Android Studio and run SDK Manager.
I saw the NDK was unchecked. I checked it. It installed NDK 21 (while before that NDK 20 was installed with ndk-bundle).
I set ANDROID_NDK_HOME to new path and did other things.
Now when packaging for Android all projects in /examples/mobile/ it shows the error:

Linking E:\Dev\Delphi\castle-engine-master\examples\mobile\simple_3d_demo\castle-engine-output\android\libsimple_3d_demo_android.so
699453 lines compiled, 99.5 sec
52 warning(s) issued
223 note(s) issued
Compiled library for Android in castle-engine-output\android\libsimple_3d_demo_android_arm.so
Packaging project “simple_3d_demo” for OS / CPU “android / arm” (platform: Android).
castle-engine: Warning: Android: Information about the keys to sign release Android package not found, because “AndroidSigningProperties.txt” file does not exist. See wiki Android for documentation how to create and use keys to sign release Android apk. Falling back to creating debug apk.
castle-engine: Warning: Icon: No icon in a format readable by our engine (for example, png or jpg) is specified in CastleEngineManifest.xml. Using default icon.
Generated CastleDataInformation.xml.
Project data contains 6 directories, 22 files, total (uncompressed) size 3.76 MB.
Exception “Exception”:
Process “C:\Programs\adt-bundle-windows-x86\sdk\ndk\21.3.6528147\ndk-build.cmd” (absolute path “C:\Programs\adt-bundle-windows-x86\sdk\ndk\21.3.6528147\ndk-build.cmd”) failed with exit status -1073741515

We’re not calling clang++ directly.

Castle Game Engine build tool only calls ndk-build and then gradlew. You can see what is being done by looking at PackageAndroid in https://github.com/castle-engine/castle-engine/blob/master/tools/build-tool/code/toolandroid.pas .

I see later that you solved it, but landed in more cryptic problem:

Exception “Exception”:
Process “C:\Programs\adt-bundle-windows-x86\sdk\ndk\21.3.6528147\ndk-build.cmd” (absolute path “C:\Programs\adt-bundle-windows-x86\sdk\ndk\21.3.6528147\ndk-build.cmd”) failed with exit status -1073741515

Can you retry executing with --verbose flag? That is, castle-engine package --verbose --target=android and attach the output?

Here is the output of

castle-engine package --os=android --cpu=arm --verbose

Linking E:\Dev\Delphi\castle-engine-master\examples\mobile\simple_3d_demo\castle-engine-output\android\libsimple_3d_demo_android.so
699453 lines compiled, 97.6 sec
52 warning(s) issued
223 note(s) issued
Compiled library for Android in castle-engine-output\android\libsimple_3d_demo_android_arm.so
Packaging project “simple_3d_demo” for OS / CPU “android / arm” (platform: Android).
castle-engine: Warning: Android: Information about the keys to sign release Android package not found, because “AndroidSigningProperties.txt” file does not exist. See wiki/Android for documentation how to create and use keys to sign release Android apk. Falling back to creating debug apk.
Copied template “android/integrated/” (21 files) to "E:\Dev\Delphi\castle-engine-master\examples\mobile\simple_3d_demo\castle-engine-output\android\project"
Copied template “android/integrated-services/vibrate” (3 files) to "E:\Dev\Delphi\castle-engine-master\examples\mobile\simple_3d_demo\castle-engine-output\android\project"
Copied template “android/integrated-services/sound” (6 files) to "E:\Dev\Delphi\castle-engine-master\examples\mobile\simple_3d_demo\castle-engine-output\android\project"
Copied template “android/integrated-services/ogg_vorbis” (6 files) to "E:\Dev\Delphi\castle-engine-master\examples\mobile\simple_3d_demo\castle-engine-output\android\project"
castle-engine: Warning: Icon: No icon in a format readable by our engine (for example, png or jpg) is specified in CastleEngineManifest.xml. Using default icon.
Packaging data file: castle.wrl
Packaging data file: castle_with_lights.wrl
Packaging data file: castle_with_lights_and_camera.wrl
Packaging data file: sample_image_with_alpha.png
Packaging data file: sample_texture.ppm
Packaging data file: skies\foggy_sky_back.png
Packaging data file: skies\foggy_sky_bottom.png
Packaging data file: skies\foggy_sky_front.png
Packaging data file: skies\foggy_sky_left.png
Packaging data file: skies\foggy_sky_right.png
Packaging data file: skies\foggy_sky_top.png
Packaging data file: sounds\player_potion_drink.wav
Packaging data file: sounds\werewolf_howling.ogg
Packaging data file: sounds\werewolf_howling.wav
Packaging data file: textures\castle\airbase_radar_panels.png
Packaging data file: textures\castle\bricksmokesidebot.png
Packaging data file: textures\castle\france_housered.png
Packaging data file: textures\castle\grassfull.png
Packaging data file: textures\castle\misslescararm.png
Packaging data file: textures\castle\water2.png
Packaging data file: textures\castle\waterwall.png
Packaging data file: textures\castle\wood_clear.png
Generated CastleDataInformation.xml.
Project data contains 6 directories, 22 files, total (uncompressed) size 3.76 MB.
Calling C:\Programs\adt-bundle-windows-x86\sdk\ndk\21.3.6528147\ndk-build.cmd
–silent
NDK_LIBS_OUT=./jniLibs

Exception “Exception”:
Process “C:\Programs\adt-bundle-windows-x86\sdk\ndk\21.3.6528147\ndk-build.cmd” (absolute path “C:\Programs\adt-bundle-windows-x86\sdk\ndk\21.3.6528147\ndk-build.cmd”) failed with exit status -1073741515

So .apk file is not created yet.

I think there is probably conflict of versions: right now I have installed:
ndk-bundle (version 20), ndk (from Android Studio version 21)
All tools for Android versions 9, 10, X.

Thus I will try to remove ndk-budle and all Android tools except for Android 9.

And I have extended the effect of --verbose, so that NDK build is not called with --silent in effect (in https://github.com/castle-engine/castle-engine/commit/8c1bcac151bcb65f8453ee930dc96716da7facde ). If you will still have problems, try with latest CGE, and use castle-engine package --target=android --verbose again.

I’m testing Android building usually through CGE Docker image, https://github.com/castle-engine/castle-engine/wiki/Docker . It works easy in this case :slight_smile: Docker is available on latest Windows too, so you can try this option too. It’s requires a little different approach, but in return you have a 100% working environment, where I tested that Android building definitely works, and you don’t need to deal with installing Android SDK/NDK anymore.

I downloaded and re-compiled updated toolandroid.pas. And I removed Android 10 etc, ndk-bundle. Now there are only Android tools for 9 and NDK installed by Android Studio. Still the problem is the same. And --verbose does not show much details. Which version of NDK do you use for building on Windows right now? Maybe I should install some version 20.* of NDK from Android Studio.

Linking E:\Dev\Delphi\castle-engine-master\examples\mobile\simple_3d_demo\castle-engine-output\android\libsimple_3d_demo_android.so
699453 lines compiled, 120.6 sec
52 warning(s) issued
223 note(s) issued
Compiled library for Android in castle-engine-output\android\libsimple_3d_demo_android_arm.so
Packaging project “simple_3d_demo” for OS / CPU “android / arm” (platform: Android).
castle-engine: Warning: Android: Information about the keys to sign release Android package not found, because “AndroidSigningProperties.txt” file does not exist. See Android · castle-engine/castle-engine Wiki · GitHub for documentation how to create and use keys to sign release Android apk. Falling back to creating debug apk.
Copied template “android/integrated/” (21 files) to "E:\Dev\Delphi\castle-engine-master\examples\mobile\simple_3d_demo\castle-engine-output\android\project"
Copied template “android/integrated-services/vibrate” (3 files) to "E:\Dev\Delphi\castle-engine-master\examples\mobile\simple_3d_demo\castle-engine-output\android\project"
Copied template “android/integrated-services/sound” (6 files) to "E:\Dev\Delphi\castle-engine-master\examples\mobile\simple_3d_demo\castle-engine-output\android\project"
Copied template “android/integrated-services/ogg_vorbis” (6 files) to "E:\Dev\Delphi\castle-engine-master\examples\mobile\simple_3d_demo\castle-engine-output\android\project"
castle-engine: Warning: Icon: No icon in a format readable by our engine (for example, png or jpg) is specified in CastleEngineManifest.xml. Using default icon.
Packaging data file: castle.wrl
Packaging data file: castle_with_lights.wrl
Packaging data file: castle_with_lights_and_camera.wrl
Packaging data file: sample_image_with_alpha.png
Packaging data file: sample_texture.ppm
Packaging data file: skies\foggy_sky_back.png
Packaging data file: skies\foggy_sky_bottom.png
Packaging data file: skies\foggy_sky_front.png
Packaging data file: skies\foggy_sky_left.png
Packaging data file: skies\foggy_sky_right.png
Packaging data file: skies\foggy_sky_top.png
Packaging data file: sounds\player_potion_drink.wav
Packaging data file: sounds\werewolf_howling.ogg
Packaging data file: sounds\werewolf_howling.wav
Packaging data file: textures\castle\airbase_radar_panels.png
Packaging data file: textures\castle\bricksmokesidebot.png
Packaging data file: textures\castle\france_housered.png
Packaging data file: textures\castle\grassfull.png
Packaging data file: textures\castle\misslescararm.png
Packaging data file: textures\castle\water2.png
Packaging data file: textures\castle\waterwall.png
Packaging data file: textures\castle\wood_clear.png
Generated CastleDataInformation.xml.
Project data contains 6 directories, 22 files, total (uncompressed) size 3.76 MB.
Calling C:\Programs\adt-bundle-windows-x86\sdk\ndk\21.3.6528147\ndk-build.cmd
NDK_LIBS_OUT=./jniLibs

Exception “Exception”:
Process “C:\Programs\adt-bundle-windows-x86\sdk\ndk\21.3.6528147\ndk-build.cmd” (absolute path “C:\Programs\adt-bundle-windows-x86\sdk\ndk\21.3.6528147\ndk-build.cmd”) failed with exit status -1073741515

I didn’t test this on Windows since a few months, I think. I’ll retest it soon.

You can also test the Docker approach, https://github.com/castle-engine/castle-engine/wiki/Docker , this contains the same Android SDK/NDK that are tested every day by my Jenkins, and are guaranteed to work :slight_smile:

I know Docker is the modern way to do. I will try find out the solution current setup for few more hours/days.
BTW do you know that Castle 6.5 base package cannot be compiled with the latest stable Lazarus 2.0.10?
Duplicate indetifier Options in the lines:

procedure Parse(Options: POption_Array; OptionsCount: Integer;
OptionProc: TOptionProc; OptionProcData: Pointer;
ParseOnlyKnownLongOptions: boolean = false); overload;
procedure Parse(const Options: array of TOption;
OptionProc: TOptionProc; OptionProcData: Pointer;
ParseOnlyKnownLongOptions: boolean = false); overload;

While I could compile it with Lazarus 2.0.8. That’s why I currently use Lazarus 2.0.10 installed by fpcupdeluxe with master branch of Castle. Thus I will try to use fpcupdeluxe ‘infrastructure’ now.

Cool. I mean of course both options (with Docker or without Docker) should work, so it’s something for me to retest anyway. But maybe Docker will provide an immediate solution for you – after setting up Docker, you’re guaranteed to have (inside Docker) proper FPC, Android SDK/NDK etc.

Duplicate indetifier Options in the lines:

That was fixed 6 months ago , Rename Options parameter to AOptions, to not conflict with TStringLis… · castle-engine/castle-engine@c46558a · GitHub :slight_smile:

Please download the latest CGE from https://castle-engine.io/ . Note that the 6.5 “release” is a snapshot, it is being updated after every commit automatically, so it changes very often :slight_smile:

I did not know that. Mine version 6.5 was from 31st March 2019 (from initial release). Thank you for information.

The information “released this on 31 Mar 2019” on https://github.com/castle-engine/castle-engine/releases/tag/snapshot is admittedly very misleading. The release called “snapshot” was created on 31 Mar 2019, but then it is updated by Jenkins completely automatically after every commit.

I haven’t been able to figure out how to present it better unfortunately.

Eventually we will make a stable 7.0 release of course (that will no longer change after every commit, and then “snapshots” will contain 7.1). Hopefully it will be simpler on the webpage then, as we will recommend using 7.0 (stable) release then, not a snapshot release as we do now.

So this waits for my big task, with which I have a ~year of delay now – make CGE 7.0 release :slight_smile: It’s taking a long time, as we keep adding and adding new features to CGE :slight_smile: https://github.com/castle-engine/castle-engine/wiki/New-Features-in-Castle-Game-Engine-7.0 .

Michalis,
You are doing a great job of developing CGE. The versions numbers is not so important. The new features like new component for third-persons and gITF support are really important.

I completely uninstalled Android Studio, deleted all parts of Android SDK, delete all settings of Android Studio etc.
Then I reinstalled everything from scratch. The issue was still present.

Then I found that running adb.exe produced the error message:

Unable to detect adb version, exit value: 0xc000007b

I found that it was related to Microsoft Visual C++ 2015 redistributes. I had to fix it. Thus the issue is not CGE related. It’s related to setup of Microsoft Visual C++ 2015 redistributes on my computer.

BTW I have noticed I have in PATH:
C:\Program Files\TortoiseSVN\bin
and inside there are many files like api-ms-win-core-console-l1-1-0.dll of Microsoft Visual 2015 redistributes.
So it’s dangerous to put it into PATH.

There is the software: Dependency Walker. I loaded adb.exe into Dependency Walker and it’s showing that adb.exe is using api-ms-win-core-*.dll like files from C:\Program Files\TortoiseSVN\bin\ - not from the system onces!
Then I removed C:\Program Files\TortoiseSVN\bin\ and on computer restart - Windows cannot be normally started - explorer hangs.
Thus I am on long journey of fixing Visual C++ redistributes on my computer.

Thank you for the good words, and info!

I guess Windows explorer has problems, as Tortoise SVN integrates with explorer (to display status icons at files, to add itself to context menu). If possible, I would first try to reinstall Tortoise SVN (to get Windows back in working state), and then later remove C:\Program Files\TortoiseSVN\bin\ from PATH, from what you describe it should not be there, and it’s TortoiseSVN doesn’t require being on PATH (as far as I recall, it’s only optional during installation).

Let me know how it goes.

For what it’s worth I had loads of trouble with Android on Windows 10 too so I installed Docker - it was well worth the effort

I created a c:\docker\cge directory and copied some of the examples in there plus a few of my own creations then I started Docker with the command…

docker run --name cge --volume=c:\docker\cge:/home/cge -it kambi/castle-engine-cloud-builds-tools:cge-unstable bash

This set up Docker so that /home/cge is my c:\docker\cge directory

Change to /home/cge/ and run…

castle-engine package

A short while later you’ve got an APK sitting in c:\docker\cge<project> ready to be installed on a device via adb

3 Likes

Peardox - thank you for your example with Docker. It will simplify the things. I will try it.