Cocos2.4.9 compiles Android program and reports error

JDK version error

* What went wrong:
Execution failed for task ':FirstCocos:externalNativeBuildDebug'.
> Build command failed.
63 actionable tasks: 5 executed, 58 up-to-date
  Error while executing process /Users/admin/Library/Android/sdk/ndk/19.2.5345600/ndk-build with arguments {NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=/Users/admin/ITCode/FirstCocosProject/build/jsb-link/frameworks/runtime-src/proj.android-studio/app/jni/Android.mk NDK_APPLICATION_MK=/Users/admin/ITCode/FirstCocosProject/build/jsb-link/frameworks/runtime-src/proj.android-studio/app/jni/Application.mk APP_ABI=arm64-v8a NDK_ALL_ABIS=arm64-v8a NDK_DEBUG=1 APP_PLATFORM=android-16 NDK_OUT=/Users/admin/ITCode/FirstCocosProject/build/jsb-link/frameworks/runtime-src/proj.android-studio/app/build/intermediates/ndkBuild/debug/obj NDK_LIBS_OUT=/Users/admin/ITCode/FirstCocosProject/build/jsb-link/frameworks/runtime-src/proj.android-studio/app/build/intermediates/ndkBuild/debug/lib NDK_TOOLCHAIN_VERSION=clang NDK_MODULE_PATH=/Applications/CocosCreator/Creator/2.4.9/CocosCreator.app/Contents/Resources/cocos2d-x:/Applications/CocosCreator/Creator/2.4.9/CocosCreator.app/Contents/Resources/cocos2d-x/cocos:/Applications/CocosCreator/Creator/2.4.9/CocosCreator.app/Contents/Resources/cocos2d-x/external -j8 NDK_DEBUG=1 cocos2djs}
  ERROR: Unknown host CPU architecture: arm64

reason

There are two possible reasons for the above error:

  1. The JDK version of the current device is not JDK8 (1.8.x), Cocos2.4.9 only supports JDK8
  2. Currently using the openjdk Jre environment instead of Java SE
    insert image description here

solution

Go to the official website of Java Downloads to download the complete JDK8 version.

missing tools.jar

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':libcocos2dx:compileDebugJavaWithJavac'.
> Could not find tools.jar. Please check that /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home contains a valid JDK installation.

This problem occurs on MAC computers, and there will be a plug-in when JDK8 is installed on the device. The device will use the plug-in to JDK environment by default.
The plug-in to the JDK lacks tools.jar.

solution

Find your JDK8安装目录/Contents/Home/libcopy of tools.jar
in the default /Library/Java/JavaVirtualMachines
copy tools.jar paste to/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib

Supongo que te gusta

Origin blog.csdn.net/DeMonliuhui/article/details/128464968
Recomendado
Clasificación