简体   繁体   中英

cocos2d-x android build failed

I'm sorry I have to depend on Google Translator because I can not speak English well.

I built the cocos2d-x project using the cocos compile -p android --android-studio command.

My development environment:
OS = Windows10
cocos2d-x = 3.17.1
ndk = r11c
sdk = 27.0.3 (android studio version = latest ( 3.2.1 ) )

How to fix this build error?

> Task :gamer:generateJsonModelDebug FAILED
Task ':gamer:generateJsonModelDebug' is not up-to-date because:
  No history is available.
External native generate JSON debug: starting JSON generation
External native generate JSON debug: using platform version 16 for ABI 
ARMEABI_V7A and min SDK version 16
External native generate JSON debug: rebuilding JSON C:\Development\cocos2d- 
x-3.17.1\tools\cocos2d- 
console\bin\gamer\proj.android\app\.externalNativeBuild\cmake\debug\armeabi- 
v7a\android_gradle_build.json due to:
External native generate JSON debug: - expected json C:\Development\cocos2d- 
x-3.17.1\tools\cocos2d- 
console\bin\gamer\proj.android\app\.externalNativeBuild\cmake\debug\armeabi- 
v7a\android_gradle_build.json file is not present, will remove stale json 
folder
External native generate JSON debug: - missing previous command file 
C:\Development\cocos2d-x-3.17.1\tools\cocos2d- 
console\bin\gamer\proj.android\app\.externalNativeBuild\cmake\debug\armeabi- 
v7a\cmake_build_command.txt, will remove stale json folder
External native generate JSON debug: removing stale contents from 
'C:\Development\cocos2d-x-3.17.1\tools\cocos2d- 
console\bin\gamer\proj.android\app\.externalNativeBuild\cmake\debug\armeabi- 
v7a'
External native generate JSON debug: created folder 'C:\Development\cocos2d- 
x-3.17.1\tools\cocos2d- 
console\bin\gamer\proj.android\app\.externalNativeBuild\cmake\debug\armeabi- 
v7a'
External native generate JSON debug: executing cmake Executable : 
C:\Development\sdk\cmake\3.10.2.4988404\bin\cmake.exe
arguments :
-HC:\Development\cocos2d-x-3.17.1\tools\cocos2d-console\bin\gamer
-BC:\Development\cocos2d-x-3.17.1\tools\cocos2d- 

console\bin\gamer\proj.android\app\.externalNativeBuild\cmake\debug\armeabi- 
v7a
-DANDROID_ABI=armeabi-v7a
-DANDROID_PLATFORM=android-16
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Development\cocos2d-x- 
 3.17.1\tools\cocos2d- 



 > Task :gamer:generateJsonModelDebug FAILED
Task ':gamer:generateJsonModelDebug' is not up-to-date because:
  No history is available.
External native generate JSON debug: starting JSON generation
External native generate JSON debug: using platform version 16 for ABI 
ARMEABI_V7A and min SDK version 16
External native generate JSON debug: rebuilding JSON C:\Development\cocos2d- 
x-3.17.1\tools\cocos2d- 
console\bin\gamer\proj.android\app\.externalNativeBuild\cmake\debug\armeabi- 
v7a\android_gradle_build.json due to:
External native generate JSON debug: - expected json C:\Development\cocos2d- 
x-3.17.1\tools\cocos2d- 
console\bin\gamer\proj.android\app\.externalNativeBuild\cmake\debug\armeabi- 
v7a\android_gradle_build.json file is not present, will remove stale json 
folder
External native generate JSON debug: - missing previous command file 
C:\Development\cocos2d-x-3.17.1\tools\cocos2d- 

console\\bin\\gamer\\proj.android\\app.externalNativeBuild\\cmake\\debug\\armeabi- v7a\\cmake_build_command.txt, will remove stale json folder External native generate JSON debug: removing stale contents from 'C:\\Development\\cocos2d-x-3.17.1\\tools\\cocos2d- console\\bin\\gamer\\proj.android\\app.externalNativeBuild\\cmake\\debug\\armeabi- v7a' External native generate JSON debug: created folder 'C:\\Development\\cocos2d- x-3.17.1\\tools\\cocos2d- console\\bin\\gamer\\proj.android\\app.externalNativeBuild\\cmake\\debug\\armeabi- v7a' External native generate JSON debug: executing cmake Executable : C:\\Development\\sdk\\cmake\\3.10.2.4988404\\bin\\cmake.exe arguments : -HC:\\Development\\cocos2d-x-3.17.1\\tools\\cocos2d-console\\bin\\gamer -BC:\\Development\\cocos2d-x-3.17.1\\tools\\cocos2d- console\\bin\\gamer\\proj.android\\app.externalNativeBuild\\cmake\\debug\\armeabi- v7a -DANDROID_ABI=armeabi-v7a -DANDROID_PLATFORM=android-16 -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\\Development\\cocos2d-x- 3.17.1\\tools\\cocos2d-

