1. Generate Cocos Prebuild Library
Debug
or Cocos gen-libs-m release
2. Create a test project with a command
Cocos New Test-l CPP
3. Modify Android Project
Modify the following two files:
1. Proj.android/build-cfg.json2. Proj.android/jni/android.mk
Build-cfg.json
Modify the following,e:/cocos2d-x-3.8.1 is the root directory of 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
Replace
$ (call import-add-path,$ (Local_path)/. /.. /cocos2d) $ (Call import-add-path,$ (Local_path)/. /.. /cocos2d/External) $ (call import-add-path,$ (Local_path)/. /.. /cocos2d/cocos)
For
$ (call import-add-path,$ (Local_path)/. /.. /COCOS2D/COCOS/PREBUILT-MK)
4. Perform command compilation
Cocos compile-p android-m Release
Compilation is fast, but the APK size will be larger, HelloWorld project has 5.4MB
cocos2d3.8.1 using Prebuild to boost Android speed release