如何包括*在Android的工作室.so库? [英] How to include *.so library in Android Studio?
问题描述
我看了很多线程如何添加* .so库到Android工作室,但他们没有工作,特别是当它涉及到文字的一点:这并不与新的XXX(Android的工作室,摇篮,工作。 ..)
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的工作室0.6.0
Android Studio 0.6.0
从项目结构我看到:
SDK位置:
/usr/share/android-studio/data/sdk
/usr/lib/jvm/default-java
项目:
Gradle version 1.10
Android Plugin Version 0.11.+
模块/应用程序: 属性:
Modules/app: Properties:
编译SDK版本19 构建工具版本19.1.0
Compile Sdk Version 19 Build Tools Version 19.1.0
依赖关系:
{dir=libs, include=[*.jar]} Compile
{dir=libs, include=[*.so]} Provided
m com.android.support: appcompat -v7:19.+ Compile
我得到了* .so文件pre编译和演示程序,他们正在努力。我要改变应用程序的源$ C $ C,所以我需要重建使用相同的* .so文件。
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.
推荐答案
在这里,我是如何完成它。同时添加$ C $ C片段在你的模块gradle.build文件
Here how i have it done. Add both code snippets in your module gradle.build file
作为依赖性:
compile fileTree(dir: "$buildDir/native-libs", include: 'native-libs.jar')
如何创建这个定制的jar:
how to create this custom jar:
task nativeLibsToJar(type: Jar, description: 'create a jar archive of the native libs') {
destinationDir file("$buildDir/native-libs")
baseName 'native-libs'
from fileTree(dir: 'libs', include: '**/*.so')
into 'lib/'
}
tasks.withType(Compile) {
compileTask -> compileTask.dependsOn(nativeLibsToJar)
}
同样的答案也可以在相关的问题发现:<一href="http://stackoverflow.com/questions/16683775/include-so-library-in-apk-in-android-studio?rq=1">Include 。所以在APK中的Android工作室库
更新拉着建议修改评分(切换到'罐子'任务类型,删除文件扩展名线)
UPDATE took suggested changes from review (Change to 'Jar' task type, removing the file extension line)
这篇关于如何包括*在Android的工作室.so库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!