I run Cocos run-p Android compile cheer apk when prompted: jni/. /.. /classes/appdelegate.cpp:67:error:undefined reference to ' Gamemain::c
Reatescene () ', the last error message: NDK build failed!, where Gamemain is the code I wrote myself.
Later, there are two ways to solve the problem:
The first method: in the Android.mk file below the \proj.android\jni, add the CPP file name of all the code you wrote under Local_src_files.
The second method: The disadvantage of the first method is that if the project has a lot of files, manual add is cumbersome, you can refer to the method below, in code to traverse the classes directory
CPP file, it is important to note that all CPP in the Classes folder is useful in the project, and the main code is as follows:
# traversing directories and subdirectories of functions define walk $ (wildcard $ (1)) $ (foreach E, $ (wildcard $ (1)/*), $ (call Walk, $ (e))) Endef # Traverse Classes Directory Allfi LES = $ (call walk, $ (local_path)/. /.. /classes) File_list: = hellocpp/main.cpp# extracts all. cpp files from all files File_list + = $ (filter%.cpp, $ (allfiles)) Local_src_files: = $ (file_list:$ (Local_path)/%=%)
Reference articles are as follows:
http://tianyiyan.com/cocos2d-x-3-x-%E7%BC%96%E8%AF%91android%E6%96%B9%E6%B3%95/
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Cocos2d-x 3.6 running Cocos run with NDK build failed solution