Integrating .so files into your APK

With the recent changes (release 0.7.3 around Dec 27), the new Android Build System starts to be really interesting also if you are using the NDK!

0.7.2Add jniLibs folder to source sets for prebuilt .so files.

Now this is really easy to integrate native libraries in your package and generate APKs for different architectures while correctly handling version codes (for more information on why this may be important, please refer to my first article).

 

If you are using Android Studio and need to integrate native libraries in your app, you may have had to use some complex methods before, involving maven and .aar/.jar packages… the good news is you don’t need these anymore :)

jniLibs

You only need to put your .so libraries inside the jniLibs folder under sub-directories named against each supported ABI (x86, mips, armeabi-v7a, armeabi), and that’s it !

Once it’s done, all the .so files will be integrated into your apk when you build it:

fatbinary

If the jniLibs folder name doesn’t suit you (you may generate your .so files somewhere else), you can set a specific location in build.gradle:

 

android {
    ...
    sourceSets.main {
        jniLibs.srcDir 'src/main/libs'
    }
}

 

Via: http://ph0b.com/android-studio-gradle-and-ndk-integration/

posted on 2015-04-25 15:58  veins  阅读(213)  评论(0编辑  收藏  举报

导航