2shady4u / godot-sqlite

GDExtension wrapper for SQLite (Godot 4.x+)
MIT License
947 stars 82 forks source link

Unable to load library in Android with x86_64 system image #114

Closed tokengamedev closed 1 year ago

tokengamedev commented 1 year ago

Environment:

Issue description: The loading of the library fails with the following error when Godot game is exported to Android x86_64 image "ERROR: does not have a library for the current platform. at: init_library (modules/gdnative/nativescript/nativescript.cpp:1479) - Condition "lib_path.length() == 0" is true."

Steps to reproduce: Create a project by adding the library (using plugin method or manually) Export the project to android by including architecture x86 and x86_64 image in export template. When you run the project in x86_64 image it crashes when library is loaded with the above given error message

Minimal reproduction project: Demo project included as part of release does not work

Additional context: I may be doing something wrong, if you can guide me also it will be of great help. Note: It works on X86 version without issues, like android 11 and earlier

Need some help urgently as I was testing for release of game, but it crashed on android 12* devices.

2shady4u commented 1 year ago

Hi @tokengamedev,

I don't think I'm currently building the plugin for Android x86_64. As you can see in the gdsqlite.gdnlib-file, there's no entry for x86_64:

Android.armeabi-v7a="res://addons/godot-sqlite/bin/android/armeabi-v7a/libgdsqlite.so"
Android.arm64-v8a="res://addons/godot-sqlite/bin/android/arm64-v8a/libgdsqlite.so"
Android.x86="res://addons/godot-sqlite/bin/android/x86/libgdsqlite.so"

An entry for x86_64 (as well as the necessary additions to CI/CD) could be added.

Reasoning behind not including x86_64 by default, is the incredibly small market share those CPUs represent:

g8eN5

(I used to have an actual pie chart for this, but I can't seem to find it any longer... my apologies)

tokengamedev commented 1 year ago

Hi @2shady4u, I think I realized this also after doing some research inside play console itself, which has a meagre 31 devices with x86_64 arch compared to a total of 12403 devices. and off which none of them, are my game targeted devices.

The problem is not targeted devices. The problem is testing app/game in simulators. I am using Windows 11 which has a x86/x64 arch. Now the simulators Android Studio provides for android 12 and higher is x86_64 arch only and not x86. This is the issue, since database is core part of the game and game will not even run when you try to load the library.

alternatively, there are also Arm based simulators in android studio, but those are very slow, Testing is very painful.

I request to create a build out of x86_64 or provide some guide so that I can create a custom build for the library

appreciate your kind response and support for the library 🙏

2shady4u commented 1 year ago

Hi @tokengamedev,

I've added a x86_64 build to Github Actions. You can download it here: https://github.com/2shady4u/godot-sqlite/actions/workflows/android_builds.yml

Also don't forget to add an x86_64 entry to gdsqlite.gdnlib as seen here: https://github.com/2shady4u/godot-sqlite/blob/master/demo/addons/godot-sqlite/bin/gdsqlite.gdnlib

tokengamedev commented 1 year ago

Hi @2shady4u,

Thanks for the changes. I took the build files from GitHub actions output and changed gdnlib file accordingly, and it kind of worked out 👍

Appreciate your quick response. and support. Closing the issue.

2shady4u commented 1 year ago

Hi @tokengamedev

Could you clarify what you mean with: "It kind of worked out"? 😛 Do the new x86_64 binaries work or are there additional issues that you had to solve independently?

tokengamedev commented 1 year ago

Hi @2shady4u,

What I meant by "it kind of worked out", is, I took the build output from the GitHub actions rather than building from scratch myself. I don't know if it is the right approach, but since it worked out, I am using it, I will replace with official release, whenever it happens.

Also, I learnt a lesson from this, as I was unnecessarily adding x86 and x86_64 archs into the released apk/aab. which was kind of bloating the size.

tokengamedev commented 1 year ago

Updated to released version 3.5.

There is an issue, in the gdsqlite.gdnlib

Need to change the line from Android.x86_64="res://addons/godot-sqlite/bin/android/x86/libgdsqlite.so" to Android.x86_64="res://addons/godot-sqlite/bin/android/x86_64/libgdsqlite.so"

Thanks

2shady4u commented 1 year ago

Hi @tokengamedev You are correct! Thank you for noticing this!

EDIT: I have fixed the path in the gdsqlite.gdnlib and pushed a new update on the Godot Asset Library. It will probably take a few days for this new update to be accepted.