Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Java + QT (Use QT in JAVA)
Forum Updated to NodeBB v4.3 + New Features

Java + QT (Use QT in JAVA)

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
3 Posts 2 Posters 1.1k 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.
  • L Offline
    L Offline
    LeeTiK
    wrote on 31 Oct 2019, 16:54 last edited by
    #1

    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);
        }
    }
    
    J 1 Reply Last reply 31 Oct 2019, 17:16
    0
    • L LeeTiK
      31 Oct 2019, 16:54

      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);
          }
      }
      
      J Offline
      J Offline
      JonB
      wrote on 31 Oct 2019, 17:16 last edited by
      #2

      @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?

      1 Reply Last reply
      0
      • L Offline
        L Offline
        LeeTiK
        wrote on 1 Nov 2019, 11:34 last edited by
        #3

        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?

        1 Reply Last reply
        0

        1/3

        31 Oct 2019, 16:54

        • Login

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