Cocos2d-X v3 rc2 Project Won't Compile in Eclipse on OS X

I’m a Cocos2d-iPhone developer who is thinking about making some cross platform apps with Cocos2d-x.
I just crated a new project using the latest version (v3 rc2).

I’m trying to get the project up and running in Eclipse on OS X. I’m used to Xcode, where you don’t have to spend such an insane amount of time configuring a project and you can get right to coding (the way it should be). Unfortunately Google dev tools seem to be pretty far behind.

Anyway, I have the project set up. But it won’t build because of the following errors:

-Cocos2dxActivity cannot be resolved to a type.
-The import org.cocos2dx.lib cannot be resolved.

I searched around, all the solutions I’ve found seem to say that Eclipse cannot find the Cocos2d-x source files and to click on the project and set up properties and link some file path, which I cannot find, probably because the solutions are outdated?

I just want to get basic set up going in Eclipse. I plan to do most of the coding in Xcode and do the nasty Android specific stuff in Eclipse later.

Any help would be greatly appreciated.

Thanks all.

Specifically, the solutions I’ve found seem to say that I need to add this path in eclipse

/Users/XXX/lib/cocos2d-2.0-x-2.0.3/cocos2dx/platform/android/java/src

In v3, I do not see any platform folder inside the cocos2dx folder.

Okay, so I imported liCocos2dX into the project. But the errors still appear in Eclipse. Now 4 additional warnings show up after I imported the cocos2d lib

I took a screenshot.

Hello,

I had same problem, this link may help you : http://www.cocos2d-x.org/forums/6/topics/20357 :wink:

@AT2013 I think u didn’t import the cocos2d-x lib.

Thanks for the reply Ryuuke.

But that path COCOS2D-X_INSTALLATION_FOLDER/cocos2dx/platform/android/java/src does not seem to exist in V3 in the installation folder. I see no “platforms” folder in the Cocos2d-x folder. So much seemingly outdated stuff around. Wonder why they don’t just generate a project with all the template code properly set up? Are Google Dev tools really so bad, that basic project templates cannot be created?

1 Like

Also if I try to link …MyProject/cocos2d/cocos/2d/platform/android/java/src

Eclipse tells me that folder is already a source folder.

@yuye Thanks for replying.

Project template comes with

import org.cocos2dx.lib.Cocos2dxActivity;

At the top right out of the box?

Hi,

Same problem here on Win 7.
It appears to be some eclipse configuration issue.
The project builds / runs using the python scripts from prompt but not from eclipse.
Does your project have settings enabled under the CDT (C++) module under project preferences?

  1. In windows,can it “convert to” does not work and says its not a CDT project
  2. The android Tools > “add native support” option does not appear.

The output of cocos new XXX does not seem to create a .cproject file under proj.android either.

Therefore, the build_native.py doesn’t seem to appear anywhere like the build_native.sh we have in v2.
Suggestions appreciated.

Check if both your project and cocos project are set to use same version of Android platform in Project’s Android settings.

Hi,

The platform folder is under YOUR_COCOS2d_INSTALLATION_FOLDER/cocos/2d.

I’m using version 3.0 rc2 and full path is : /Users/Ryuuke/Documents/cocos2d-x-3.0rc2/cocos/2d/platform/android/java/src.

did you import on eclipse both of your project and libcocos2dx?

Hi,this may help you, becouse of cocos2d api modify, you had better replace the older proj.androd dir files with the one one, good luck too you!
http://www.cocos2d-x.org/forums/6/topics/51133?r=51271#message-51271

Hello, I read almost every post about this topic, but still can’t manage to run cocos2d-x v3 project on Eclipse. The problem is that C++ code is not resolved and it throws errors. I already converted project to C++ project. And now I must include some folders in properties->C/C++ General->Paths And Symbols->GNU C++. I must include /Users/levani/Documents/android-ndk-r9d/platforms/android-19/arch-arm/usr/include and some kind of cocos2d-2.1/cocos2dx/include folder, but the thing is that in cocos2d-x v3 there is no such folder and I am stuck, can’t find solution. Can anyone help me to resolve C++ code in cocos2d-x v3? http://devcircle.blogspot.com/2013/03/setting-up-cocos2d-x-for-android-game.html I followed this tutorial, but it’s written for older version.

I copied the org/cocos2dx/lib right into /src
and I did this a min ago on rc2 and worked, I hope this may be what you are looking for.

@kusamochi Thanks for answer, I made all the steps but have problem with last one:
“go to C/C++ build, change build command: /usr/bin/python ${workspace_loc:/EclipseTest}/build_native.py 8, Behaviour tab, select checkbox “Build on resource save”, “Build”, “Clean”, but clear all arguments 9, check .project, add the following with other buildCommand”

I selected those 3 checkboxes “Build on resource save”, “Build”, “Clean”. And after this is complete black out for me.

  1. “clear all arguments” - you mean I must delete values next to those checkboxes?
  2. “check .project, add the following with other buildCommand” - is .project some kind of file that I should modify and insert those build command? I can’t locate file with extension .project in android project.

@Levani512

I think by default, “Build” “Clean” is checked, then should be fine. (there you can play around and set it as you like, I think if u don’t clear the value next to checkboxes would also works, not much to worry about there)

yea, you need to edit the .project by hand (with some text editor) because the template project doesn’t have the buildCommand needed for u to just push the “play” button and execute, when u opened up the .project file, there should be other tags exists there, just insert in the right place (I am sure you know how).

PS note that ${workspace_loc:/EclipseTest} “EclipseTest” is your project folder name, I believe u can see it on another text field just below build command on the same screen.

I know it is complicated, but this is the quickest way I’ve found so far.