大家好!
在这里我介绍的是编辑原始的方法,我个人认为也是比较通用的方法,不管是现在cocos2d-x 2.2 还是cocos2d-x 3.0版本都是一样的
先来介绍android的编译过程:
在编译之前首先要准备几个东西
1、搭建android开发环境
http://developer.android.com/sdk/index.html 现在android开发环境
在这个工具里面已经集成了android的开发环境
2、因为要编译ndk,所有我们要搭建ndk的编译环境
首先要去去下载:Cygwin 地址:http://www.programarts.com/cfree_ch/doc/help/UsingCF/CompilerSupport/Cygwin/Cygwin1.htm
其次要去下载:ndk (注意:最好用现在的最新版本) 地址:https://developer.android.com/tools/sdk/ndk/index.html
配置 Cygwin:
找到Cygwin安装路径,找到cygwin\home\win7\.bash_profile 找到这个文件打开,在文件末尾加上:
NDK_ROOT=/cygdrive/E/android/android-ndk-r9c(这个你ndk的文件路径)
export NDK_ROOT
内容如下:
# base-files version 3.9-3
# To pick up the latest recommended .bash_profile content,
# look in /etc/defaults/etc/skel/.bash_profile
# Modifying /etc/skel/.bash_profile directly will prevent
# setup from updating it.
# The copy in your home directory (~/.bash_profile) is yours, please
# feel free to customise it to create a shell
# environment to your liking. If you feel a change
# would be benifitial to all, please feel free to send
# a patch to the cygwin mailing list.
# ~/.bash_profile: executed by bash for login shells.
# source the system wide bashrc if it exists
if [ -e /etc/bash.bashrc ] ; then
source /etc/bash.bashrc
fi
# source the users bashrc if it exists
if [ -e "${HOME}/.bashrc" ] ; then
source "${HOME}/.bashrc"
fi
# Set PATH so it includes user's private bin if it exists
# if [ -d "${HOME}/bin" ] ; then
# PATH=${HOME}/bin:${PATH}
# fi
# Set MANPATH so it includes users' private man if it exists
# if [ -d "${HOME}/man" ]; then
# MANPATH=${HOME}/man:${MANPATH}
# fi
# Set INFOPATH so it includes users' private info if it exists
# if [ -d "${HOME}/info" ]; then
# INFOPATH=${HOME}/info:${INFOPATH}
# fi
NDK=/cygdrive/E/android/android-ndk-r9c
export NDK
这个cygwin与ndk的配置就已经完成
测试是否配置成功,可以到:E:\android\android-ndk-r9c\samples\hello-jni 这个目录下面编译这个ndk自带的例子
如果出现这个说明编译成功了!说明cygwin和ndk的配置已经搭建好了
3、一切已经准备好,我们就开始编译我们cocos2d-x helloword
打开cygwin,进入/cocos2d-x-2.2.2/samples/Cpp/HelloCpp/proj.android 输入
这个就开始编译了: