Getting AssetManager pointer from AAssetManager_fromJava (Android Qt6.9.1)
-
I was given this code to access the Android asset manager, I think the "activity.object<jobject>()" is wrong because when I run the App it errors:
QJniEnvironment env; QJniObject activity; if (env.isValid()) { activity = QJniObject::callStaticObjectMethod("org/qtproject/qt/android/QtNative", "activity", "()Landroid/app/Activity;"); if (activity.isValid()) { assetManager = AAssetManager_fromJava(env.jniEnv(), activity.object<jobject>()); } }
Running the app gives the following error:
F/.home.QtTest: runtime.cc:716] JNI DETECTED ERROR IN APPLICATION: jfieldID long android.content.res.AssetManager.mObject not valid for an object of class org.qtproject.qt.android.bindings.QtActivity F/.home.QtTest: runtime.cc:716] in call to GetLongField F/.home.QtTest: runtime.cc:716] from void org.qtproject.qt.android.QtNative.startQtApplication()
Can anyone suggest a correct value?