Native C++ Android project template

In this section we begin the development cycle by showing you what to select in your Android Studio options. Here are step by step instruction on what you need to do.

  1. Create a project using the Native C++ Project Template, as you can see in the following screenshot:
    Android editor
  2. Set the application name to Neon Intrinsics, selected Java as the language, and set the minimum SDK to API 19: Android 4.4 (KitKat) as shown in the follow screenshot:

    Android editor
  3. Select Toolchain Default for the C++ Standard, as shown in the following screenshot:

    Android editor

The project that you created comprises one activity that is implemented within the MainActivity class, deriving from AppCompatActivity which you can see at app/java/com.example.neonintrinsics/MainActivity.java for further information. The associated view contains only a TextView control that displays the string: “Hello from C++, as you can see in the following image:
Android editor

To get these results, run the project directly from Android Studio using one of the emulators. To build the project successfully:

  1. You must install CMake along with the Android NDK. You can do this through File > Settings. Then select NDK and CMake on the SDK Tools tab.

    Android editor
  2. Open the MainActivity.java file. The string that is displayed in the app comes from native-lib. The code for this library is in the app/cpp/native-lib.cpp file. That file is used for the implementation.
Previous Next