Cocos 2.0 - Box2D with Android project

Cocos 2.0 - Box2D with Android project

Hi,

Im using the new version of Cocos2D (2.0)

I want know how i can add box2d library to my android project. With iOS my game is running perfect and in android too, but when i add box2d, on iOS it compile with success and run, but on android i get some exceptions.

I try follow this tutorial, but the files are so differents:
http://gameit.ro/2011/08/creating-a-cocos2d-x-box2d-android-project/

See the screenshot attached plz.

Thanks.


Screen Shot 2012-06-01 at 4.10.02 AM.png (205.1 KB)

You should use create-android-project.sh to create android project.
Please refer [[How to create android project with script]] for more detail information.

Im attaching another screenshot.

The libbox2d is not building when i run “build_native.sh”

@Mingoo

Im already have a android project. It is running while im not using box2d one hour ago.

The problem is when i put box2d on the project.

Did you see the screenshot?

wow!

I see the parameter “box2d” now. Thanks! I will try!

Hi,

Now it is working. Perfect!

But the .sh script has a bug when add box2d parameter.

It forgot add the paths for Box2D includes.

LOCAL_C_INCLUDES := $(LOCAL_PATH)/…/…/Classes $(LOCAL_PATH)/…/…/…/…/Box2D $(LOCAL_PATH)/…/…/…/…/

instead of only:

LOCAL_C_INCLUDES := $(LOCAL_PATH)/…/…/Classes

Can you add it on official script? with this everything is working

Thanks man!

Please refer tests/Classes/Android.mk.
You should only add this

$(call import-module,Box2D)

Box2D module already exports its header path.

But my Android.mk already has it, and if i remove that line that i say, Box2D.h file is not found. Look my Android.mk:

LOCAL_PATH := $(call my-dir)
>
include $(CLEAR_VARS)
>
LOCAL_MODULE := game_shared
>
LOCAL_MODULE_FILENAME := libgame
>
LOCAL_SRC_FILES := helloworld/main.cpp > …/…/Classes/AppDelegate.cpp > …/…/Classes/engine/GameObjects.cpp > …/…/Classes/engine/SplashManager.cpp > …/…/Classes/engine/scenes/SplashScene.cpp > …/…/Classes/engine/scenes/SplashScene1.cpp > …/…/Classes/engine/scenes/SplashScene2.cpp > …/…/Classes/engine/stages/StageScene.cpp > …/…/Classes/engine/entities/Player.cpp > …/…/Classes/engine/GameEvents.cpp > …/…/Classes/engine/CCParallaxScrollNode.cpp > …/…/Classes/engine/CCParallaxScrollOffset.cpp > …/…/Classes/engine/entities/Coin.cpp > …/…/Classes/engine/entities/Entity.cpp > …/…/Classes/engine/Util.cpp > …/…/Classes/engine/entities/Enemy.cpp > …/…/Classes/engine/entities/Effect.cpp > …/…/Classes/engine/ContactListener.cpp >
LOCAL_C_INCLUDES := $(LOCAL_PATH)/…/…/Classes $(LOCAL_PATH)/…/…/…/…/Box2D $(LOCAL_PATH)/…/…/…/…/
>
LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static cocosdenshion_static box2d_static
>
include $(BUILD_SHARED_LIBRARY)
>
$(call import-module,CocosDenshion/android) $(call import-module,cocos2dx) $(call import-module,Box2D)

If i remove the paths:

$(LOCAL_PATH)/…/…/…/…/Box2D $(LOCAL_PATH)/…/…/…/…/

I got exception:

error: Box2D.h: No such file or directory