Android-可能有条件地执行外部固定建筑?
使用Kotlin DSL,有人知道我如何告诉Gradle仅在图书馆模块的外部续签块中执行指令,如果 a)存在cmakelists.txt吗?或者 b)基于buildType(调试否,发布是)。
我已经尝试将外部网络构建
块移至buildTypes
块中,但这无效。 我还尝试了类似的几种变体:(
val cMakePath = "src/main/cpp/CMakeLists.txt"
if (File(cMakePath).exists()) {
externalNativeBuild {
cmake {
path(cMakePath)
}
}
}
在我的特定设置中,cmakelists.txt
在发行版构建过程中生成,本机零件仅用于发行版构建。这就是为什么我尝试过的原因)
但是,即使Gradle很高兴 - 就像没有编译器警告或错误一样,我尝试的每个有条件的解决方案都会尝试,我的应用程序失败了,因为
java.lang.UnsatisfiedLinkError: dlopen failed: library "mylibrary.so" not found
很明显,本机LIB并未构建。
我该如何实现所需的行为?
Using Kotlin DSL, does anyone know how I can tell Gradle to only execute the instructions in my library module's externalNativeBuild block if
a) CMakeLists.txt is present? or
b) based on buildType (debug no, release yes).
I've tried moving the externalNativeBuild
block into buildTypes
block, but this did not work.
I've also tried several variations of something like this:
val cMakePath = "src/main/cpp/CMakeLists.txt"
if (File(cMakePath).exists()) {
externalNativeBuild {
cmake {
path(cMakePath)
}
}
}
(In my specific setup, CMakeLists.txt
gets generated during release builds, the native part is only present for release builds. That's why I tried it this way.)
But even if Gradle is happy - as in no compiler warnings or errors, with every conditional solution I try, at startup my app fails because
java.lang.UnsatisfiedLinkError: dlopen failed: library "mylibrary.so" not found
so obviously the native lib doesn't get built.
How can I achieve my desired behaviour?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论