I Need Loadlibrary Two So Library Files On Android Studio V1.1.0
I had an examples for two so files for one app which is very simple, and I just have tried to do same code on Android Studio 1.1.0. I refer many web sites, so I put my so files on
Solution 1:
you have two solutions to use more than one ndk lib from an Android Studio project.
1) remove the jni folder from your Android Studio project, compile your .so files from anywhere outside of your Android studio project, directly using ndk-build, and put them under src/main/jniLibs/(armeabi-v7a, x86, ...)/
2) keep your jni folder with your sources and Makefiles, deactivate the built-in call to ndk-build, change the location of jniLibs to libs, and add a call to ndk-build. In summary, put this inside your build.gradle file:
import org.apache.tools.ant.taskdefs.condition.Os
apply plugin: 'com.android.application'
android {
...
sourceSets.main {
jniLibs.srcDir'src/main/libs'//set .so files directory to libs
jni.srcDirs = [] //disable automatic ndk-build call
}
// call regular ndk-build(.cmd) script from app directory
task ndkBuild(type: Exec) {
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
commandLine 'ndk-build.cmd', '-C', file('src/main').absolutePath
} else {
commandLine 'ndk-build', '-C', file('src/main').absolutePath
}
}
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn ndkBuild
}
}
If you're still encountering issues, look if your .so files are getting properly packaged inside your APK, under lib/(armeabi-v7a, x86, ...)
, by opening it as a zip file. If that's the case, the issue isn't on packaging.
Post a Comment for "I Need Loadlibrary Two So Library Files On Android Studio V1.1.0"