Android game development with Cocos2d lib

半世苍凉 提交于 2019-12-12 20:13:35

问题


I want to develop game development with Cocos2d . I am following the tutorial http://dan.clarke.name/2011/04/how-to-make-a-simple-android-game-with-cocos2d/ . I added external cocos2d-android.jar file but when i run sample apps then caused following error. please anyone help me.

04-18 13:09:50.783: E/AndroidRuntime(497): FATAL EXCEPTION: main
04-18 13:09:50.783: E/AndroidRuntime(497): java.lang.NoClassDefFoundError: org.cocos2d.opengl.CCGLSurfaceView
04-18 13:09:50.783: E/AndroidRuntime(497):  at com.agv.Cocos2d.CoCos2dActivity.onCreate(CoCos2dActivity.java:24)
04-18 13:09:50.783: E/AndroidRuntime(497):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-18 13:09:50.783: E/AndroidRuntime(497):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
04-18 13:09:50.783: E/AndroidRuntime(497):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
04-18 13:09:50.783: E/AndroidRuntime(497):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
04-18 13:09:50.783: E/AndroidRuntime(497):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
04-18 13:09:50.783: E/AndroidRuntime(497):  at android.os.Handler.dispatchMessage(Handler.java:99)
04-18 13:09:50.783: E/AndroidRuntime(497):  at android.os.Looper.loop(Looper.java:123)
04-18 13:09:50.783: E/AndroidRuntime(497):  at android.app.ActivityThread.main(ActivityThread.java:4627)
04-18 13:09:50.783: E/AndroidRuntime(497):  at java.lang.reflect.Method.invokeNative(Native Method)
04-18 13:09:50.783: E/AndroidRuntime(497):  at java.lang.reflect.Method.invoke(Method.java:521)
04-18 13:09:50.783: E/AndroidRuntime(497):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-18 13:09:50.783: E/AndroidRuntime(497):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-18 13:09:50.783: E/AndroidRuntime(497):  at dalvik.system.NativeStart.main(Native Method)

回答1:


NoClassDefFoundError usually means that the library has not being included in the compilation process. Check that you have added all the relevant jar files and that it is in the Build path in eclipse.




回答2:


check your manifest file. you have to declare the activities. I had similar problem and i solved it this way.




回答3:


Put the jar file into your project lib directory and then change the build path to this path. It solved my problem. If you will not put the jar files into your project then while building the apk it won't take the directory path which is on your computer.




回答4:


After you verify all the files are where they should be. Check to see if your hitting code that requires a permission that you might be missing.

My code compiles in Eclipse but I get a ClassNotFound at runtime how can I fix it?



来源:https://stackoverflow.com/questions/10210302/android-game-development-with-cocos2d-lib

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