android-studiogradlenullpointerexceptionapkcocos2d-js

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


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?


Solution

  • 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