O'Reilly logo

Pro Android Apps Performance Optimization by Hervé Guihot

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Mixing Java and C/C++ Code

Calling a C/C++ function from Java is actually quite easy but requires several steps:

  1. The native method must be declared in your Java code.
  2. The Java Native Interface (JNI) glue layer needs to be implemented.
  3. Android makefiles have to be created.
  4. The native method must be implemented in C/C++.
  5. The native library must be compiled.
  6. The native library must be loaded.

It really is easy in its own twisted way. We will go through each one of these steps, and by the end of this section, you will know the basics of mixing Java and C/C++. We will discuss the more intricate details of the Android makefiles, which allow you to optimize your code even more, in later sections. Since the Android NDK exists for Linux, MacOS X, and ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required