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.
- Create a project using the Native C++ Project Template, as you can see in the following screenshot:
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:
Select Toolchain Default for the C++ Standard, as shown in the following screenshot:
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:
To get these results, run the project directly from Android Studio using one of the emulators. To build the project successfully:
- You must install
CMakealong with the Android NDK. You can do this through File > Settings. Then select NDK and CMake on the SDK Tools tab.
- Open the
MainActivity.javafile. The string that is displayed in the app comes from
native-lib. The code for this library is in the
app/cpp/native-lib.cppfile. That file is used for the implementation.