Search code examples
androidqtandroid-ndkqt-designerqtwidgets

Qt android ndk - app crashes


I've been recently trying to make some very simple app in Qt, and yesterday it used to work correctly on both Desktop and Android (using android ndk, I know it's not good to make android apps in c++, but I just want to try).

Today, out of nowhere, application output says sth like this: error image

The only thing I've found was cleaning app's cache and data, restarting phone, rebuilding, none of these things worked


Solution

  • A Qt app has an array of used .so library names, somewhere in the resources. On start-up, it loads all these .so libraries (via loadLibrary()). The order in which the libraries are loaded is important: functions cannot reference functions defined in libraries that have not yet been loaded. So implementing a circular dependency is tricky.

    From the logs I see that some function in libszachy_android_1.so (is it the right name? it's a bit strange) invokes srand() that has not yet been loaded; maybe, it is mentioned later in the load list, but loadLibrary() has no idea about the planned future. Therefore, you get this.

    If your code worked yesterday, you likely have made some changes. If you use version control, you likely can compare the today's and yesterday's versions and see the difference. Maybe, you have inserted a forward reference (in the load list sense). OTOH, sometimes both Eclipse and make cannot detect that the source has changed and make incorrect builds (I did observe this, but cannot reproduce). Did you try to uninstall the app from the phone? Did you try to remove all existing .so files in the build directories (rm *.so)?

    Maybe, one of your .so modules is broken: sometimes an object is generated despite of errors and it may get used in subsequent builds (at least this is how I can explain the build glitches).

    Maybe, you have no memory left on the device, and the .so could not be unpacked correctly.

    I suggest examining the application directory with adb shell on a rooted device.

    PS you posted a screenshot that is barely readable. Please replace it with the relevant portion of the adb logcat output (I hope you know how to use it; if not, the first thing to do is to learn adb logcat and adb shell).