A problem occurred configuring project ':game'. > java.lang.NullPointerException (no error message)

Viewed 10244

I'm building apk from an android project exported from Cocos Creator V2.4.3 but getting the below error with Gradle

A problem occurred configuring project ':game'.
> java.lang.NullPointerException (no error message)

I've deleted all android SDK, NDK and re-installed Android Studio, then re-update SDK, NDK, Build Tool. But the error still occurs.

Some configurations:

Android SDK = 23, 26, 28, 30

SDK Build Tool = 30.0.3

NDK = 19.2.5345600

Gradle version: 4.10.3

Gradle plugin version: 3.2.0

JDK: jdk1.8.0_281


The build.gradle looks like this

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

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.0'


        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        flatDir {
                dirs 'libs'
        }
    }
}

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

Anyone has any idea about what should be done to fix this?

2 Answers

I had the same issue, I solved this by specifying 3.6.3 as Android Gradle plugin version and 5.6.4 as Gradle version.

You can do this by clicking File--> project structure--> project then type the versions I mentioned above then click on apply.

wait for the new versions to be downloaded and rebuild your project.

gradle settings in android studio

The problem was with setting the NDK Path in Cocos Creator.

I've changed C:\Users\SomeUserName\AppData\Local\Android\Sdk\ndk

into C:\Users\SomeUserName\AppData\Local\Android\Sdk\ndk\19.2.5345600

And things worked

Related