Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt with 3rd party SDK
Qt 6.11 is out! See what's new in the release blog

Qt with 3rd party SDK

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 456 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • liewjlsL Offline
    liewjlsL Offline
    liewjls
    wrote on last edited by
    #1

    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",);
    
        if(testObject.isValid()){
            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\
            mainwindow.cpp
    
    HEADERS  += mainwindow.h
    
    FORMS    += mainwindow.ui
    
    CONFIG += mobility
    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 \
        android/libs/gradlew.bat
    
    contains(ANDROID_TARGET_ARCH,armeabi-v7a) {
        ANDROID_EXTRA_LIBS = \
            $$PWD/android/libs/libSerial.so
    }
    
    

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

    thanks.

    regards,
    jen

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved