Java + QT (Use QT in JAVA)



  • Good afternoon, there is a library for communicating with servers implemented on QT. There is also an application written in JAVA (Android Studio).

    Question is it possible to use the QT library in a java project?

    I created a test project, I took everything from the android project created in QT and added them to my libs folder. At startup, an error is written already at System.loadLibrary:

    A/QtCore: initJNI failed
    E/AndroidRuntime: FATAL EXCEPTION: main
        Process: test.black, PID: 16392
        java.lang.UnsatisfiedLinkError: JNI_ERR returned from JNI_OnLoad in "/data/app/test.black.bscentertest-1/lib/arm/libQt5Core.so"
            at java.lang.Runtime.loadLibrary0(Runtime.java:977)
            at java.lang.System.loadLibrary(System.java:1567)
            at test.black.bscentertest.MainActivity.<clinit>(MainActivity.java:12)
    

    MainActivity:

    package test.black.bscentertest;
    
    import androidx.appcompat.app.AppCompatActivity;
    
    import android.os.Bundle;
    
    public class MainActivity extends AppCompatActivity {
    
        static {
            System.loadLibrary("Qt5Core");
        }
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
        }
    }
    


  • @LeeTiK
    I think: read through https://stackoverflow.com/questions/4577313/using-qt-in-java. Looks like people used to use Qt Jambi, but it's discontinued now.

    The last post there says:

    I believe it can be done using JNI (Java Native Interface) calls.

    Have a read through https://ambes-engineering.com/2018/03/22/qt-java-native-interface/, that's 2018.

    So does https://doc.qt.io/qt-5/qandroidjniobject.html get you what you are wanting?



  • not yet(
    But! I managed to connect qt under windows without any problems. One question remains, if there is any peculiarity when implementing this all in the android (Android Studio) !?
    Maybe if some example where QT is used in a java project for android?


Log in to reply