如何更改 Gradle 中的 libs 目录? [英] How to change libs directory in Gradle?
问题描述
我想将 Zbar 集成到我的应用程序中,但似乎无法弄清楚如何使用新的 Android Studio 来实现这一点.
I want to integrate Zbar into my application but cant seem to figure out how to accomplish this using the new Android Studio.
我已经查看了示例并复制了代码,没有任何问题.我遇到的问题是将库添加到我的项目中,我似乎无法弄清楚如何去做.有人可以带我过去吗?
I have looked through the example and have copied over the code without any issues. The problem I am having is adding the libs to my project I cant seem to figure out how to do it. Could someone walk me through it?
推荐答案
其实@Michael 的回答是正确的,也是过时的.现在,使用 gradle 您需要做的就是在 build.gradle 文件中添加以下几行:
Actually, @Michael's answer is correct, it is also obsolete. Now, using gradle all you need to do is to add the lines below in the build.gradle file:
android {
...
sourceSets {
main.jniLibs.srcDirs = ['libs']
test.jniLibs.srcDirs = ['libs']
}
}
或直接将您的 .so 库放入:
or directly put your .so libraries into:
src/main/jniLibs
src/main/jniLibs
这样,当您构建应用程序或库时,jni 库会被复制到目标 .jar/.aar 文件中.
This way, when you build your application or library, the jni libraries are being copied into destination .jar/.aar file.
这篇关于如何更改 Gradle 中的 libs 目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!