Jan Roorda Jan Roorda - 2 months ago 22
Android Question

How is C/C++ code in an Android App executed?

I'm working on an Android app which uses OpenCV to do some intensive computer vision operations. At this point I am wondering if I can get a better performance if I do the vision processing in C/C++ instead of Java. The rest of the App is written in Java using Android Studio.

I am confused how C/C++ code is compiled and runned on Android devices. Since a Java app runs on a JVM on the Android platform I don't quite understand how the C/C++ code is compiled for the JVM and how this code runs.

I'm thinking if the C/C++ code is compiled so that it can run in the JVM, what is the point of using it since its still running in a VM and not directly targetting the devices CPU?


NDK is used for coding in C/C++. It improves application performance. NDK is usually true for many processor-bound applications

Native code(C/C++) is compiled to a binary code and run directly on OS. Java code is translated into Java byte-code to run on JVM.

You can use NDK for programming C/C++ application. You can also use QT for andriod for developing C/C++ application