编译gradle时出错 - '无法找到方法源()'

时间:2016-08-03 21:48:54

标签: android c++ gradle android-ndk

我正在尝试通过包含CPP文件来编译Android studio中的Gradle文件。但是我得到了这个错误:

Error:(37, 0) Could not find method sources() for arguments [build_4ebkggkawsqgr6xhsg6qsm89y$_run_closure1$_closure3$_closure7$_closure8@25140] on object of type com.android.build.gradle.internal.dsl.NdkOptions.

它被弃用了吗? 我的代码如下所示:

apply plugin: 'com.android.library'
apply plugin: 'maven'
apply plugin:  'cpp'

android {
    publishNonDefault true

    compileSdkVersion 23
    buildToolsVersion '23.0.2'

    defaultConfig {
        minSdkVersion 19
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"

        ndk {
            moduleName = "xxxNative"
            ldLibs "dlib"
            ldLibs.addAll(["opencv_shape", "lopencv_stitching",
                           "lopencv_objdetect", "lopencv_superres", "lopencv_videostab",
                           "lopencv_calib3d", "lopencv_features2d", "lopencv_videoio",
                           "lopencv_imgcodecs", "lopencv_video", "lopencv_photo",
                           "lopencv_core", "llibjpeg", "llibpng",
                           "llibtiff", "lzlib", "llog",
                           "lgnustl_static"])

            stl = 'gnustl_shared'

            sources {
                cpp {
                    source {
                        srcDirs "src/main/jni"
                        include "*.cpp"
                    }
                }
            }
        }
    }

    buildTypes {
        debug {
            minifyEnabled false
            versionNameSuffix "-debug"
        }

        release {
            minifyEnabled false
            shrinkResources true
            debuggable false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), '../proguard-rules.pro'
        }
    }

    lintOptions {
        abortOnError false
        textReport true
        textOutput 'stdout'
    }

    dexOptions {
        incremental true
        //preDexLibraries = rootProject.ext.preDexEnabled
        javaMaxHeapSize "3g"
    }
}

dependencies {
    compile project(path: ':testApp')
    compile 'com.android.support:appcompat-v7:23.2.1'
}

感谢。

0 个答案:

没有答案