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

时间:2016-10-18 10:52:39

标签: android gradle jgrapht

我试图使用Jgrapht库,但它需要lambdas ......

这是我的代码:

    // Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        maven {
            url "https://plugins.gradle.org/m2/"
        }
        jcenter()
    }
    dependencies {
        classpath "gradle.plugin.me.tatarka:gradle-retrolambda:3.3.0"
        classpath 'com.android.tools.build:gradle:2.2.1'
    }
}
allprojects {
    repositories {
        jcenter()
        mavenCentral()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

和:app

apply plugin: "me.tatarka.retrolambda" version "3.3.0"
apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "24.0.3"
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
        applicationId "it.univpm.gruppoids.iotforemergencyandnavigation"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"

       jackOptions {
            enabled true
        }
    }



    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.android.support:design:23.4.0'
    compile 'com.android.support:support-v4:23.4.0'
    compile 'com.journeyapps:zxing-android-embedded:3.2.0@aar'
    compile 'com.google.zxing:core:3.2.1'
    compile 'org.jgrapht:jgrapht-core:1.0.0'
}

错误是:错误:(1,0)无法在null对象上调用方法version() 打开文件 哪里有什么错误?感谢

2 个答案:

答案 0 :(得分:5)

您正在混合使用两种语法。使用

var_dump

buildscript {
    repositories {
       mavenCentral()
    }
    dependencies {
        classpath "gradle.plugin.me.tatarka:gradle-retrolambda:3.3.0"
    }
}

apply plugin: 'me.tatarka.retrolambda'

gradle-retrolambda README),另见the gradle documentation

答案 1 :(得分:2)

我有同样的问题。 您需要更新一些内容:

android / build.gradle:

i)类路径'com.google.gms:google-services:4.0.1'

ii)确保在构建脚本和所有项目中google()都出现在jcenter()上方

android / app / build.gradle:

将Android库更新为此处指定的最新版本:

https://firebase.google.com/support/release-notes/android#20180523

如果您还有其他库(对我来说,这是firebase),请确保也检查这些库的build.gradle。