中文

Experience Sharing: Android Studio NDK development

NDK Related Directories

1. app/src/main/java
for java source codes
2. app/src/main/jni
for header files generated by javah, c/c++ sources
3. app/src/main/jniLibs
for native libraries (so files)
4. app/libs
for jar files (must compiled by jdk7)

Condition One: import from external resources

1. Already having jar and so files

copy jar files to app/libs;
copy so files to app/src/main/jniLibs;

2. Make jar and so files from zero

1) Make jar
jar cvf some.jar class_files...

2) Make so

a. Copy one of Android NDK samples
b. Generate header file by javah command, wirte c/c++ implementation file, save it to jni folder
c. Modify LOCAL_MODULE and LOCAL_SRC_FILES in Android.mk, change its value to your own library name and source file name
d. Execute ndk-build command, so file should created under libs folder
e. Import jar and so files

Condition Two: NDK Development Inside Android Studio

1. Download Android NDK package and unzip it to some directory
2. In Android Studio, set NDK path
3. Write java file with native methods
4. Use javah command to generated .h file in app/src/main/jni directory
5. Write c/c++ file, save it in app/src/main/jni directory
6. Build and run
Products: Sealion Seacat Seaflower Seaspider Seasnipe Seastar Seadog Jiong WBXL Xultray webapp
iDocSet iDocSetHelper Blink templateJS
(C) 2017 ZHUATANG.COM, All rights reserved

update: 2015-9-21