Nominate our 2022 Qt Champions!

QApplication was not created in the main() thread. Android + calling java

  • I am getting that warning QApplication was not created in the main() thread.

    The app is C++ calling some java functions, all encapsulated in a class extending

    I am already creating the QApplication in the main() function so I see no way to fix that.

    Until now all was running fine anyway but with Android 5 the app does not start. The error is not explicitly there but later there's an exception

    bq. java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()

    when calling QAndroidJniEnvironment::RegisterNatives. that souns very likely to be related.

    Has anyone experienced something similar? (I've seen similar threads but not one related to android + calling java)


  • Qt Champions 2016

    I have written an example program that can call Java from C++ and C++ from Java's UI thread. You may take a look:

Log in to reply