Creating a native build using cocos creator version 2.4.8

Hello,
I have followed this Setup Native Development
I can build the code but could not compile them. It gives error :

Error: Compile failed. The log file path [ C:\Users\Admin\.CocosCreator\logs\native.log ]
    at ChildProcess.<anonymous> (C:\CocosDashboard_1.0.20\resources\.editors\Creator\2.4.8\resources\app.asar\editor\core\native-utils.ccc:1:24494)
    at ChildProcess.<anonymous> (C:\CocosDashboard_1.0.20\resources\.editors\Creator\2.4.8\resources\app.asar\editor\core\native-utils.ccc:1:6414)
    at ChildProcess.emit (events.js:315:20)
    at ChildProcess.emit (domain.js:467:12)
    at maybeClose (internal/child_process.js:1048:16)
    at Process.onexit (internal/child_process.js:288:5)
    at Process.callbackTrampoline (internal/async_hooks.js:131:14)

This is the log.

Starting process 'command 'C:\Users\Admin\AppData\Local\Android\Sdk\ndk\23.1.7779620\ndk-build.cmd''. Working directory: D:\CCP\CCAnd\jsb-link\frameworks\runtime-src\proj.android-studio\instantapp Command: C:\Users\Admin\AppData\Local\Android\Sdk\ndk\23.1.7779620\ndk-build.cmd NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=D:\CCP\CCAnd\jsb-link\frameworks\runtime-src\proj.android-studio\instantapp\jni\Android.mk NDK_APPLICATION_MK=D:\CCP\CCAnd\jsb-link\frameworks\runtime-src\proj.android-studio\instantapp\jni\Application.mk APP_ABI=x86 NDK_ALL_ABIS=x86 NDK_DEBUG=1 APP_PLATFORM=android-16 NDK_OUT=D:/CCP/CCAnd/jsb-link/frameworks/runtime-src/proj.android-studio/instantapp/build/intermediates/ndkBuild/debug/obj NDK_LIBS_OUT=D:\CCP\CCAnd\jsb-link\frameworks\runtime-src\proj.android-studio\instantapp\build\intermediates\ndkBuild\debug\lib NDK_TOOLCHAIN_VERSION=clang NDK_MODULE_PATH=C:\CocosDashboard_1.0.20\resources\.editors\Creator\2.4.8\resources\cocos2d-x;C:\CocosDashboard_1.0.20\resources\.editors\Creator\2.4.8\resources\cocos2d-x\cocos;C:\CocosDashboard_1.0.20\resources\.editors\Creator\2.4.8\resources\cocos2d-x\external -j8 NDK_DEBUG=1 cocos2djs
Successfully started process 'command 'C:\Users\Admin\AppData\Local\Android\Sdk\ndk\23.1.7779620\ndk-build.cmd''
C:/CocosDashboard_1.0.20/resources/.editors/Creator/2.4.8/resources/cocos2d-x/external/sources/pvmp3dec/src/pvmp3_alias_reduction.cpp:172:70: error: implicit conversion from 'int' to 'float' changes value from 2147483647 to 2147483648 [-Werror,-Wimplicit-const-int-float-conversion]
    *used_freq_lines = fxp_mul32_Q32(*used_freq_lines << 16, (int32)(0x7FFFFFFF / (float)18 - 1.0f)) >> 15;
                                                                     ^~~~~~~~~~ ~
