pstar
February 13, 2011, 10:09am
#1
First, Great job on cocos2d-x.
I’m a relative noob developing on the iPhone and this is a great way to use what I’m learning on android.
I’ve managed to compile and run the tests, helloworld and create a new project named Cocos2dSimpleGame.
I’m trying to add chipmunk to no success.
I’ve added…
chipmunk
to the Android.mk
and…
LOCAL_C_INCLUDES := $(LOCAL_PATH)/…/…/…/…/cocos2dx $(LOCAL_PATH)/…/…/…/…/cocos2dx/include $(LOCAL_PATH)/…/…/…/tests $(LOCAL_PATH)/…/…/…/… $(LOCAL_PATH)/…/…/… $(LOCAL_PATH)/…/…/…/chipmunk/include/chipmunk
it is used for ndk-r4
LOCAL_LDLIBS := ~~L$/…/…/libs/armeabi ~~lcocos2d ~~llog ~~lchipmunk
to the HelloWorld/Android.mk
and added…
System.loadLibrary(“chipmunk”);
to Cocos2dSimpleGame.java
It builds fine, but when I try to run the app on the device I keep getting “Cocos2dSimpleGame has stopped unexpectedly, try again”
What am i missing here?
Thanks in advance
Pat
pstar
February 14, 2011, 6:03am
#2
I spent the whole weekend and still lost here?
What does your logcat say?
pstar
February 14, 2011, 3:10pm
#4
strawberry,
This is what I get in the logcat…
02-14 17:58:44.832: ERROR/AndroidRuntime(6414): FATAL EXCEPTION: main
02-14 17:58:44.832: ERROR/AndroidRuntime(6414): java.lang.ExceptionInInitializerError
02-14 17:58:44.832: ERROR/AndroidRuntime(6414): at java.lang.Class.newInstanceImpl(Native Method)
02-14 17:58:44.832: ERROR/AndroidRuntime(6414): at java.lang.Class.newInstance(Class.java:1429)
02-14 17:58:44.832: ERROR/AndroidRuntime(6414): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
02-14 17:58:44.832: ERROR/AndroidRuntime(6414): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
02-14 17:58:44.832: ERROR/AndroidRuntime(6414): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
02-14 17:58:44.832: ERROR/AndroidRuntime(6414): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
02-14 17:58:44.832: ERROR/AndroidRuntime(6414): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
02-14 17:58:44.832: ERROR/AndroidRuntime(6414): at android.os.Handler.dispatchMessage(Handler.java:99)
02-14 17:58:44.832: ERROR/AndroidRuntime(6414): at android.os.Looper.loop(Looper.java:123)
02-14 17:58:44.832: ERROR/AndroidRuntime(6414): at android.app.ActivityThread.main(ActivityThread.java:4627)
02-14 17:58:44.832: ERROR/AndroidRuntime(6414): at java.lang.reflect.Method.invokeNative(Native Method)
02-14 17:58:44.832: ERROR/AndroidRuntime(6414): at java.lang.reflect.Method.invoke(Method.java:521)
02-14 17:58:44.832: ERROR/AndroidRuntime(6414): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
02-14 17:58:44.832: ERROR/AndroidRuntime(6414): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
02-14 17:58:44.832: ERROR/AndroidRuntime(6414): at dalvik.system.NativeStart.main(Native Method)
02-14 17:58:44.832: ERROR/AndroidRuntime(6414): Caused by: java.lang.UnsatisfiedLinkError: Library helloworld not found
02-14 17:58:44.832: ERROR/AndroidRuntime(6414): at java.lang.Runtime.loadLibrary(Runtime.java:461)
02-14 17:58:44.832: ERROR/AndroidRuntime(6414): at java.lang.System.loadLibrary(System.java:557)
02-14 17:58:44.832: ERROR/AndroidRuntime(6414): at org.cocos2dx.cocos2dsimplegame.Cocos2dSimpleGame.(Cocos2dSimpleGame.java:36)
Thanks for you help
Pat
walzer
February 14, 2011, 6:09pm
#5
@Pat
Sorry. I apologize for the delay.
Ming is our chief programmer on android, but he is on maternity leave with his wife in this whole week.
I have to facing all tech support requirements in China and beyond, more than 50 active developers. so busy…
Well, I will create the android project and try to add chipmunk dependance. But I’m not very familiar to android, it make take some times.
walzer
February 15, 2011, 12:21am
#6
well, I follow your steps, and find a trap here, in Cocos2dSimpleGame.java
I guess your code may like this:
static {
System.loadLibrary("cocos2d");
System.loadLibrary("helloworld");
System.loadLibrary("chipmunk");
}
You may added chipmunk at the end. But this will case the error “stopped unexpectedly”, as you descripted above.
change the order like this
static {
System.loadLibrary("cocos2d");
System.loadLibrary("chipmunk");
System.loadLibrary("helloworld");
}
It works well. Note that helloworld depends on chipmunk, so you must load chipmunk before helloworld.
My solution is the attachment. You can run it, and compare to your source. I add some source invoking chipmunk in HelloWorldScene.cpp
Apologize for the late reply again, hope you can enjoy this engine
pstar
February 15, 2011, 6:45am
#7
Walzer,
I’ll give that a try.
Thanks for your time and patience.
Pat
edited: That worked great! I’ll need to pay attention to loading order.
Hello,kanrinin_kanmasato(hirokazu_ono).
I ported cocos2d-x’s “chipmunk” & “BOX2D” to the Android Apps(applications) as to work.
Prease also see this url of git site below.
(I’m sorry that I also posted to “another BOX2D’s forum” just a little minutes ago. )