1.打开eclipse在PackageExploer内右击,将项目的.android文件导入eclipse,同样将项目的cocos2d/cocos/2d/platform/android/java也导入。
2.导入后,clean一下
3.打开jni下的android.mk导入路径,这里有种直接搜索路径的方法
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := cocos2dcpp_shared
LOCAL_MODULE_FILENAME := libcocos2dcpp
#traverse all the directory and subdirectory
define walk
$(wildcard $(1)) $(foreach e,$(wildcard $(1)/*),$(call walk,$(e)))
endef
#traverse Classes Directory
ALLFILES=$(call walk,$(LOCAL_PATH)/../../Classes)
FILE_LIST :=hellocpp/main.cpp
FILE_LIST +=$(filter %.cpp,$(ALLFILES))
FILE_INCLUDES :=$(shell find $(LOCAL_PATH)/../../Classes -type d)
#source file will be compiled
LOCAL_SRC_FILES :=$(FILE_LIST:$(LOCAL_PATH)/%=%)
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes
LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static
LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static
LOCAL_WHOLE_STATIC_LIBRARIES += Box2d_static
LOCAL_WHOLE_STATIC_LIBRARIES += cocos_extension_static
LOCAL_WHOLE_STATIC_LIBRARIES += cocostudio_static
include $(BUILD_SHARED_LIBRARY)
$(call import-module,2d)
$(call import-module,audio/android)
$(call import-module,Box2D)
$(call import-module,editor-support/cocostudio)
$(call import-module,extensions)
需要什么库再在后面添加
4.编译build_native.py(最好下载pyhon)
5.手机运行
注意cocos2d-x里面的log()函数有问题,转移到android里面可能不能通过编译.