This file is not part of the proejct

Hello,

I’m on a fresh coco2d x Android Studio project which works fine. Now I want to refract the HelloWorldScene.cpp/h by my own class Game.cpp/h.
So I do a refractor from HelloWorldScene to Game. In these files lot of red color appears.
And a message occurs:
“This file is not part of the project. Please include it in the appropriate file (build.gradle, CMakelists.txt or Android.mk etc) and sync the project.”

The problem is I dont know which file to edit for fix that. And this error prevents me from compiling.

Can you help me ?

@doums,

You need to update Android.mk file.
Android.mk file should contain path of the all CPP file to compile.

In Android.mk file , we define paths like this…

LOCAL_SRC_FILES := hellocpp/main.cpp \
                   ../../../Classes/AppDelegate.cpp \
                   ../../../Classes/CookHud.cpp \
                   ../../../Classes/HelloWorldScene.cpp \
	               ../../../Classes/HudLayer.cpp \
                   ../../../Classes/JoyStick.cpp \
                   ../../../Classes/Player.cpp \
		       ../../../Classes/Player_Selection.cpp \
			../../../Classes/ShootHud.cpp \
                   ../../../Classes/ShootIcon.cpp 

LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../Classes
1 Like

Okay and there is no way to do this automatically ? Without to have to edit the Android. mk manually ?

no automatic script yet…must got do copy and past .cpp names

Ok thanks you !

@doums well you can do it like this,
Remove LOCAL_SRC_FILES & add below 2 lines,
FILE_LIST := $(wildcard $(LOCAL_PATH)/../../Classes/*.cpp)
LOCAL_SRC_FILES := $(FILE_LIST:$(LOCAL_PATH)/%=%)
BUT
it will consider all your cpp files, so if you put some backup files in same folder then you have the problem.
choice is yours. :slight_smile:

Yes I know this trick, used sometimes in my makefile to select all files depends the pattern. But like you said it’s not safe and clean. But interesting to know it also works on Android. mk file. Thanks you.

Thanks @ Gurudath it’s worked.