Cocos2d-x on Android Studio - New CPP files are not listed

房东的猫 提交于 2019-12-04 20:16:33

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)/%=%)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!