Qt with 3rd party SDK

  • Hi,

    I'm developing an application on a customized tablets which has a barcode scanner. I got the sdk from the manufacturer and the sdk is using Java. I had googled around, I understand I can use QAndroidJniObject to load the java sdk for my application. But I don't really use JNI before. The sdk i got from the manufacturer has libSerial.so and sdk.jar. I'm bit stuck how do i add and point my app to the sdk? Most of the examples i found from google and qt webpage, are loading the .java files directly to the project. can't find any useful info using .jar.

    I wrote a dummy Dialog Window and I have a scan button.

    void MainWindow::on_scanBarcode_clicked()
        qDebug() <<"Scan button clicked.";
        QAndroidJniObject testObject = QAndroidJniObject::callStaticObjectMethod("com/xxxxx/support/openapi/StBarcodeScanner", "getInstance", "()Lcom/xxxx/support/openapi/StBarcodeScanner;");
      //  QAndroidJniObject scanResult = QAndroidJniObject::callMethod("com/xxxxx/support/openapi/StBarcodeScanner", "scan",);
            qDebug() <<"testObject is valid...";
        } else{
            qDebug() <<"testObject is invalid..";

    This is my .pro file

    # Project created by QtCreator 2016-09-16T12:26:49
    QT       += core gui
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    QT += androidextras
    TARGET = untitled
    TEMPLATE = app
    SOURCES += main.cpp\
    HEADERS  += mainwindow.h
    FORMS    += mainwindow.ui
    CONFIG += mobility
    ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android/libs/
    DISTFILES += \
        android/libs/sdk.jar \
        android/libs/libSerial.so \
        android/libs/AndroidManifest.xml \
        android/libs/gradle/wrapper/gradle-wrapper.jar \
        android/libs/gradlew \
        android/libs/res/values/libs.xml \
        android/libs/build.gradle \
        android/libs/gradle/wrapper/gradle-wrapper.properties \
    contains(ANDROID_TARGET_ARCH,armeabi-v7a) {

    When i pressed the button, the "testObject is invalid..." is printed. Anyone can point me to right place please?



Log in to reply

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