Under the Mac good not to write the game, I thought it would be easy to compile into Android project, unexpectedly get nearly 1 days to solve the problem
First, without the Jsoncpp of the compilation method, please refer to: http://www.bold-it.com/ios/cocos2d-x-box2d-iosandroid-hybrid-tutorial/
With Jsoncpp third-party library reference http://blog.csdn.net/sniffer12345/article/details/7336732, the author expressed thanks.
I am using the normal version of Jsoncpp, in the Jsoncpp folder to create a new android.mk, the content is
[Plain]View Plaincopy
- Local_path: = $ (call My-dir)
- Include $ (clear_vars)
- Local_module: = jsoncpp_static
- Local_module_filename: = Libjsoncpp
- Local_cppflags: =-fexceptions
- Local_src_files: = src/lib_json/json_internalarray.inl \
- SRC/LIB_JSON/JSON_INTERNALMAP.INL \
- SRC/LIB_JSON/JSON_VALUEITERATOR.INL \
- Src/lib_json/json_reader.cpp \
- Src/lib_json/json_value.cpp \
- Src/lib_json/json_writer.cpp
- Local_export_c_includes: = $ (Local_path)/.
- Local_c_includes: = $ (Local_path)/. \
- $ (local_path)/include \
- $ (Local_path)/src/lib_json
- Include $ (build_static_library)
You will then need to modify the configuration in the Proj.android/jni/android.mk, which is configured as follows
[Plain]View Plaincopy
- Local_path: = $ (call My-dir)
- Include $ (clear_vars)
- Local_module: = game_shared
- Local_module_filename: = Libgame
- Local_src_files: = hellocpp/main.cpp \
- .. /.. /classes/appdelegate.cpp \
- .. /.. /classes/basesprite.cpp\
- .. /.. /classes/gamelayer.cpp \
- .. /.. /classes/gamemenu.cpp \
- .. /.. /classes/gamescene.cpp \
- .. /.. /classes/jsonutils.cpp \
- .. /.. /classes/levellayer.cpp \
- .. /.. /classes/levelmanager.cpp \
- .. /.. /classes/optionscene.cpp \
- .. /.. /classes/spritefactory.cpp \
- .. /.. /classes/welcomelayer.cpp
- Local_c_includes: = $ (Local_path)/. /.. /classes \
- $ (Local_path)/.. /.. /libs/box2d\
- $ (Local_path)/.. /.. /libs/jsoncpp/include/json/
- Local_whole_static_libraries: = Jsoncpp_static cocosdenshion_static
- Local_whole_static_libraries + = Cocos2dx_static
- Local_whole_static_libraries + = Cocos_extension_static
- Local_whole_static_libraries + = Box2d_static
- Include $ (build_shared_library)
- $ (call import-module,jsoncpp) \
- $ (call import-module,cocosdenshion/android) \
- $ (call import-module,cocos2dx) \
- $ (call import-module,extensions) \
- $ (call import-module,box2d)
If an error still occurs, refer to the configuration method in the first link (very important)
Excerpt from: http://blog.csdn.net/ashqal/article/details/8728269