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

2

7

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?

Polydipsia answered 27/2, 2021 at 19:24 Comment(0)
P
3

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

Polydipsia answered 27/2, 2021 at 20:26 Comment(0)
C
12

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

Candless answered 19/5, 2021 at 20:58 Comment(0)
P
3

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

Polydipsia answered 27/2, 2021 at 20:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.