GDPaho
GDPaho copied to clipboard
Problem exporting to android
Hello !
I don't know if this is the right place to write this, so do tell me if I need to move it somewhere else.
I've been working with this addon on a project for a while now and I've arrived at a stage where I need to deploy my app. on a tablet.
I've managed to build the library (libgdpaho.so
) for android (arm64) after rummaging through the SConstruct
file. After that, I exported the app. on a Samsung Galaxy Tab A8 so that I can test if it runs as intended.
To build the library for the Android platform, I've used the following tools:
- SCons v4.0.1
- CMake v3.22.1
- gcc (Ubuntu) v11.4.0
- Android NDK v23.2.8568313
This is the command I've used to build the library (android-ndk
is where I've unzipped the archive downloaded from here https://github.com/android/ndk/wiki/Unsupported-Downloads)
set ANDROID_NDK_ROOT=~/android-ndk && scons platform=android android_arch=arm64v8 target=release
Also, this was done on WSL Ubuntu 22.04 running on Windows 10.
The app. runs without crashing, however when looking at the logs using ADB and Logcat, I have the following error:
I've searched for a while, trying to find a problem similar to mine but to no avail. I found nothing that could help me with this issue and I'm no expert in C/C++ nor in compiling stuff...
This line indicates that it can not find the disconnect function which I presume is the one declared in the async_client.h
file
ERROR: Can't open dynamic library: libgdpaho.so, error: dlopen failed: cannot locate symbol "_ZN4mqtt12async_client10disconnectENS_18disconnect_optionsE"...
/**
* Disconnects from the server.
* @param opts Options for disconnecting.
* @return token used to track and wait for the disconnect to complete.
* The token will be passed to any callback that has been set.
* @throw exception for problems encountered while disconnecting
*/
token_ptr disconnect(disconnect_options opts) override;
Hello, sorry I've only just seen your message, I need to activate notifications... From what I understand the library seems not to be copied, is it possible to see what files are installed? For Windows, macOS and Linux the library should be next to the executable, for Android and iOS I'm not used to working for these platforms ...
My first clue is the configuration of the gdnlib file:
By the way, if your procedure works for Android, it would be very nice to share it in the Readme :)
Hello ! Thank you for your reply on this matter.
First to answer your query
From what I understand the library seems not to be copied, is it possible to see what files are installed? For Windows, macOS and Linux the library should be next to the executable, for Android and iOS I'm not used to working for these platforms ...
The files are added properly, I've modified the GDPaho.gdnlib
file to make sure of that 🙂 !
As for the addon, I have unfortunatly abandonned using it on my project because I was nearing my deadline and I absolutely needed to deploy the game on the tablet, so I resorted to using another method.
Nevertheless, I've documented my "little adventure" on trying to make this work for Android !
First, I noticed that the SConstruct
file does not contain the lines to append the dependencies for the library, so I added them (copied from the linux dependencies append lines).
...
if env['platform'] == "android":
env.Append(LIBS=["paho-mqtt3as", "paho-mqttpp3", "crypto", "ssl"])
Secondly, I recompiled all the dependencies for ARM64 platform using the same compiler that I used for your addon (Android NDK v23.2.8568313). Fortunately for me, there is a cross-compilation section on the Paho MQTT C library so it wasn't that hard to build it for ARM64. This was also the case for the OpenSSL library (there were notes on how to build for ARM64).
As for the Paho MQTT C++ library, there was nothing but I applied the same method used on the C library and it worked just fine.
After rebuilding all the dependencies, I rebuilt the GDPaho libarary using the modified SConstruct
file.
Finally, after building everything for the ARM64 platform, I coppied the necessary files inside the Addons/GDPaho/android
and Addons/GDPaho/android/deps
folders. The file structure is the following:
-
android/deps/libssl.so
- OpenSSL main library -
android/deps/libcrypto.so
- OpenSSL crypto library -
android/deps/libpaho-mqtt3as.so
- Paho MQTT C SSL asynchronous library -
android/deps/libpaho-mqttpp3.so
- Paho MQTT C++ SSL library -
android/libgdpaho.so
- GDPaho library
Additionally, I re-modified the GDPaho.gdnlib
so that it includes the dependencies for the library.
After deploying on the tablet, the Godot application seemed to be running fine, there were no errors concerning libgdpaho.so
or MQTT on Logcat. However, no communication could be established to my MQTT broker.
Before deploying, I had connected the signals to ouput errors concerning MQTT but nothing was printed on the console.
Ok, thanks, I've encountered a similar problem with https://github.com/GDWired/GDSimpleBLE (Bluetooth Low Energy BLE) but I've never delved into the subject, I'll try to figure it out one day :/ maybe you need to add a permission when exporting or something. I've created the Godot4 version of the plugin, I'll try to export from this version, maybe it will work better.
The repo is now compatible with Godot 4 I will try to compile the plugin for Android !
Sorry, is it possible to send me all compiled libs ? its will be easier for me
Sure, here you go. addons.zip