- 说在前面
操作系统:win10 64位
vs版本:2017
python版本:2.7
Cocos2d-x版本:3.17
AndroidStudio 版本:3.2
- 步骤
1. 在cmd窗口中新建项目
cocos new angame -p com.example.angame -d d:/project -l cpp --portrait
生成后:
2. 用Android studio打开项目
3. 更改配置文件
gradle.properties
(前面Comple/Min/Target_SDK_Version Build_tools_Version选择自己已安装的版本,或者下载对应的版本)
(PROP_APP_ABI可以选择三项armeabi-v7a | arm64-v8a | x86,根据提示进行更改,例如=x86:armeabi-v7a)
# Android SDK version that will be used as the compile project
PROP_COMPILE_SDK_VERSION=27
# Android SDK version that will be used as the earliest version of android this application can run on
PROP_MIN_SDK_VERSION=14
# Android SDK version that will be used as the latest version of android this application has been tested on
PROP_TARGET_SDK_VERSION=27
# Android Build Tools version that will be used as the compile project
PROP_BUILD_TOOLS_VERSION=28.0.2
# List of CPU Archtexture to build that application with
# Available architextures (armeabi-v7a | arm64-v8a | x86)
# To build for multiple architexture, use the `:` between them
# Example - PROP_APP_ABI=armeabi-v7a:arm64-v8a:x86
PROP_APP_ABI=armeabi-v7a:x86
# android native code build type
# none, native code will never be compiled.
# cmake, native code will be compiled by CMakeLists.txt
# ndk-build, native code will be compiled by Android.mk
PROP_BUILD_TYPE=ndk-build
4. 设置NDK路径
填入下载的NDK路径
5. run
(使用虚拟机的话注意选择对应的CPU框架,也就是第三步中的armeabi-v7a | arm64-v8a | x86,可在AVD manager中下载不同版本的虚拟机)
建议使用x86版本,开启速度较快
6. 其他注意事项
当在Classes中引入了新的.cpp后,请在Android.mk文件中添加对应的语句