console\\bin\\gamer\\proj.android\\app\\build\\intermediates\\cmake\\debug\\obj\\armeabi- v7a -DCMAKE_BUILD_TYPE=Debug -DANDROID_NDK=C:\\Development\\android-ndk-r11c -DCMAKE_CXX_FLAGS=-frtti -fexceptions -fsigned-char -DCMAKE_SYSTEM_NAME=Android -DCMAKE_ANDROID_ARCH_ABI=armeabi-v7a -DCMAKE_SYSTEM_VERSION=16 -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_ANDROID_NDK=C:\\Development\\android-ndk-r11c -DCMAKE_TOOLCHAIN_FILE=C:\\Development\\cocos2d-x-3.17.1\\tools\\cocos2d- console\\bin\\gamer\\proj.android\\app.externalNativeBuild\\cmake\\debug\\armeabi- v7a\\pre-ndk-r15-wrapper-android.toolchain.cmake -G Ninja -DCMAKE_FIND_ROOT_PATH= -DANDROID_STL=c++_static -DANDROID_TOOLCHAIN=clang -DANDROID_ARM_NEON=TRUE jvmArgs :

[== "CMake Server" ==[

{"supportedProtocolVersions":[{"isExperimental":true,"major":1,"minor":1}],"type":"hello"}

]== "CMake Server" ==]

[== "CMake Server" ==[

{ "type": "handshake", "cookie": "gradle-cmake-cookie", "protocolVersion": { "isExperimental": true, "major": 1, "minor": 1 }, "sourceDirectory": "C:/Development/cocos2d-x-3.17.1/tools/cocos2d-console/bin/gamer", "buildDirectory": "C:/Development/cocos2d-x-3.17.1/tools/cocos2d-console/bin/gamer/proj.android/app/.externalNativeBuild/cmake/debug/armeabi-v7a", "generator": "Ninja" }

]== "CMake Server" ==]

[== "CMake Server" ==[

{"cookie":"gradle-cmake-cookie","inReplyTo":"handshake","type":"reply"}

]== "CMake Server" ==]

[== "CMake Server" ==[

{ "type": "configure", "cacheArguments": [ "", "-DANDROID_ABI\=armeabi-v7a", "-DANDROID_PLATFORM\=android-16", "-DCMAKE_LIBRARY_OUTPUT_DIRECTORY\=C:\\Development\\cocos2d-x-3.17.1\\tools\\cocos2d-console\\bin\\gamer\\proj.android\\app\\build\\intermediates\\cmake\\debug\\obj\\armeabi-v7a", "-DCMAKE_BUILD_TYPE\=Debug", "-DANDROID_NDK\=C:\\Development\\android-ndk-r11c", "-DCMAKE_CXX_FLAGS\=-frtti -fexceptions -fsigned-char", "-DCMAKE_SYSTEM_NAME\=Android", "-DCMAKE_ANDROID_ARCH_ABI\=armeabi-v7a", "-DCMAKE_SYSTEM_VERSION\=16", "-DCMAKE_EXPORT_COMPILE_COMMANDS\=ON", "-DCMAKE_ANDROID_NDK\=C:\\Development\\android-ndk-r11c", "-DCMAKE_TOOLCHAIN_FILE\=C:\\Development\\cocos2d-x-3.17.1\\tools\\cocos2d-console\\bin\\gamer\\proj.android\\app\\.externalNativeBuild\\cmake\\debug\\armeabi-v7a\\pre-ndk-r15-wrapper-android.toolchain.cmake", "-G Ninja", "-DCMAKE_FIND_ROOT_PATH\=", "-DANDROID_STL\=c++_static", "-DANDROID_TOOLCHAIN\=clang", "-DANDROID_ARM_NEON\=TRUE" ] }

]== "CMake Server" ==]

