Build/Make for Android doesn't work in Cocos Creator 3.5.1-3.5.2

Just try to build a Empty project with settings below, finished by error.
How to fix it?




Task :TestBuildAOS352:mergeReleaseJniLibFolders

2-9-2023 15:05-log: [runCmd /Users/alex/projects/tests/TestBuildAOS352/build/android/proj/gradlew] > Task :TestBuildAOS352:validateSigningRelease

2-9-2023 15:05-log: [runCmd /Users/alex/projects/tests/TestBuildAOS352/build/android/proj/gradlew] > Task :TestBuildAOS352:mergeReleaseNativeLibs

Task :libcocos:compileReleaseJavaWithJavac FAILED

2-9-2023 15:05-log: [runCmd /Users/alex/projects/tests/TestBuildAOS352/build/android/proj/gradlew - error]
FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:libcocos:compileReleaseJavaWithJavac’.

java.lang.NullPointerException (no error message)

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 4m 33s

Log file - android2-9-2023 14-56.log - Google Drive

Hi, once you have built your Android project, you can open it once with android studio.

Bro, yes we can do it, but we are developers and lazy , prefer to do automation.

Face problem with CC 2.4.6


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':libcocos2dx:compileReleaseJavaWithJavac'.
> Cannot find System Java Compiler. Ensure that you have installed a JDK (not just a JRE) and configured your JAVA_HOME system variable to point to the according directory.

i 've checked JAVA_HOME, and it’s correct installed. dont understand a issue, could you help to fix it ?

1 Like

Can you provide more details of your setup?

  • A screenshot of setting JAVA_HOME, JDK installation path, etc. under the project for reference, please.

Yes, sure.

Hi, any suggestions? @muxiandong

Sorry for the late reply, I see that your settings are correct. 2.4.x packaging issues are most likely related to python version, you can confirm the python version, you need python 2.7.x version.
(Note: previously encountered user feedback, macOS computer upgrade version will delete the local 2.x python)

Yeah, sure, i guess when is not 2.7.x, CC itself says error during Build phase.

Is the project ready to build properly?

can Build , but not Compile or Make in editor.

Screenshot 2023-03-01 at 12.25.38

alright we have fixed the issue @muxiandong , the solution is some how gradle defined wrong location of JDK (i can’t see more details cause Cocos Editor uses some command line args i guess for building), so we added in global properties(<home directory of the current user>/.gradle/gradle.properties) overriding for java home

org.gradle.java.home=/Library/Java/JavaVirtualMachines/jdk1.8.0_361.jdk/Contents/Home

And now it works fine.

Thank you for the solution.