JNI Problem: Can't find my Java Class (worked pre 5.2)



  • Hey,

    I got a Problem with my custom java class i added to my android app.
    As I said it worked previously but after updating to Qt 5.2 I dont get the class when calling FindClass on my JNIEnv.

    calling:
    env->FindClass("org/qtproject/qt5/android/QGooglePlayManager")
    returns nothing.

    app crashes with:
    D/AndroidRuntime(19137): Shutting down VM
    W/dalvikvm(19137): threadid=1: thread exiting with uncaught exception (group=0x415cf700)
    E/AndroidRuntime(19137): FATAL EXCEPTION: main
    E/AndroidRuntime(19137): java.lang.NoClassDefFoundError: org/qtproject/qt5/android/QGooglePlayManager
    E/AndroidRuntime(19137): at java.lang.Runtime.nativeLoad(Native Method)
    E/AndroidRuntime(19137): at java.lang.Runtime.doLoad(Runtime.java:418)
    E/AndroidRuntime(19137): at java.lang.Runtime.loadLibrary(Runtime.java:359)
    E/AndroidRuntime(19137): at java.lang.System.loadLibrary(System.java:525)
    E/AndroidRuntime(19137): at org.qtproject.qt5.android.bindings.QtActivity.loadApplication(QtActivity.java:209)
    ......

    I am not very experienced with setting up any build processes so i hope i just have to add the java file or class somewhere?!

    Thanks,
    Laroh



  • Your need to use ANDROID_PACKAGE_SOURCE_DIR.

    In your <project>.pro file, you might have:

    ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android-sources

    Then in your project directory, you would have a sub-directory called android-sources. The manifest file, if you need a special one, would go in this sub-directory and your java files would go under this in android-sources/src.

    In fact, in the end we copied the complete 5.1.1 android\src sub-directory tree from the 5.1.1 into android-sources/src and deleted the java files that were not our own from the android-sources/src tree.

    In the end it was simple, but finding out how to do it took ages!!



  • Thank you!!!

    so all user-modified files to be included in the apk now go into the ANDROID_PACKAGE_SOURCE_DIR!?





  • After adding ANDROID_PACKAGE_SOURCE_DIR. Deployment is failed


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.