How to fix gradle task ':app:mergeDebugJniLibFolders' in flutter gradle build for opencv native with NDK?

非 Y 不嫁゛ 提交于 2019-12-14 02:20:15

问题


I'm setting up a new flutter app and I want to add opencv native (c++) plugin using NDK.

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

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.


回答1:


I found a solution !

I get in my build.gradle those lines:

sourceSets {
    main {
        jniLibs.srcDirs = ['src/main/libs']
        java.srcDirs = ['src']
        ...
    }
 }

So I decided to open the src/main/libs file which contain only

../../../../OpenCV-Andoid-sdk/native/libs/

... a wrong path that should be :

../../../../sdk/native/libs/

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...



来源:https://stackoverflow.com/questions/54450398/how-to-fix-gradle-task-appmergedebugjnilibfolders-in-flutter-gradle-build-fo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!