[== "CMake Server" ==[

{"cookie":"","inReplyTo":"configure","message":"CMake Error at C:/Development/sdk/cmake/3.10.2.4988404/android.toolchain.cmake:356 (message):\\n Invalid Android NDK revision (should be 12): 11.2.2725575.\\nCall Stack (most recent call first):\\n proj.android/app/.externalNativeBuild/cmake/debug/armeabi-v7a/pre-ndk-r15-wrapper-android.toolchain.cmake:2 (include)\\n C:/Development/sdk/cmake/3.10.2.4988404/share/cmake-3.10/Modules/CMakeDetermineSystem.cmake:94 (include)\\n CMakeLists.txt:30 (project)\\n\\n","title":"Error","type":"message"}

]== "CMake Server" ==]

CMake Error at C:/Development/sdk/cmake/3.10.2.4988404/android.toolchain.cmake:356 (message): Invalid Android NDK revision (should be 12): 11.2.2725575. Call Stack (most recent call first): proj.android/app/.externalNativeBuild/cmake/debug/armeabi-v7a/pre-ndk-r15-wrapper-android.toolchain.cmake:2 (include) C:/Development/sdk/cmake/3.10.2.4988404/share/cmake-3.10/Modules/CMakeDetermineSystem.cmake:94 (include) CMakeLists.txt:30 (project)

CMake Error at C:/Development/sdk/cmake/3.10.2.4988404/android.toolchain.cmake:356 (message): Invalid Android NDK revision (should be 12): 11.2.2725575. Call Stack (most recent call first): proj.android/app/.externalNativeBuild/cmake/debug/armeabi-v7a/pre-ndk-r15-wrapper-android.toolchain.cmake:2 (include) C:/Development/sdk/cmake/3.10.2.4988404/share/cmake-3.10/Modules/CMakeDetermineSystem.cmake:94 (include) CMakeLists.txt:30 (project)

[== "CMake Server" ==[

{"cookie":"","inReplyTo":"configure","message":"CMake Error: CMake was unable to find a build program corresponding to \\"Ninja\\". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.","title":"Error","type":"message"}

]== "CMake Server" ==]

CMake Error: CMake was unable to find a build program corresponding to "Ninja". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool. CMake Error: CMake was unable to find a build program corresponding to "Ninja". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.

[== "CMake Server" ==[

{"cookie":"","inReplyTo":"configure","message":"CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage","title":"Error","type":"message"}

]== "CMake Server" ==]

CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage

[== "CMake Server" ==[

{"cookie":"","inReplyTo":"configure","message":"CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage","title":"Error","type":"message"}

]== "CMake Server" ==]

CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage

[== "CMake Server" ==[

{"cookie":"","inReplyTo":"configure","progressCurrent":1000,"progressMaximum":1000,"progressMessage":"Configuring","progressMinimum":0,"type":"progress"}

]== "CMake Server" ==]

[== "CMake Server" ==[

{"cookie":"","inReplyTo":"configure","message":"Configuring incomplete, errors occurred!","type":"message"}

]== "CMake Server" ==]

Configuring incomplete, errors occurred! Configuring incomplete, errors occurred!

[== "CMake Server" ==[

{"cookie":"","errorMessage":"Configuration failed.","inReplyTo":"configure","type":"error"}

]== "CMake Server" ==]

Configuration failed. External native generate JSON debug: JSON generation completed with problems

:gamer:generateJsonModelDebug (Thread[Task worker for ':' Thread 7,5,main]) completed. Took 0.2 secs.

Task :libcocos2dx:platformAttrExtractor Task ':libcocos2dx:platformAttrExtractor' is not up-to-date because: No history is available.

:libcocos2dx:platformAttrExtractor (Thread[Task worker for ':' Thread 5,5,main]) completed. Took 0.232 secs.

FAILURE: Build failed with an exception.
  • What went wrong: Execution failed for task ':gamer:generateJsonModelDebug'.

    com.android.ide.common.process.ProcessException: Error configuring

  • Try: Run with --stacktrace option to get the stack trace. Run with --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 21s 21 actionable tasks: 21 executed Error running command, return code: 1.

What's wrong with me?

CMake Error: CMake was unable to find a build program corresponding to "Ninja".

cocos2d-x 3.17.1 using CMake, cross-platform build system(by default).

Google mostly upgrade missing dependencies by automatic downloading in SDK.
eg CMake was upgraded from 3.6 to 3.10 (ninja required in latest cMake).

so you've to install Ninja in your system .

I hope this solve your issue.

macOS 10.15 + cpp3171 + ndk-r16b

brew install ninja
cocos compile -p android

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM