如何将.so库包含到Android Studio项目中

时间:2015-11-16 08:38:34

标签: android sdk .so

我在我的项目中使用了新浪SDK。我们必须包含它的.so libs。但我不知道如何包含它。 enter image description here

我把.so libs放在我的jniLibs文件夹中。然后我不知道如何编写gradle代码来包含它们。

// Copy *.so files from libs/ folder of your project to native-libs folder
// Adjust if your native libraries are somewhere else..
task copyNativeLibs(type: Copy) {
    from(new File(project(':yourproject').projectDir, 'libs')) { include '**/*.so' }
    into new File(buildDir, 'native-libs')
}

// Whenever the code is compiled, also copy the native libs to the build folder
tasks.withType(Compile) { compileTask -> compileTask.dependsOn copyNativeLibs }

// On "gradle clean" also reverse the copying of the native libraries
clean.dependsOn 'cleanCopyNativeLibs'

// Include the native-libs folder into the final APK
tasks.withType(com.android.build.gradle.tasks.PackageApplication) { pkgTask ->
    pkgTask.jniDir new File(buildDir, 'native-libs')
}

我从网络中找到代码,我不知道如何为我的项目编写代码。

0 个答案:

没有答案