1 error generated.
make: *** [C:/Users/Admin/AppData/Local/Android/Sdk/ndk/23.1.7779620/build//../build/core/build-binary.mk:478: D:/CCP/CCAnd/jsb-link/frameworks/runtime-src/proj.android-studio/instantapp/build/intermediates/ndkBuild/debug/obj/local/x86/objs-debug/pvmp3dec/src/pvmp3_alias_reduction.o] Error 1
make: *** Waiting for unfinished jobs....

> Task :instantapp:externalNativeBuildDebug FAILED
:instantapp:externalNativeBuildDebug (Thread[Execution worker for ':' Thread 2,5,main]) completed. Took 18.259 secs.
:instantapp:processDebugManifestForPackage (Thread[Execution worker for ':' Thread 6,5,main]) completed. Took 23.612 secs.

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':CocosCreatorAndroidBuild:externalNativeBuildDebug'.
> Build command failed.
  Error while executing process C:\Users\Admin\AppData\Local\Android\Sdk\ndk\23.1.7779620\ndk-build.cmd with arguments {NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=D:\CCP\CCAnd\jsb-link\frameworks\runtime-src\proj.android-studio\app\jni\Android.mk NDK_APPLICATION_MK=D:\CCP\CCAnd\jsb-link\frameworks\runtime-src\proj.android-studio\app\jni\Application.mk APP_ABI=x86 NDK_ALL_ABIS=x86 NDK_DEBUG=1 APP_PLATFORM=android-16 NDK_OUT=D:/CCP/CCAnd/jsb-link/frameworks/runtime-src/proj.android-studio/app/build/intermediates/ndkBuild/debug/obj NDK_LIBS_OUT=D:\CCP\CCAnd\jsb-link\frameworks\runtime-src\proj.android-studio\app\build\intermediates\ndkBuild\debug\lib NDK_TOOLCHAIN_VERSION=clang NDK_MODULE_PATH=C:\CocosDashboard_1.0.20\resources\.editors\Creator\2.4.8\resources\cocos2d-x;C:\CocosDashboard_1.0.20\resources\.editors\Creator\2.4.8\resources\cocos2d-x\cocos;C:\CocosDashboard_1.0.20\resources\.editors\Creator\2.4.8\resources\cocos2d-x\external -j8 NDK_DEBUG=1 cocos2djs}
  Android NDK: WARNING: Unsupported source file extensions in C:\CocosDashboard_1.0.20\resources\.editors\Creator\2.4.8\resources\cocos2d-x/cocos/Android.mk for module cocos2dx_static    
  Android NDK:   ../external/sources/edtaa3func/edtaa3func.h renderer/memop/RecyclePool.hpp    
  [x86] Compile++      : pvmp3dec <= pvmp3_alias_reduction.cpp
  [x86] Compile++      : pvmp3dec <= pvmp3_get_main_data_size.cpp
  [x86] Compile++      : pvmp3dec <= pvmp3_get_side_info.cpp
  
  C:/CocosDashboard_1.0.20/resources/.editors/Creator/2.4.8/resources/cocos2d-x/external/sources/pvmp3dec/src/pvmp3_alias_reduction.cpp:172:70: error: implicit conversion from 'int' to 'float' changes value from 2147483647 to 2147483648 [-Werror,-Wimplicit-const-int-float-conversion]
      *used_freq_lines = fxp_mul32_Q32(*used_freq_lines << 16, (int32)(0x7FFFFFFF / (float)18 - 1.0f)) >> 15;
                                                                       ^~~~~~~~~~ ~
  1 error generated.
  make: *** [C:/Users/Admin/AppData/Local/Android/Sdk/ndk/23.1.7779620/build//../build/core/build-binary.mk:478: D:/CCP/CCAnd/jsb-link/frameworks/runtime-src/proj.android-studio/app/build/intermediates/ndkBuild/debug/obj/local/x86/objs-debug/pvmp3dec/src/pvmp3_alias_reduction.o] Error 1
  make: *** Waiting for unfinished jobs....


* 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.
==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':instantapp:externalNativeBuildDebug'.
> Build command failed.
  Error while executing process C:\Users\Admin\AppData\Local\Android\Sdk\ndk\23.1.7779620\ndk-build.cmd with arguments {NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=D:\CCP\CCAnd\jsb-link\frameworks\runtime-src\proj.android-studio\instantapp\jni\Android.mk NDK_APPLICATION_MK=D:\CCP\CCAnd\jsb-link\frameworks\runtime-src\proj.android-studio\instantapp\jni\Application.mk APP_ABI=x86 NDK_ALL_ABIS=x86 NDK_DEBUG=1 APP_PLATFORM=android-16 NDK_OUT=D:/CCP/CCAnd/jsb-link/frameworks/runtime-src/proj.android-studio/instantapp/build/intermediates/ndkBuild/debug/obj NDK_LIBS_OUT=D:\CCP\CCAnd\jsb-link\frameworks\runtime-src\proj.android-studio\instantapp\build\intermediates\ndkBuild\debug\lib NDK_TOOLCHAIN_VERSION=clang NDK_MODULE_PATH=C:\CocosDashboard_1.0.20\resources\.editors\Creator\2.4.8\resources\cocos2d-x;C:\CocosDashboard_1.0.20\resources\.editors\Creator\2.4.8\resources\cocos2d-x\cocos;C:\CocosDashboard_1.0.20\resources\.editors\Creator\2.4.8\resources\cocos2d-x\external -j8 NDK_DEBUG=1 cocos2djs}
  Android NDK: WARNING: Unsupported source file extensions in C:\CocosDashboard_1.0.20\resources\.editors\Creator\2.4.8\resources\cocos2d-x/cocos/Android.mk for module cocos2dx_static    
  Android NDK:   ../external/sources/edtaa3func/edtaa3func.h renderer/memop/RecyclePool.hpp    
  [x86] Compile++      : pvmp3dec <= pvmp3_alias_reduction.cpp
  [x86] Compile++      : pvmp3dec <= pvmp3_get_main_data_size.cpp
  [x86] Compile++      : pvmp3dec <= pvmp3_get_side_info.cpp
  
  C:/CocosDashboard_1.0.20/resources/.editors/Creator/2.4.8/resources/cocos2d-x/external/sources/pvmp3dec/src/pvmp3_alias_reduction.cpp:172:70: error: implicit conversion from 'int' to 'float' changes value from 2147483647 to 2147483648 [-Werror,-Wimplicit-const-int-float-conversion]
      *used_freq_lines = fxp_mul32_Q32(*used_freq_lines << 16, (int32)(0x7FFFFFFF / (float)18 - 1.0f)) >> 15;
                                                                       ^~~~~~~~~~ ~
  1 error generated.
  make: *** [C:/Users/Admin/AppData/Local/Android/Sdk/ndk/23.1.7779620/build//../build/core/build-binary.mk:478: D:/CCP/CCAnd/jsb-link/frameworks/runtime-src/proj.android-studio/instantapp/build/intermediates/ndkBuild/debug/obj/local/x86/objs-debug/pvmp3dec/src/pvmp3_alias_reduction.o] Error 1
  make: *** Waiting for unfinished jobs....


* 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 27s49 actionable tasks: 24 executed, 25 up-to-date

Error running command, return code: 1.

native.zip (31.0 KB)

Android gradle plugin version : 4.2.2
Gradle version : 6.7.1
python version : 2.7.18
Android Studio Bumblebee | 2021.1.1 Patch 3 for Windows 64-bit.
Android API : 32
Android SDK Build tools : 33.0.0-rc2
NDK : 24.0.8215888

ndk recommended version is r17 - r19, you can change it and try again.
https://docs.cocos.com/creator/2.4/manual/en/publish/setup-native-development.html


You mean 17, 18 or 19 in this. I couldn’t find r17 in this.


This is r17, you can use one of these three.

I did use r19 but this is the error in the log.

> Task :CocosCreatorAndroidBuild:stripDebugDebugSymbols
Caching disabled for task ':CocosCreatorAndroidBuild:stripDebugDebugSymbols' because:
  Build cache is disabled
Task ':CocosCreatorAndroidBuild:stripDebugDebugSymbols' is not up-to-date because:
  No history is available.
The input changes require a full rebuild for incremental task ':CocosCreatorAndroidBuild:stripDebugDebugSymbols'.
Unable do incremental execution: full task run
android.ndkVersion from module build.gradle is [not set]
android.ndkPath from module build.gradle is not set
ndk.dir in local.properties is C:\Users\Admin\AppData\Local\Android\Sdk\ndk\19.2.5345600
Not considering ANDROID_NDK_HOME because support was removed after deprecation period.
sdkFolder is C:\Users\Admin\AppData\Local\Android\Sdk
Because no explicit NDK was requested, the default version [21.4.7075529] for this Android Gradle Plugin will be used
Checking whether deleting ndk.dir and setting android.ndkVersion to [19.2.5345600] would result in the same NDK
C/C++ ndk.dir delete check : android.ndkVersion from module build.gradle is [19.2.5345600]
C/C++ ndk.dir delete check : android.ndkPath from module build.gradle is not set
C/C++ ndk.dir delete check : ndk.dir in local.properties is not set
C/C++ ndk.dir delete check : Not considering ANDROID_NDK_HOME because support was removed after deprecation period.
C/C++ ndk.dir delete check : sdkFolder is C:\Users\Admin\AppData\Local\Android\Sdk
C/C++ ndk.dir delete check : Deleting ndk.dir and setting android.ndkVersion to [19.2.5345600] would result in the same NDK.
WARNING:: NDK was located by using ndk.dir property. This method is deprecated and will be removed in a future release. Please delete ndk.dir from local.properties and set android.ndkVersion to [19.2.5345600] in all native modules in the project. https://developer.android.com/r/studio-ui/ndk-dir
NDK was located by using ndk.dir property. This method is deprecated and will be removed in a future release. Please delete ndk.dir from local.properties and set android.ndkVersion to [19.2.5345600] in all native modules in the project. https://developer.android.com/r/studio-ui/ndk-dir
Starting process 'command 'C:\Users\Admin\AppData\Local\Android\Sdk\ndk\19.2.5345600\toolchains\llvm\prebuilt\windows-x86_64\bin\i686-linux-android-strip''. Working directory: D:\CCP\CCAnd\jsb-link\frameworks\runtime-src\proj.android-studio\app Command: C:\Users\Admin\AppData\Local\Android\Sdk\ndk\19.2.5345600\toolchains\llvm\prebuilt\windows-x86_64\bin\i686-linux-android-strip --strip-unneeded -o D:\CCP\CCAnd\jsb-link\frameworks\runtime-src\proj.android-studio\app\build\intermediates\stripped_native_libs\debug\out\lib\x86\libcocos2djs.so D:\CCP\CCAnd\jsb-link\frameworks\runtime-src\proj.android-studio\app\build\intermediates\merged_native_libs\debug\out\lib\x86\libcocos2djs.so
Starting process 'command 'C:\Users\Admin\AppData\Local\Android\Sdk\ndk\19.2.5345600\toolchains\llvm\prebuilt\windows-x86_64\bin\aarch64-linux-android-strip''. Working directory: D:\CCP\CCAnd\jsb-link\frameworks\runtime-src\proj.android-studio\app Command: C:\Users\Admin\AppData\Local\Android\Sdk\ndk\19.2.5345600\toolchains\llvm\prebuilt\windows-x86_64\bin\aarch64-linux-android-strip --strip-unneeded -o D:\CCP\CCAnd\jsb-link\frameworks\runtime-src\proj.android-studio\app\build\intermediates\stripped_native_libs\debug\out\lib\arm64-v8a\libcocos2djs.so D:\CCP\CCAnd\jsb-link\frameworks\runtime-src\proj.android-studio\app\build\intermediates\merged_native_libs\debug\out\lib\arm64-v8a\libcocos2djs.so
Starting process 'command 'C:\Users\Admin\AppData\Local\Android\Sdk\ndk\19.2.5345600\toolchains\llvm\prebuilt\windows-x86_64\bin\x86_64-linux-android-strip''. Working directory: D:\CCP\CCAnd\jsb-link\frameworks\runtime-src\proj.android-studio\app Command: C:\Users\Admin\AppData\Local\Android\Sdk\ndk\19.2.5345600\toolchains\llvm\prebuilt\windows-x86_64\bin\x86_64-linux-android-strip --strip-unneeded -o D:\CCP\CCAnd\jsb-link\frameworks\runtime-src\proj.android-studio\app\build\intermediates\stripped_native_libs\debug\out\lib\x86_64\libcocos2djs.so D:\CCP\CCAnd\jsb-link\frameworks\runtime-src\proj.android-studio\app\build\intermediates\merged_native_libs\debug\out\lib\x86_64\libcocos2djs.so
Successfully started process 'command 'C:\Users\Admin\AppData\Local\Android\Sdk\ndk\19.2.5345600\toolchains\llvm\prebuilt\windows-x86_64\bin\x86_64-linux-android-strip''
Successfully started process 'command 'C:\Users\Admin\AppData\Local\Android\Sdk\ndk\19.2.5345600\toolchains\llvm\prebuilt\windows-x86_64\bin\aarch64-linux-android-strip''
Successfully started process 'command 'C:\Users\Admin\AppData\Local\Android\Sdk\ndk\19.2.5345600\toolchains\llvm\prebuilt\windows-x86_64\bin\i686-linux-android-strip''
:CocosCreatorAndroidBuild:stripDebugDebugSymbols (Thread[Daemon worker Thread 6,5,main]) completed. Took 2.213 secs.
:CocosCreatorAndroidBuild:packageDebug (Thread[Daemon worker Thread 6,5,main]) started.

> Task :instantapp:packageDebug
Caching disabled for task ':instantapp:packageDebug' because:
  Build cache is disabled
Task ':instantapp:packageDebug' is not up-to-date because:
  No history is available.
The input changes require a full rebuild for incremental task ':instantapp:packageDebug'.

> Task :CocosCreatorAndroidBuild:packageDebug FAILED
Caching disabled for task ':CocosCreatorAndroidBuild:packageDebug' because:
  Build cache is disabled
Task ':CocosCreatorAndroidBuild:packageDebug' is not up-to-date because:
  No history is available.
The input changes require a full rebuild for incremental task ':CocosCreatorAndroidBuild:packageDebug'.
:CocosCreatorAndroidBuild:packageDebug (Thread[Daemon worker Thread 6,5,main]) completed. Took 6.662 secs.
:instantapp:packageDebug (Thread[Execution worker for ':',5,main]) completed. Took 9.226 secs.
85 actionable tasks: 34 executed, 51 up-to-date

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':CocosCreatorAndroidBuild:packageDebug'.
> A failure occurred while executing com.android.build.gradle.tasks.PackageAndroidArtifact$IncrementalSplitterRunnable
   > java.lang.OutOfMemoryError (no error message)

* 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 37m 43s
Error running command, return code: 1.

I tried to run even when the compile gave error. It showed error. There was a log saying no emulator ad apk is stored in some other file. I moved it to my mobile device and the apk is running.
Is there a problem that might occur?


How are you set up here, here you must find the path corresponding to ndk r19.

1 Like

Yes, I have

You are still using 21.

So, you better clean up your native folder and rebuild again.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.