I am trying to get Qt 5.2.1 on Android C++ to Java interop working.
I have a piece of C++ code that uses QAndroidJniObject to invoke a static method on a Java class.
This works (C++ first, then Java):
QAndroidJniObject::callStaticObjectMethod(
"org/example/AndroidTest",
"doSomething",
"()Ljava/lang/String;"
);
public static String doSomething() {
return "Done something.";
}
However, I have a method that has a void
return type, so:
QAndroidJniObject::callStaticObjectMethod(
"org/example/AndroidTest",
"doSomething",
"()V"
);
public static void doSomething() {
}
The method signature is ()V
and I understood this to mean a method that takes no parameters and has a void
return type - so it should match my Java method.
The problem is that on execution this causes a SIGSEGV in libc when the callStaticObjectMethod
invocation returns.
If I add debug trace I see the Java class enter and exit correctly, the SIGSEGV occurs on return to the C++ code. In fact, if I change the method signature to return an int, e.g. ()I, I still see a SIGSEGV so I am pretty sure the problem relates to the return type but I can not understand why it fails.