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

…衆ロ難τιáo~ 提交于 2019-12-21 04:28:28

问题


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?


回答1:


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


来源:https://stackoverflow.com/questions/14096191/cant-link-to-cocos2dx-using-eclipse-for-android-on-osx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!