Search code examples
javaandroid-studiojava-native-interface

How to add JNI sources to my project in Android Studio?


I'm using Android Studio 2.2.3 and I have a nice jniLibs directory created by AS when importing Eclipse project. It took the jar file with .so files and it created a nice structure for every architecture:

jniLibs tree

I, however, have sources of those libraries and I would like to add them to the structure, so I could edit them and debug easily. How should I proceed? The only relevant entry I have in my build.gradle file is:

dependencies {
    compile files('libs/sdk.jar')
}

Thank you


Solution

  • I was able to do this by removing the dependencies section and adding:

    sourceSets {
        main {
            jniLibs {
                srcDirs = ['jni/db', 'jni/minizip', 'jni/roxml']
            }
    
        }
    }
    

    Now I can nicely track my source code in Android Studio.