3.17.2 not working on command line but works well on android studio

Platform: Mac OS.
Cocos2d-x version:3.17.2

Following the tutorial:

./setup.py

cocos new abc317 -p com.abc.abc317 -l cpp -d .

cd abc317

cocos compile -p android

Error message as below:
"Configuration failed.

External native generate JSON debug: JSON generation completed with problems

:abc317:generateJsonModelDebug (Thread[Task worker for ‘:’,5,main]) completed. Took 0.05 secs.

FAILURE: Build failed with an exception."

Change the following configuration in android-studio.
PROP_BUILD_TYPE=ndk-build

Run the game on Android studio, it works fine.

After that, try again on command line, it doesn’t work.

cocos compile -p android

Error message as below:
"Configuration failed.

External native generate JSON debug: JSON generation completed with problems

:abc317:generateJsonModelDebug (Thread[Task worker for ‘:’,5,main]) completed. Took 0.05 secs.

It looks the command line is still using the CMAKE. Would you mind to tell me how to correct the command line issue? Thank you very much.

running: ‘"/Users/xxx/Documents/abc317/proj.android/gradlew" --parallel --info assembleDebug -PPROP_BUILD_TYPE=cmake’

I see the above message when run cocos compile -p android. How could I change the PROP_BUILD_TYPE to ndk?

Change it in proj.android/gradle.properties

# android native code build type
# none, native code will never be compiled.
# cmake, native code will be compiled by CMakeLists.txt
# ndk-build, native code will be compiled by Android.mk
PROP_BUILD_TYPE=ndk-build

A text search in the files would have led you to the solution. :wink:

R101,
Thank you.
I had changed PROP_BUILD_TYPE=ndk-build in gradle.properties. It works well on Android studio, but it doesn’t work on the command line.

I’m not sure why it would be failing, and I don’t use the command line build, but I’m certain other people do use it so they may be able to help.

Hi all,

I found the solution. Please use the following command to build with NDK.

cocos run -p android --build-type ndk-build

Reference:

1 Like