Android Studio上的Cocos2d-x-未列出新的CPP文件 [英] Cocos2d-x on Android Studio - New CPP files are not listed
问题描述
这是我第一次体验 Cocos2d-x 游戏引擎,遇到了很多问题.第一次尝试使用最新版本的Android Studio NDK ,但是当我尝试使用cocos compile -p android --android-studio
编译项目时,此 NDK 版本存在一个错误. NDK 版本升级到13b.
It's my first experience with Cocos2d-x Game Engine, I encountered a lot of problems. The first time I tried the latest NDK of Android Studio but there is a bug on this NDK version when I tried to compile my project with : cocos compile -p android --android-studio
so I change the NDK version to 13b.
当我更改为 NDK 13b 时,编译没有任何问题,android studio成功构建了我的项目,但是当我尝试创建新CPP文件或JAVA FILE或Android Studio中 Classes文件夹中的所有内容除了第一个 CPP文件以外,它什么都不显示,然后我再次将 NDK更改为14b ,我遇到了同样的问题.
When I changed to NDK 13b the compilation was done without any problems and android studio build my project successfully but when I tried to create new CPP FILE or JAVA FILE or anything inside the Classes folder, Android Studio It does not display anything except the first CPP FILES, then I changed again NDK to 14b and I encountered the same problem.
光盘上存在 CPP 文件,但Android Studio无法检测到我创建的文件.
The CPP files exist on my disc but Android Studio could not detect the files I created.
推荐答案
我找到了解决方案,解决方案是每次在Classes文件夹中添加文件时,使用通配符消除并修改 Android.mk
I found the solution, the solution is to using Wildcards eliminates and modify Android.mk each time you add a file inside Classes folder.
像这样:
...
LOCAL_MODULE_FILENAME := libMyGame
LOCAL_SRC_FILES_JNI_PREFIXED := \
$(wildcard $(LOCAL_PATH)/../../../Classes/*.cpp) \
$(wildcard $(LOCAL_PATH)/../../../Classes/**/*.cpp) \
$(wildcard $(LOCAL_PATH)/../../../Classes/**/**/*.cpp)
LOCAL_SRC_FILES := hellocpp/main.cpp \
$(LOCAL_SRC_FILES_JNI_PREFIXED)
...
如果添加新的cpp文件,则需要更新Android.mk
If you add a new cpp file, you need to update Android.mk
此外,请运行Android Studio菜单中的构建>刷新链接的C ++项目".
In addition, please run "Build > Refresh Linked C++ Projects" of Android Studio menu.
这篇关于Android Studio上的Cocos2d-x-未列出新的CPP文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!