kingBook

导航

cocos2d3.8.1 使用prebuild提升发布android速度

1.生成cocos prebuild库

  cocos gen-libs -m debug
或 
cocos gen-libs -m release

2.使用命令创建test项目

cocos new test -l cpp

3.修改android项目

修改以下两个文件:

1. proj.android/build-cfg.json
2. proj.android/jni/Android.mk

 

build-cfg.json

修改如下,E:/cocos2d-x-3.8.1为cocos2d3.8.1的根目录

{
    "ndk_module_path" :[
        "E:/cocos2d-x-3.8.1",
        "E:/cocos2d-x-3.8.1/cocos/prebuilt-mk",
        "E:/cocos2d-x-3.8.1/cocos",
        "E:/cocos2d-x-3.8.1/external"
    ],
    "copy_resources": [
        {
            "from": "../Resources",
            "to": ""
        }
    ]
}

 

Android.mk

替换

$(call import-add-path,$(LOCAL_PATH)/../../cocos2d)
$(call import-add-path,$(LOCAL_PATH)/../../cocos2d/external)
$(call import-add-path,$(LOCAL_PATH)/../../cocos2d/cocos)

$(call import-add-path,$(LOCAL_PATH)/../../cocos2d/cocos/prebuilt-mk)

4.执行命令编译

cocos compile -p android -m release

编译的速度很快,但apk的大小会变大,helloWorld项目有5.4MB

posted on 2016-01-19 10:39  kingBook  阅读(609)  评论(0编辑  收藏  举报