Android: QtNative activity in java with non-bundled Qt Libraries (Ministro service)
-
I am using Qt to develop an android application. In this application, I wanted to be able to display a "toast" message on the screen. I based my code on "this thread":http://qt-project.org/forums/viewthread/42779 and I successfully got this working with the two snippets at the end of this post.
This works absolutely fine, as long as I bundle the Qt libraries in the APK. If I set Qt Creator up to use the Ministro service to install Qt, I get compilation errors:
Errors:
@
-compile:
[javac] Compiling 7 source files to C:\cygwin\home\al\development\build-QtArpCalc-Android_for_armeabi_v7a_GCC_4_9_Qt_5_3_2-Release\android-build\bin\classes
[javac] C:\cygwin\home\al\development\build-QtArpCalc-Android_for_armeabi_v7a_GCC_4_9_Qt_5_3_2-Release\android-build\src\uk\co\cgtk\ARPCalc\ToastClient.java:22: error: cannot find symbol
[javac] org.qtproject.qt5.android.QtNative.activity(),
[javac] ^
[javac] symbol: class QtNative
[javac] location: package org.qtproject.qt5.android
[javac] C:\cygwin\home\al\development\build-QtArpCalc-Android_for_armeabi_v7a_GCC_4_9_Qt_5_3_2-Release\android-build\src\uk\co\cgtk\ARPCalc\ToastClient.java:18: error: cannot find symbol
[javac] org.qtproject.qt5.android.QtNative.activity().runOnUiThread(new Runnable()
[javac] ^
[javac] symbol: class QtNative
[javac] location: package org.qtproject.qt5.androidBUILD FAILED
C:\applications\development\languages\android-sdk\tools\ant\build.xml:720: The following error occurred while executing this line:
C:\applications\development\languages\android-sdk\tools\ant\build.xml:734: Compile failed; see the compiler error output for details.Total time: 2 seconds
[javac] Note: C:\cygwin\home\al\development\build-QtArpCalc-Android_for_armeabi_v7a_GCC_4_9_Qt_5_3_2-Release\android-build\src\org\qtproject\qt5\android\bindings\QtActivity.java uses or overrides a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] 2 errors
Building the android package failed!
@As can probably be told from the error messages, I'm using Qt 5.3.2 on Windows. I'm using Qt Creator 3.2.2 to compile.
Is there a way of making this work with non-bundled libraries? I don't know much about java programming and I don't really understand what Qt is doing to make the different types of package (bundled or minstro-service).
Thanks for your help.
C++ Code snippet:
@
QAndroidJniObject javaToast = QAndroidJniObject::fromString(message);
QAndroidJniObject::callStaticMethod<void>("uk/co/cgtk/ARPCalc/ToastClient",
"toast",
"(Ljava/lang/String;)V",
javaToast.object<jstring>());
@Java Code snippet (this is the entire and only java source file):
@
package uk.co.cgtk.ARPCalc;import android.widget.Toast;
import android.view.Gravity;public class ToastClient extends org.qtproject.qt5.android.bindings.QtActivity
{
private static String messageData = "";public static void toast(String message) { messageData = message; new Thread() { public void run() { org.qtproject.qt5.android.QtNative.activity().runOnUiThread(new Runnable() { public void run() { Toast t = Toast.makeText( org.qtproject.qt5.android.QtNative.activity(), messageData, Toast.LENGTH_LONG); t.setGravity(Gravity.TOP|Gravity.CENTER_HORIZONTAL, 0, 0); t.show(); } }); } }.start(); }
}
@