1. Path environment variable
2. Android Studio Associated NDK
Local.properties Ndk.dir
Gradle.properties android.usedeprecatedndk=true//compatible old version
3. Build.gradle Configuration
defaultconfig{
ndk{
ModuleName "Hello"
Abifilters "Armeabi", "armeabi-v7a", "x86"
}
}
4, according to the upper Java native function, can automatically generate the corresponding header file
Console execution: Javah-calsspath. Path file
5. Use Android_log_print to add Log library to the build configuration
If you are using the official version of Gradle, add ldlibs " in the NDK label Span style= "COLOR: #800000" >log " If you are using experimental version gradle, add: Ldlibs.add ( " ) If you use Cmakelists, in TARGET_LINK_ Libraries tag Add log if you are using a Mk file, add the following statement: local_ldlibs: =-llog
// print a simple info-level log corresponding to Java log.i ("JNI", " This is log ") __android_log_print (Android_log_info, " jni ", " this is log " // print a formatted string here is the format used in printf in the C language. About the printf formatted output in C can self-Baidu, the document is very many. int i=5 ;__android_log_print (Android_log_info, " jni ", " i=%d " , i);
Android Studio NDK Development Summary