Will apps targeting Android devices written with C++ on Qt perform better than apps written with Java using Android SDK?
Google offers the native development kit (NDK) that uses native languages like C and C++ for Android development. But you can't build an entire Android app with C or C++. You need to learn Java.
The official language for Android development is Java. Large parts of Android are written in Java and its APIs are designed to be called primarily from Java. It is possible to develop C and C++ app using the Android Native Development Kit (NDK), however it isn't something that Google promotes.
Java is best suited for creating Android apps since it is platform-independent, and as a result, Java apps work on any platform. Java has its own runtime environment, Java Runtime Environment, as well as an API. A major portion of Android apps are based on Java, which is one of the most popular languages on GitHub.
Java, Python, C++, Kotlin, and Rust are popular app development languages ranked among the world's top 10 most preferred languages in 2022.
Java is the first choice of android app developers because of ease of use, robustness, security features, and cross-platform development capabilities.
It seems all other answers are disputes about C++ and Java, so I will try to share my experience and knowledge about Java and Qt programming in Android.
First of all, Android SDK implemented in Java and thus developer should use Java as default.
.
But there is need to more performance in some cases. Games is an example. Image processing is another use case example.
In some situations you need to use C++ for better control over HW. (e.g. use Accelerometer with higher frequency)
Android uses an specific virtual machine named Dalvik (until ver.5). Any application which needs UI, needs Dalvik. So C++ applications (games and Qt e.g.) needs to involve Dalvik.
Also there is no C++ library to utilising services and OS features directly from C++ (such as contact book). Therefore you need to use Java alongside C++. For this purpose you need to write some Java codes in .java
file and you need to use JNI for communicate C++ and Java. JNI is another problematic thing which you need to learn.
So developing Android application using C++ is very more difficult than regular Java apps.
.
I have written some Android applications by Qt\QtQuick without QtQuick Controls. QtQuick is AWESOME for UI development but you need to doing some stuff such as managing load and unload UI manually. It is not a problem, since there is some features in QtQuick for this purpose like Loader
.
Implementing general section of the application (non-specific to Android section) in Desktop is very productive and fast and interesting (both C++ and QtQuick).
But implementing Android specific section in JNI needs more time and care.
.
AnimationFramework
. Using Qt you don't have this problem).
IF (you are not a Qt experienced developer) => Use Java
IF (you need just some more performance for some processing) => Java + C++(NDK)
IF (you are a Qt experienced developer) AND ((you are beginner in Java) OR (you planned to porting your app into other platforms)) => Use Qt with C++
Lets break this into two parts:
1)Will C++ perform better than Java?
Yes. Of course it will. It always does, so long as you don't make to many JNI calls back into Java. That's why people (including Google) use C++ where performance is of the essence.
2)Will QT perform better than using JNI to go back to Java or than using the raw calls available to C++ in the NDK?
Assuming you write both kinds of code optimally, the order is probably raw NDK calls > Java calls > QT calls. The QT library is just going to be making the exact same function calls you would, it just puts a different abstraction layer on it. That layer will add overhead. Chances are that the overhead is minimal most of the time. If you're an experienced QT programmer, you will likely get something coded faster using QT. If you're an experienced Android programmer, you'll get it done faster without it. QT will increase the odds of bugs, because any bugs in the QT layer itself will show through in your code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With