Cocos2d,h file not found in a newly added file

Hey everyone, hope you are all well.
I am new to cocos2dx with Android Studio. I have previously worked with Visual Studio. I am using cocos2dx V4.0 and Android Studio V4.0.1
Here’s the problem, when I added a new cpp file, it shows a ‘cocos2d.h file not found’ error in the header file. This works fine for default classes but not for newly added classes. I did a bit of searching, some suggested making changes to the android.mk file each time I added a new class, but there is no android.mk file in my folder. There is a cmakelists.txt file, but I don’t know how to add new files to it. Another thing is a sync option now available in the .cpp file, but it remains the same after syncing.
I am adding attachments to both .h and .cpp file.
Someone please help me.

How did you make this project?

Check your library and header search paths.

I made that by cocos new … command. After completing the process, I opened it in Android Studio and made some recommended changes to the sdk manager such as including cmake and all. Then built my project, it worked fine and created an app in my mobile with default function and interface. After that, I added a new cpp file and then these errors occure.
There are two cmakelists.txt file, one at the root folder and another inside cocosd/cocos/platform/android folder.

library details are like this
inside root folder cmaklists.txt

and inside android folder file 4

I didn’t find any header path details in cmakelists.txt Are those in the same file?

I had some real problems with this as well! Try this out.

Thank you so much @bongiszubbis. This worked for me. :grin:

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.