Run is not compatible with components of your project written in native
Which returns "Hello from C++", and uses it to update the TextView.
For new projects, Android Studio creates a CMake build script,ĬMakeLists.txt, and places it in your module’s root directory.
Similar to how adle files tell Gradle how to build yourĪpp, CMake and ndk-build require a build script to know how to build your Source files to your project in the section about how to This sampleĬode provides a simple C++ function, stringFromJNI(), that In the src/main/cpp/ directory of your app module. For new projects, Android StudioĬreates a sample C++ source file, native-lib.cpp, and places it Libraries that are a part of your project. Source files, headers, build scripts for CMake or ndk-build, and prebuilt The cpp group is where you can find all the native On disk, but groups similar files to simplify navigating your project. Note: This view does not reflect the actual file hierarchy Android view groups for your native sources As shown in figure 2, Android Studio adds theįigure 2. Project pane from the left side of the IDE and select theĪndroid view. Selecting ToolchainĪfter Android Studio finishes creating your new project, open the Select which standardization of C++ you want to use. Your project with the C++ Standard field. In the Customize C++ Support section of the wizard, you can customize
You do not need this component if you only plan to use ndk-build.ĭebugger Android Studio uses to debug native code.įor information on installing these components, see Install and configure the NDK, CMake, andĬreating a new project with support for native code is similar to (NDK): a toolset that allows you to use C and C++ code withĪndroid, and provides platform libraries that allow you to manage nativeĪctivities and access physical device components, such as sensors and touchĮxternal build tool that works alongside Gradle to build your native To compile and debug native code for your app, you need the following The experimental version of Gradle and the Android plugin. Version of the Gradle build system or you want support for add-on tools, Native project already uses CMake or ndk-build you would rather use a stable To build your native libraries if any of the following apply to you: Your Migrating to plugin version 2.2.0 or higher, and using CMake or ndk-build To learn more, go to the section about how toĪttention experimental Gradle users: Consider NdkCompile tool, you should migrate to using either CMake or Note: If your existing project uses the deprecated Java or Kotlin code using the JNI framework. Once you configure your project, you can access your native functions from Studio project and package your native library (the SO file) into the Gradle uses the build script to import source code into your Android Gradle by providing a path to your CMake or ndk-build script file.