Android Studio 2.3.3 (LATEST)
Cocos2d-x 3.15.1 (LATEST)
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.
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.
The CPP files exist on my disc but Android Studio could not detect the files I created.
To avoid all these problems I think of migrating to eclipse, is a good choice ? I guess eclipse is better for performance and stability, please answer to this question, because I lost 3 days to test...ect
In fact I created several files inside Classes folder but look to the image :
Thank you,
I found the solution, the solution is to using Wildcards eliminates and modify Android.mk each time you add a file inside Classes folder.
like this :
...
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)
...
If you add a new cpp file, you need to update Android.mk
In addition, please run “Build > Refresh Linked C++ Projects” of Android Studio menu.
If found another solution to add all files, without modifying Android.mk each time you add a file inside Classes folder.
LOCAL_SRC_FILES := hellocpp/main.cpp
FILE_LIST := $(wildcard $(LOCAL_PATH)/../../../Classes/*.cpp)
LOCAL_SRC_FILES += $(FILE_LIST:$(LOCAL_PATH)/%=%)
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../Classes
To add other cpp files from another folder you can use ( LOCAL_SRC_FILES += ) just change directory name according to yours.
FILE_LIST := $(wildcard $(LOCAL_PATH)/../../../DirectoryName/*.cpp)
LOCAL_SRC_FILES += $(FILE_LIST:$(LOCAL_PATH)/%=%)
来源:https://stackoverflow.com/questions/45725259/cocos2d-x-on-android-studio-new-cpp-files-are-not-listed