[Solved]Android.mk config error

In my Android.mk.
there is a definition for LOCAL_SRC_FILES where each of the cpp file are listed.

CPP_FILES := $(shell find $(LOCAL_PATH)/../../Classes -name *.cpp)
LOCAL_SRC_FILES := hellocpp/main.cpp
LOCAL_SRC_FILES += $(CPP_FILES:$(LOCAL_PATH)/%=%)

H_FILES := $(shell find $(LOCAL_PATH)/../../Classes -name *.h)
LOCAL_C_INCLUDES += $(H_FILES:$(LOCAL_PATH)/%=%)

But build fail. I get errors:

jni/hellocpp/main.cpp:1:25: fatal error: AppDelegate.h: No such file or directory
 #include "AppDelegate.h"
                         ^
compilation terminated.
make: *** [obj/local/armeabi/objs-debug/cocos2dcpp_shared/hellocpp/main.o] Error 1
make: *** Waiting for unfinished jobs....
jni/../../Classes/AppDelegate.cpp:2:26: fatal error: LoadingScene.h: No such file or directory
 #include "LoadingScene.h"
                          ^
compilation terminated.

I also try add manual:

LOCAL_SRC_FILES := hellocpp/main.cpp \
                   hellocpp/myclass.cpp \
                   hellocpp/mynextclass.cpp \
                   ../../Classes/Screens/LaunchScreen.cpp \
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes \
					$(LOCAL_PATH)/../../Data \
					$(LOCAL_PATH)/../../Road \
					$(LOCAL_PATH)/../../etc_dir \
					$(LOCAL_PATH)/../../Screens

But I still get same error. Someone can tell me why and how to fix it. Thank you so much.

Hello!

I don’t know if this is going to fix the issue but when I modify the Android.mk file I also add every single .h to C_INCLUDES. So in the end you get something like this:

LOCAL_C_INCLUDES := $(LOCAL_PATH)/…/…/…/Classes
$(LOCAL_PATH)/…/…/…/Classes/Engine
$(LOCAL_PATH)/…/…/…/Classes/Engine/Tasks
$(LOCAL_PATH)/…/…/…/Classes/Engine/Zones
$(LOCAL_PATH)/…/…/…/Classes/Layers
$(LOCAL_PATH)/…/…/…/Classes/Platform
$(LOCAL_PATH)/…/…/…/Classes/Platform/Android
$(LOCAL_PATH)/…/…/…/Classes/Platform/iOS
$(LOCAL_PATH)/…/…/…/Classes/Scenes
…/…/…/Classes/AppDelegate.h
…/…/…/Classes/CustomGlobals.h
…/…/…/Classes/CustomMacros.h \

and so on.

The error states that it is not able to find the .h files, so it might be worth to try to add them one by one and not just the folders!

Hope this helps you!

Davide

1 Like

Thank you so much.
I forget Classes directory :smiley:

Glad it helped : )