Can't link to cocos2dx using eclipse for android on OSX
Asked Answered
P

1

7

I've never spent so much time on initial setup for a development environment before, this is getting kind of ridiculous.

I'm trying to run the demo code that comes with cocos2dx. I'm using:

  • the eclipse flavor that comes with the ADK.
  • cocos2d-2.1beta3-x-2.1.0
  • ndk-r8c

Ive tried building an app template using create-android-project.sh which I had the same problems with but for this question I'll reference the hello.cpp sample app.

I run the build_native.sh script and then import it in eclipse. Next is where all the different tutorials I've tried vary. Some say to 'convert to a c++ project' some say you can already 'run as android project' at this point already.

For me it seem like the android java project can't link to the cocos2dx project.

I get:

The import org.cocos2dx.lib cannot be resolved

for

import org.cocos2dx.lib.Cocos2dxActivity

No tutorial really made any mention of having to build the cocos2dx libraries except for one that said you now have to import the cocos libraries as projects in to the eclipse workspace. So Ive done that and built them but there are some errors in them after building.

I've also tried adding the folder path to link to in the project which for me is at /cocos2d-2.1beta3-x-2.1.0/cocos2dx/platform/android/java/src/org/cocos2dx/lib but that didn't help.

Any idea why I can't build/run the examples that come with cocos2dx even when following the build instructions that are on the cocos2dx website to the T?

Pyrimidine answered 31/12, 2012 at 0:32 Comment(0)
K
8

I'm doing this now on OSX as well and this fixed it for me:

run the adroid script create-android-project.sh then import that new project into Eclipse

  1. in the new Eclipse project right-click the src folder > left-click 'Import'
  2. in the Import window choose Android > Existing Android Code Into Workspace > Next >>
  3. Browse to '/cocos2dx/platform/android/java' ('/cocos2dx/' should be be one level above the new project's directory)
  4. click Finish. If the error persists try a Project > Clean
Kotta answered 13/1, 2013 at 7:19 Comment(1)
In addition to all this I had to add the libcocos2dx in the new project's build path.Rashida

© 2022 - 2024 — McMap. All rights reserved.