Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.NullPointerException (no error message) APK building

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

The :app file

apply plugin: 'me.tatarka.retrolambda'
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'
}

When i try to build APK it shows me: Error:A problem occurred configuring project ':app'.

java.lang.NullPointerException (no error message)

Is it a problem with versions? or with lamdas?? someone can help me?

like image 240
Piero Tozzi Avatar asked Oct 18 '16 12:10

Piero Tozzi


3 Answers

I had the same issue after adding:

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

It was because my default java version was 10:

$ java -version
java version "10.0.1" 2018-04-17

After changing to 1.8 (with sudo update-alternatives --config java) issue was fixed.

like image 169
LLL Avatar answered Nov 16 '22 21:11

LLL


I have had the same kind of problem these days. I found it might be caused by the version of gradle. After changing the version to 2.1.0, the problem's gone.

dependencies {
        classpath 'com.android.tools.build:gradle:2.1.0'
    }

I'm not sure it works for you.

like image 30
Mark Shen Avatar answered Nov 16 '22 20:11

Mark Shen


Add this to your app module's build.gradle file:

lintOptions {
    checkReleaseBuilds false
}
like image 2
Vlad Dogadaev Avatar answered Nov 16 '22 19:11

Vlad Dogadaev