Unsolved Java compilation on Android
-
I want to understand what happens when I compile a QT/QML Application for Android.
From what I get from this site in the docs:
https://doc.qt.io/qt-5/deployment-android.html#java-code
So does the Javacode call the C++ functions?
Or
Does all the application get compiled into Java?
-
Does all the application get compiled into Java?
No.
Your c++ code is compiled using a normal c++ compiler (clang) into binary form. Same as on all other platforms.
So does the Javacode call the C++ functions?
Android system runs the Qt5Application which is a Java "wrapper" for Qt:
- it creates Android Activity
- it creates a surface to draw on
Then Qt code (c++) uses that surface to draw your QtWidgets or QML UI into a texture - which is then drawn in the Android activity.
So the Java code contained in Qt templates is just a thin interface between Qt platform abstractions and what Android OS expects to see.
In your apps, you can use C++ to write your app, and if you need to access some "deeper" native functions, you can call Java through JNI.
-
@sierdzio Thanks for the explanation.
What is JNI ?
-
@sandro4912 Easy to find with Google: https://en.wikipedia.org/wiki/Java_Native_Interface
-
And Qt has a short tutorial on how to use it, too: https://doc.qt.io/qt-5/qandroidjniobject.html
-
Sorry to ask more questions but I really have to be sure.
Does it mean that technically the app runs as an Java app on a JVM which calls the C++ part as a library?
And what about the QML Files how are they interpreted to Java?
-
@sandro4912
since ANdroid is a Linux derivat (if you want so) your app runs like a normal C++ app. And JAVA interfaces with native (C/C++) via JNI. Your Android App is not 100% JAVA in the end. -
@sandro4912 said in Java compilation on Android:
And what about the QML Files how are they interpreted to Java?
Java does not know about QML, that is handled only by C++.