nativeLibsToJar的魔力是什么 [英] what is the magic of nativeLibsToJar
本文介绍了nativeLibsToJar的魔力是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下代码片段似乎是如何在Android Studio中包含本机库的答案:
The following code snippet seems to be the answer how to include native libraries with Android Studio:
task nativeLibsToJar(type: Zip, description: 'create a jar archive of the native libs') {
destinationDir file("$buildDir/native-libs")
baseName 'native-libs'
extension 'jar'
from fileTree(dir: 'libs', include: '**/*.so')
into 'lib/'
}
tasks.withType(Compile) {
compileTask -> compileTask.dependsOn(nativeLibsToJar)
}
似乎只是将* .so打包到* .jar中.但我真的不明白:
- 为什么有必要将其包装在 * .jar?
- 更改本机库中的某些内容时,我可以看到更改在我的应用程序中生效,并且Gradle构建过程始终会在输出日期之前输出"...:app:nativeLibsToJar" ...".因此,我假设此任务没有重新运行.但是,当此任务将* .so包装在* .jar中时,如何在不重新运行此任务的情况下重新包装它们?
- Why is it necessary to wrap it in a *.jar?
- When changing something in my native libraries, I can see the changes taking effect in my Application, also the Gradle building process always outputs "...:app:nativeLibsToJar UP-TO-DATE...". So I assume this task is not re-run. But when this task wraps the *.so in *.jar than how is it possible to re-wrap them without rerunning this task??
It seems to simply pack the *.so into *.jar. But I really don't understand it:
我对每一个解释都很感谢:)
I am thankful for every explanation :)
推荐答案
这真的很有趣-我找到了很多次作为解决方案:
That's really funny - I found this as solution so many times:
task nativeLibsToJar(type: Zip, description: 'create a jar archive of the native libs') {
destinationDir file("$buildDir/native-libs")
baseName 'native-libs'
extension 'jar'
from fileTree(dir: 'libs', include: '**/*.so')
into 'lib/'
}
但是可以将其删除,因为它没有任何用处(也许在较早的build版本中有用).
But it can be removed because it does nothing useful (maybe it did in older build-versions).
真正的把戏是通过sourceSets.main.jniLibs.srcDir 'src/main/libs/' //integrate your libs from libs instead of default dir 'jniLibs
这篇关于nativeLibsToJar的魔力是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文