How to add CocosDenshion into Helloworld Android

Hi All
I am using cocos2d-0.99.5-x-0.7.2-rc. I want to use CocosDenshion in the Android Helloworld. I learn and copy the Android.mk from test
cocos2d-0.99.5-x-0.7.2-rc\tests\test.android\jni\Android.mk and cocos2d-0.99.5-x-0.7.2-rc\tests\test.android\jni\tests\Android.mk.
Below is my modified content. But after I compile successfully in cygwin and adb install it to my andriod, hellowrold will crash after I run it.

Do I need more modification except the two android.mk?
Thanks!

My
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)

subdirs := $(addprefix $(LOCAL_PATH)/…/…/…/,$(addsuffix /Android.mk, cocos2dx CocosDenshion/android ))
subdirs += $(LOCAL_PATH)/helloworld/Android.mk

include $(subdirs)

/////////////////////////////////////////////////////////////////
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := helloworld

LOCAL_SRC_FILES := main.cpp …/…/…/AppDelegate.cpp …/…/…/HelloWorldScene.cpp

LOCAL_C_INCLUDES := $(LOCAL_PATH)/…/…/…/…/cocos2dx $(LOCAL_PATH)/…/…/…/…/cocos2dx/include $(LOCAL_PATH)/…/…/…/… $(LOCAL_PATH)/…/…/… $(LOCAL_PATH)/…/…/…/…/CocosDenshion/include

LOCAL_LDLIBS := ~~L$/…/…/libs/armeabi ~~lGLESv1_CM lcocos2dlcocosdenshion ~~llog
# it is used for ndk-r5
# because the new Windows toolchain doesn’t support Cygwin’s drive
# mapping
# LOCAL_LDLIBS :=~~L$(call host-path, $(LOCAL_PATH)/…/…/libs/armeabi) # lcocos2dllog

include $(BUILD_SHARED_LIBRARY)

Plz ref to this post http://www.cocos2d-x.org/boards/10/topics/586
Adding CocosDenshion is the same to adding chipmunk.
I think you had to call System.loadLibrary in YourGame.java

You have to also add this

System.loadLibrary(“cocosdenshion”);

to your .java file.

follow the format at the bottom of tests/tests.android/src/org/tests/TestDemo.java file.
Pay attention to the loading order.

PatS

sorry Walzer, I didn’t see you had already replied.

@Pat, thank you all the same :slight_smile:

Thanks to Pat and Walzer. It works well.

Update. We also need add the test.android\src\org\cocos2dx\lib
Cocos2dxMusic.java Cocos2dxSound.java into HelloWorld\android\src\org\cocos2dx\lib

and Replace with new Cocos2dxActivity.java