如何在NDK的opencv本机的gradle gradle构建中修复gradle任务':app:mergeDebugJniLibFolders'? [英] How to fix gradle task ':app:mergeDebugJniLibFolders' in flutter gradle build for opencv native with NDK?
问题描述
我正在设置一个新的flutter应用程序,我想使用NDK添加opencv本机(c ++)插件.
I'm setting up a new flutter app and I want to add opencv native (c++) plugin using NDK.
我已经安装并配置了OpenCV和NDK(使用不同的教程),而我在尝试构建项目(flutter run
)时遇到此错误:
I've installed and configured OpenCV and NDK (using differents tutorials) and I got this error while I'm trying to build my project (flutter run
):
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeDebugJniLibFolders'.
> java.lang.NullPointerException (no error message)
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --
debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 31s
Finished with error: Gradle task assembleDebug failed with exit code 1
我不知道它来自哪里,我的应用程序build.gradle
中没有任务" mergeDebugJniLibFolders
.
我不能用指定的参数来颤动:它会出错.
I don't know where it come from, there is no 'task' mergeDebugJniLibFolders
in my build.gradle
from my app.
I can't run flutter with specified arguments : it make errors.
推荐答案
我找到了解决方案!
我进入build.gradle
这些行:
sourceSets {
main {
jniLibs.srcDirs = ['src/main/libs']
java.srcDirs = ['src']
...
}
}
所以我决定打开仅包含
../../../../OpenCV-Andoid-sdk/native/libs/
...应该是错误的路径:
... a wrong path that should be :
../../../../sdk/native/libs/
我将corect路径放入gradle文件中,尊重新的相对路径:
I put the corect path into the gradle file respecting the new relative path :
sourceSets {
main {
jniLibs.srcDirs = ['../../sdk/native/libs/']
java.srcDirs = ['src']
...
}
}
现在,它可以完美编译了!我度过了六个晚上真是一个棘手的错误...
And now it compile perfectly ! What a tricky error on which I spend 6 evenings...
这篇关于如何在NDK的opencv本机的gradle gradle构建中修复gradle任务':app:mergeDebugJniLibFolders'?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!