Nominate our 2022 Qt Champions!

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.

    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(
    E/AndroidRuntime(19137): at java.lang.Runtime.loadLibrary(
    E/AndroidRuntime(19137): at java.lang.System.loadLibrary(
    E/AndroidRuntime(19137): at

    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?!


  • 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