Android Studio 为工程添加.so库

1.把文件copy到libs下。

2.在app/build.gradle文件的android层级下添加。

sourceSets.main {
jniLibs.srcDir 'libs'
}

问答链接 http://stackoverflow.com/questions/24357687/how-to-include-so-library-in-android-studio/28430334#28430334

Solution 1 : Creation of a JniLibs folder

Create a folder called “jniLibs” into your app and the folders containing your *.so inside. The "jniLibs" folder needs to be created in the same folder as your "Java" or "Assets" folders.

Solution 2 : Modification of the build.gradle file

If you don’t want to create a new folder and keep your *.so files into the libs folder, it is possible !

In that case, just add your *.so files into the libs folder (please respect the same architecture as the solution 1 : libs/armeabi/.so for instance) and modify the build.gradle file of your app to add the source directory of the jniLibs.

sourceSets {
        main {
             jni.srcDirs = ["libs"]
             }
           }

You will have more explanations, with screenshots to help you here ( Step 6 ):

http://blog.guillaumeagis.eu/setup-andengine-with-android-studio/

原文地址:https://www.cnblogs.com/StuLiuJun/p/5091279.html