Issue
Using Android Studio 1.2.1.1 with Gradle 1.2.3. I have an NDK library project A that produces a number of .so files in its own libs folder. Though, I cannot see the reference to this folder anywhere in the build.gradle file.
When I reference library A from my app MyApp I would expect the .so files to be copied to MyApp/src/main/jniLibs, but they aren't. Do I have to manually copy these files every time I make a change in the A library?
How can I automate this step?
Solution
I does not know if ther is a way to have you .so files copied as you want whiout wirtting anything.
But you could have gradle doing it for you.
In your gradle file, add a task that copy those .so files where you need them to be.
android {
...
sourceSets.main {
jni.srcDirs = []
jniLibs.srcDir 'src/main/libs'
}
//copying files
task copyNativeLib(type: Exec, description: 'Copy native file') {
commandLine 'cp <path_of_so_files> src/main/libs'
}
//add dependencies
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn copyNativeLib
}
}
Or maybe just
android {
...
sourceSets.main {
jni.srcDirs = []
jniLibs.srcDir '<path_to_your_so_files>'
}
}
Answered By - sonic
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.