07 CoCos Creator libcocos2dx verifyReleaseResources FAILED

本文解决Cocos2d-x项目中常见的编译错误,如libcocos2dx:verifyReleaseResources失败,以及未定义引用错误,提供调整Gradle属性和确保正确NDK版本的解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1. 现象

libcocos2dx:verifyReleaseResources FAILED

:libcocos2dx:verifyReleaseResources FAILED
:libcocos2dx:verifyReleaseResources (Thread[Daemon worker,5,main]) completed. Took 0.187 secs.
Android NDK: android-10 is unsupported. Using minimum supported version android-14.    
[armeabi-v7a] Compile++ arm  : cocos2djs_shared <= AppDelegate.cpp
[armeabi-v7a] Compile++ arm  : cocos2djs_shared <= jsb_module_register.cpp
[armeabi-v7a] SharedLibrary  : libcocos2djs.so

C
:/CocosCreator/resources/cocos2d-x/cocos/2d/CCParticleSystem.cpp:597: error: undefined reference to 'rand'
C:/CocosCreator/resources/cocos2d-x/cocos/2d/CCTMXXMLParser.cpp:696: error: undefined reference to 'atof'
C:/CocosCreator/resources/cocos2d-x/cocos/2d/CCTMXXMLParser.cpp:690: error: undefined reference to 'atof'
C:/CocosCreator/resources/cocos2d-x/cocos/2d/CCTMXXMLParser.cpp:653: error: undefined reference to 'atof'
C:/CocosCreator/resources/cocos2d-x/cocos/2d/CCTMXXMLParser.cpp:647: error: undefined reference to 'atof'
C:/CocosCreator/resources/cocos2d-x/cocos/base/CCConsole.cpp:1220: error: undefined reference to 'srand'
C:/CocosCreator/resources/cocos2d-x/cocos/base/CCConsole.cpp:1221: error: undefined reference to 'rand'
C:/CocosCreator/resources/cocos2d-x/cocos/base/CCConsole.cpp:1249: error: undefined reference to 'srand'
C:/CocosCreator/resources/cocos2d-x/cocos/base/CCConsole.cpp:1250: error: undefined reference to 'rand'
C:/CocosCreator/resources/cocos2d-x/cocos/base/ccRandom.h:117: error: undefined reference to 'rand'
C:/CocosCreator/resources/cocos2d-x/cocos/2d/CCActionTiledGrid.cpp:280: error: undefined reference to 'srand'
C:/CocosCreator/resources/cocos2d-x/cocos/2d/CCActionTiledGrid.cpp:606: error: undefined reference to 'srand

C:/CocosCreator/resources/cocos2d-x/cocos/2d/CCActionTiledGrid.cpp:606: error: undefined reference to 'srand
'
collect2.exe: error: ld returned 1 exit status
make: *** [D:/CoCosCreator/HelloWorld/build/jsb-link/frameworks/runtime-src/proj.android-studio/app/build/intermediates/ndkBuild/release/obj/local/armeabi-v7a/libcocos2djs.so] Error 1
:hello_world:externalNativeBuildRelease FAILED
:hello_world:externalNativeBuildRelease (Thread[Task worker for ':' Thread 2,5,main]) completed. Took 23.337 secs.

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':libcocos2dx:verifyReleaseResources'.
> java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details

* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.
==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':hello_world:externalNativeBuildRelease'.
> Build command failed.
  Error while executing process D:\android-ndk-r16b-windows-x86_64\android-ndk-r16b\ndk-build.cmd with arguments {NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=D:\CoCosCreator\HelloWorld\build\jsb-link\frameworks\runtime-src\proj.android-studio\app\jni\Android.mk NDK_APPLICATION_MK=D:\CoCosCreator\HelloWorld\build\jsb-link\frameworks\runtime-src\proj.android-studio\app\jni\Application.mk APP_ABI=armeabi-v7a NDK_ALL_ABIS=armeabi-v7a NDK_DEBUG=0 APP_PLATFORM=android-14 NDK_OUT=D:/CoCosCreator/HelloWorld/build/jsb-link/frameworks/runtime-src/proj.android-studio/app/build/intermediates/ndkBuild/release/obj NDK_LIBS_OUT=D:\CoCosCreator\HelloWorld\build\jsb-link\frameworks\runtime-src\proj.android-studio\app\build\intermediates\ndkBuild\release\lib NDK_TOOLCHAIN_VERSION=4.9 APP_PLATFORM=android-10 NDK_MODULE_PATH=C:\CocosCreator\resources\cocos2d-x;C:\CocosCreator\resources\cocos2d-x\cocos;C:\CocosCreator\resources\cocos2d-x\external -j4 NDK_DEBUG=0 D:/CoCosCreator/HelloWorld/build/jsb-link/frameworks/runtime-src/proj.android-studio/app/build/intermediates/ndkBuild/release/obj/local/armeabi-v7a/libcocos2djs.so}
  Android NDK: android-10 is unsupported. Using minimum supported version android-14.    
  [armeabi-v7a] Compile++ arm  : cocos2djs_shared <= AppDelegate.cpp
  [armeabi-v7a] Compile++ arm  : cocos2djs_shared <= jsb_module_register.cpp
  [armeabi-v7a] SharedLibrary  : libcocos2djs.so
  C:/CocosCreator/resources/cocos2d-x/cocos/2d/CCParticleSystem.cpp:597: error: undefined reference to 'rand'
  C:/CocosCreator/resources/cocos2d-x/cocos/2d/CCTMXXMLParser.cpp:696: error: undefined reference to 'atof'
  C:/CocosCreator/resources/cocos2d-x/cocos/2d/CCTMXXMLParser.cpp:690: error: undefined reference to 'atof'
  C:/CocosCreator/resources/cocos2d-x/cocos/2d/CCTMXXMLParser.cpp:653: error: undefined reference to 'atof'
  C:/CocosCreator/resources/cocos2d-x/cocos/2d/CCTMXXMLParser.cpp:647: error: undefined reference to 'atof'
  C:/CocosCreator/resources/cocos2d-x/cocos/base/CCConsole.cpp:1220: error: undefined reference to 'srand'
  C:/CocosCreator/resources/cocos2d-x/cocos/base/CCConsole.cpp:1221: error: undefined reference to 'rand'
  C:/CocosCreator/resources/cocos2d-x/cocos/base/CCConsole.cpp:1249: error: undefined reference to 'srand'
  C:/CocosCreator/resources/cocos2d-x/cocos/base/CCConsole.cpp:1250: error: undefined reference to 'rand'
  C:/CocosCreator/resources/cocos2d-x/cocos/base/ccRandom.h:117: error: undefined reference to 'rand'
  C:/CocosCreator/resources/cocos2d-x/cocos/2d/CCActionTiledGrid.cpp:280: error: undefined reference to 'srand'
  C:/CocosCreator/resources/cocos2d-x/cocos/2d/CCActionTiledGrid.cpp:606: error: undefined reference to 'srand'
  collect2.exe: error: ld returned 1 exit status
  make: *** [D:/CoCosCreator/HelloWorld/build/jsb-link/frameworks/runtime-src/proj.android-studio/app/build/intermediates/ndkBuild/release/obj/local/armeabi-v7a/libcocos2djs.so] Error 1


* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.
==============================================================================

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

BUILD FAILED in 42s
43 actionable tasks: 2 executed, 41 up-to-date
执行命令出错,返回值:1。

2. 解决方案

2.1 网上通用解决方案

But if you are facing issues with it, you can switch back to previous version by adding this in gradle.properties

android.enableAapt2=false

例如

  • D:\CoCosCreator\HelloWorld\build\jsb-link\frameworks\runtime-src\proj.android-studio\gradle.properties
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

PROP_TARGET_SDK_VERSION=22
PROP_APP_ABI=armeabi-v7a

RELEASE_STORE_FILE=C:/CocosCreator/resources/static/build-templates/native/debug.keystore
RELEASE_STORE_PASSWORD=123456
RELEASE_KEY_ALIAS=debug_keystore
RELEASE_KEY_PASSWORD=123456

android.enableAapt2=false
2.2 缺少符点库

上述少了浮点库,且需要确保ndk版本在16

ndk版本

2.3 选armv7,兼容模式

arm7.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

法迪

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值