Android Studio JNI development (1) - NDK installation and environment configuration

Android Studio JNI development (1) - NDK installation and environment configuration

Introduction

  1. JNI

JNI (Java Native Interface) is an interface for Java and C/C++ to communicate with each other. It realizes a project and multiple languages ​​coexist. In the Android Framework, it is necessary to provide a medium or bridge to organically connect the Java layer (upper layer) and the C/C++ layer (lower layer), so that they coordinate with each other to complete certain tasks. And what acts as this medium is the Java Native Interface (JNI, Java Native Interface).

JNI provides a series of interfaces that allow Java classes to interact with applications, modules, and libraries written in native editing languages ​​such as C/C++ (in JNI, these languages ​​are called native languages). For example, using the functions in the C language library in the Java class or using the Java class library in the C language requires the help of JNI.

In the Android platform, JNI is used to encapsulate hardware-related operations, so that related JNI modules can be called through Java to achieve calls to hardware.

  1. GDR

Native Development Kit (NDK) is a set of tools that provides a series of tools to quickly develop C/C++ dynamic libraries, and can automatically package .so/.dll and Java applications into Apk, enabling you to use C in Android applications and C++ code, and provides a number of platform libraries that you can use to manage native activities and access physical device components, such as sensors and touch input.

Simply put, JNI is responsible for the interoperability between Java and C/C++, and NDK provides tools to facilitate the use of JNI on the Android platform.

NDK installation configuration

  1. Open Android Studio to create a new project, click Tools on the toolbar ----> SDK Manager ----> SDK Tools, check the NDK and CMake options, and click Apply to download and install.

insert image description here

  1. Environment configuration, open the environment variable, and add the installation path of ndk to PATH.
    insert image description here

  2. To verify, open the cmd command line and enter ndk-build to verify whether the installation and configuration are successful.
    insert image description here

Guess you like

Origin blog.csdn.net/tracydragonlxy/article/details/121314480