Gradle Build - 无法在null对象

时间:2018-03-09 02:42:48

标签: null

我有以下错误,已经在圈子里进行了几天,会感激任何想法。

这曾经在早期版本的Gradle中工作,但是现在它已经窒息了。我目前正在使用4.1 谢谢。

无法在null对象上调用方法(add)

    productFlavors {
    create("armv7") {
        ndk.abiFilters.add("${basedir}/src/main/jniLibs/armeabi-v7a")

以下是完整列表;

apply plugin: 'com.android.library'

def basedir = projectDir.absolutePath


android {
compileSdkVersion 22
buildToolsVersion '27.0.3'
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_7
    targetCompatibility JavaVersion.VERSION_1_7
}
defaultConfig {
    minSdkVersion 22
    targetSdkVersion 22
}
productFlavors {
    create("armv7") {
        ndk.abiFilters.add("${basedir}/src/main/jniLibs/armeabi-v7a")
        String libsDir = "${basedir}/src/main/jniLibs/armeabi-v7a/"
        ndk.ldLibs.addAll([
                libsDir + "libopencv_legacy.a",
                libsDir + "libopencv_calib3d.a",
                libsDir + "libopencv_features2d.a",
                libsDir + "libopencv_flann.a",
                libsDir + "libopencv_imgproc.a",
                libsDir + "libopencv_highgui.a",
                libsDir + "libopencv_contrib.a",
                libsDir + "libopencv_objdetect.a",
                libsDir + "libopencv_core.a",
                libsDir + "libtbb.a",
                libsDir + "liblibtiff.a",
                libsDir + "liblibpng.a",
                libsDir + "liblibjpeg.a",
                libsDir + "liblibjasper.a",
                libsDir + "libIlmImf.a",
        ])
    }
}
ndk {
    moduleName = "biocore"
    stl = "gnustl_shared"

    cppFlags.add("-std=c++11")
    cppFlags.add("-frtti")
    cppFlags.add("-fexceptions")

    cppFlags.add("-I${basedir}/src/main/headers".toString())
    cppFlags.add("-iquote${basedir}/src/main/jni".toString())

    ldLibs.addAll(["android","log","atomic","z"])
}
buildTypes {
    debug {
        minifyEnabled = false
    }
    release {
        minifyEnabled = false
    }
}
}

dependencies {
}

这是项目Gradle

buildscript {
repositories {
    mavenLocal()
    mavenCentral()
    jcenter()
    google()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.0.1'


    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}
allprojects {
repositories {
    mavenLocal()
    mavenCentral()
    jcenter()
    maven {
        // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
       url "$rootDir/../node_modules/react-native/android"
    }
    google()
}
}

0 个答案:

没有答案