Including external jniLibs with experimental grade plugin

159 views
Skip to first unread message

Gary Bak

unread,
Oct 8, 2015, 1:25:45 PM10/8/15
to android-ndk
I'm attempting to use AndroidStudio with the experimental 0.2.0 plugin to edit a few C sources in our large NDK project.  Iv'e hacked up a small project that includes only the sources I need to edit and all the headers it depends on.  With a creative set of CFlags, ldFlags and ldLibs, Iv'e managed to get the project to compile.  

The problem I have is adding the .so files that are built from another project to the apk.  I've created a job that copies the shared objects to the local jniLibs directory, but they are never included in the apk.  I've managed to include them by copying them into the intermediate gradle directory, but that hack does not survive a clean build.

I've tried the directories src/main/lib, src/main/libs and src/main/jniLibs.  Defining a jniLibs srcDir seems to have no affect.

model {
  android.sources {
        main.jni.source.srcDir 'src/main/config'
        main.jni.source.srcDir '../../../../drivers/audio/android'
        main.jni.source.srcDir '../../../../drivers/audio/android/incl'
        main.jni.source.srcDir '../../../../common/incl'
        main.jni.source.srcDir '../../../../common/clib/incl'
        main.jni.source.srcDir '../../../../common/utils/incl'
        
        main.jniLibs.source.srcDir '../../../../libs'
  }
}

Is there any way of including external libraries with the experimental plugin?





Gary Bak

unread,
Oct 9, 2015, 1:12:25 PM10/9/15
to android-ndk
Adding in my own copy seems to be my only solution for now:

task copyLibs(type: Copy) {
    def source = file("" + projectDir + File.separator + "/../../../../path/to/project/src/main/obj/local/armeabi-v7a").toPath().normalize()
    from source.toString()
    include "*.so"
    exclude "libSomeFile.so"
    into 'build/intermediates/binaries/debug/arm/lib/armeabi-v7a'
}
tasks.whenTaskAdded { currentTask ->
    if ( currentTask.name == "preDexArmDebug") {
        currentTask.dependsOn copyLibs
Reply all
Reply to author
Forward
0 new messages