Environment: 2dx-1.0.1-x-0.9.2
PS: In version 1.0.1, a new Android project is created. A default. properties file is missing and copied to the androud directory.
However, an error occurs during compilation to Android because the 2dx for Android project is not added to the box2d library.
You need to modify the following files:
Under the JNI directory
Application. mk
App_modules: = cocos2d box2d cocosdenshion game_logic game
Android. mk
Subdirs: = $ (addprefix $ (local_path )/.. /.. /, $ (Addsuffix/Android. mk ,\
Cocos2dx \
Box2d \
Cocosdenshion/Android \
))
Android. mk in helloworld
$ (Local_path )/.. /.. \
$ (Local_path )/.. /.. /Classes
Local_ldlibs: =-L $ (call host-path, $ (local_path )/.. /.. /Libs/$ (target_arch_abi ))\
-Lcocos2d-llog-lgame_logic-lbox2d
Android. mk in Classes
Local_c_includes: = $ (local_path )/.. /.. /Cocos2dx \
$ (Local_path )/.. /../\
$ (Local_path )/.. /../Box2d \
Local_ldlibs: =-L $ (call host-path, $ (local_path)/../Android/libs/$ (target_arch_abi ))\
-Lcocos2d-lcocosdenshion-lbox2d \
In this way, you can
PS. If you are prompted to import box. H, you must modify the position $ (local_path)/of box2d )/.. /../Box2d \.
From: http://leenjewel.blog.163.com/blog/static/60193792201162710514314/
In the previous log "use box2d in cocos2d-x" missed a step, it is likely to cause androidProgram. Here we will add some additional instructions. According to the previous log "use box2d in cocos2d-x" after the operation is completed, you also need to modify the main activity class of the android Project (inherited from cocos2dxactivity) file. The standard Android project file generated by cocos2d contains a main activity file.Code:
Static {
System. loadlibrary ("cocos2d ");
System. loadlibrary ("cocosdenshion ");
System. loadlibrary ("game ");
}
Here we need to introduce the box2d library. Note that the system. loadlibrary statement of the box2d library is introduced. Introduction
The box2d library statement must be placed before the system. loadlibrary ("game") statement, that is, to ensure
The system. loadlibrary ("game") statement is the last introduced operation statement. The modified code is like this:
static {
system. loadlibrary ("cocos2d");
system. loadlibrary ("box2d");
system. loadlibrary ("cocosdenshion");
system. loadlibrary ("game");
}
in this case, introduce box2d program in the cocos2d-x can run smoothly. In fact, not only box2d, there are other engines in the cocos2d-x, the need to introduce these library methods and the introduction of box2d method is similar, please put it in another place.