How to include *.so library in Android Studio?

Ronald Wiplinger picture Ronald Wiplinger · Jun 23, 2014 · Viewed 202.7k times · Source

I read many threads how to add a *.so library to Android Studio, but none of them works, especially when it comes to the point of text: This does not work with the newer xxx (Android Studio, gradle, ...)

Can we make a fresh start please. I got:

Android Studio 0.6.0

From Project Structure I see:

SDK Location:

/usr/share/android-studio/data/sdk
/usr/lib/jvm/default-java

Project:

Gradle version 1.10
Android Plugin Version 0.11.+

Modules/app: Properties:

Compile Sdk Version 19 Build Tools Version 19.1.0

Dependencies:

{dir=libs, include=[*.jar]} Compile

{dir=libs, include=[*.so]}  Provided

m com.android.support: appcompat -v7:19.+   Compile

I got the *.so files pre-compiled and at the demo app they are working. I have to change the source code of the app, so I need to rebuild with the same *.so files.

Answer

Vasanth picture Vasanth · Feb 10, 2015

Adding .so Library in Android Studio 1.0.2

  1. Create Folder "jniLibs" inside "src/main/"
  2. Put all your .so libraries inside "src/main/jniLibs" folder
  3. Folder structure looks like,
    |--app:
    |--|--src:
    |--|--|--main
    |--|--|--|--jniLibs
    |--|--|--|--|--armeabi
    |--|--|--|--|--|--.so Files
    |--|--|--|--|--x86
    |--|--|--|--|--|--.so Files
  4. No extra code requires just sync your project and run your application.

    Reference
    https://github.com/commonsguy/sqlcipher-gradle/tree/master/src/main