5

i'm trying to use the Jgrapht library but it needs lambdas...

Here's my code:

    // 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
}

And the :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'
}

The error is: Error:(1, 0) Cannot invoke method version() on null object Open File Where and what is the error? thanks

Piero Tozzi
  • 219
  • 2
  • 3
  • 4

2 Answers2

7

You're mixing two kinds of syntaxes. Use either

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

apply plugin: 'me.tatarka.retrolambda'

or

plugins {
  id "me.tatarka.retrolambda" version "3.3.0"
}

(gradle-retrolambda README), see also the gradle documentation.

weston
  • 54,145
  • 21
  • 145
  • 203
Michael
  • 57,169
  • 9
  • 80
  • 125
  • And in the second form, no need for `classpath` correct? – weston Oct 18 '16 at 11:46
  • _"Instead of combining a `buildscript` script block and an `apply` statement, both statements can be replaced by a `plugins` script block"_ I interpret that as a "Yes" to your question. But I haven't used this syntax myself, so I can't say for sure. – Michael Oct 18 '16 at 11:50
  • i am facing the same issue in `versioning.gradle` file and error is `Cannot invoke method endsWith() on null object` can you please help for same – Arbaz.in Sep 23 '20 at 06:46
2

I have the same issue. You'll need to update a few things:

android/build.gradle:

i) classpath 'com.google.gms:google-services:4.0.1'

ii) Make sure google() appears above jcenter() in both buildscripts and allprojects

android/app/build.gradle:

Update Android libs to the latest specified here:

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

if you have other libraries (for me, it's firebase) make sure to check build.gradle of the libraries, too.

Ali Radmanesh
  • 2,248
  • 22
  • 26