#ndk on andorid studio for mac ##1.Configure JDK, NDK path environments ####I'm using jdk 1.8.0_45 and official ndk. ##2. Add javah, ndk-build as External Tools (Menu Location is 'Settings > Tools > External Tools') ###2-1. Configure javah ###2-2. Configure ndk-build ###2-3. Configure ndk-build clean ##3. Create a new Android Studio Project ##4. Add a java class for JNI ##5. Create a folder for JNI ##6. Configure build.gradle
android {
...
defaultConfig {
...
ndk {
moduleName "your dllname"
}
sourceSets.main {
jni.srcDirs = []
jniLibs.srcDir "src/main/libs"
}
...
}
...
}
##7. First Build ####We will encounter an error like 'Error: NDK integration is deprecated in the current plugin. blah blah'. ####Because we are not using the experimental class for NDK.
####Let's add one line in 'gradle.properties'.
android.useDeprecatedNdk=true
####And build again, it must be succeeded.
##8. Create a JNI header file ####Use 'NDK external tools - javah' ####Then we will have a JNI header file. ##9. Create a C++ source file
####We don't need to check "Create associated header".
##10. Create some MakeFiles
##12. Let's Use Our NDK Library Function ##13. Final Build and Create APK