Jni Folder In Android Studio
Solution 1:
Nowadays there is an easier method than the accepted answer.
All you have to do is create a folder called "jniLibs" under your /src/main directory (ie, /app/src/main/jniLibs) and place your .so files there. It will look like this:
app
|
src
|
main
|
jniLibs
|
armeabi
| |
| your_lib_compiled_for_armeabi.so
|
armeabi-v7a
| |
| your_lib_compiled_for_v7a.so
|
x86
| |
| your_lib_compiled_for_x86.so
Your .so files should be picked up now.
Solution 2:
There is other way to import so to the android project.
- create the lib dir and armeabi dir like this, and copy so to it. |-project |--lib |----armeabi |------libhello-jni.so
- zip the dir lib.
- put the zip to the libs dir of project, and change .zip to .jar.
- add code to the dependencies part of build.gradle. compile fileTree(dir:'libs', include:'lib.jar')
Solution 3:
add this to your build.gradle:
sourceSets {
main {
jniLibs.srcDir 'jniLibs'
}
}
underneath:
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
Solution 4:
You can add pre built *.so files in Android Studio using gradle 0.7.2+. First create the jniLibs at this location /app/src/main/ location and copy the all the folder with *.so files (armeabi, armeabi-v7a, mips, x86) in the jniLibs.
As Xavier said same here https://groups.google.com/forum/#!msg/adt-dev/nQobKd2Gl_8/ctDp9viWaxoJ
Solution 5:
The gradle build system does not support bundling native libraries at the moment. Check https://groups.google.com/d/msg/adt-dev/nQobKd2Gl_8/Z5yWAvCh4h4J for some custom tasks you'd need to add to your build.gradle.
Note that this is a temporary workaround until gradle supports building native projects.
Post a Comment for "Jni Folder In Android Studio"