使用Cygwin下载下列命令:
autoconf, automake, binutils, gcc-core, gcc-g++, gcc4-core, gcc4-g++, gdb, pcre, pcre-devel, gawk, make
windows 环境变量
JAVA_HOME C:\Program Files\Java\jdk1.7.0_09 NDK_ROOT E:\services\android-ndk
加入PATH中:
E:\Portable\cygwin\bin; #这个放在path的最前面 C:\Program Files\Java\jdk1.7.0_09\bin; E:\services\android-sdk-windows\tools; E:\services\android-sdk-windows\platform-tools;
cygwin环境变量
Windows的文件的cygwin下没有权限,文件的权限显示的是----------+,没有读写的权限。添加这行到
none /cygdrive cygdrive binary,noacl,posix=0,user 0 0
到vi /etc/fstab文件.
vi .bash_profile NDK_ROOT=e:\android\android-ndk-r8 export NDK_ROOT
可以才cygwin中执行以下命令查看环境变量:
env|grep xxx
chmod -R 775 cocos2d-x //首先更改下目录的权限,如果不行的话手动更改 cd /cygdrive/e/workspace/js/cocos2d-x/tools/project-creator/ ./create_project.py -project MyGame -package com.MyCompany.AwesomeGame -language javascript //建立新项目
1.设置COCOS2DX变量
2.设置C++环境变量 NDK_ROOT和CYGWIN和SHELLOPTS变量
3.添加 NDK_MODULE_PATH
以下三个位置皆可:
E:\workspace\js\cocos2d-x;E:\workspace\js\cocos2d-x\cocos2dx\platform\third_party\android\prebuilt
4.导入项目
$ cd cocos2d-x/samples/Cpp/TestCpp/proj.android/ $ export NDK_ROOT=/path/to/ndk $ ./build_native.sh $ ant debug install
如果这个命令的结果 : sdk.dir missing error then do:
$ android list target $ android update project -p . -t (id from step 6) $ android update project -p cocos2d-x/cocos2dx/platform/android/java/ -t (id from step 6)
如果出现
*** multiple target patterns. stop
直接删除Lib, Obj两个文件夹重新编译。
Android.mk:44: *** [color=#FF0000]commands commence before first target[/color]. Stop.
在Android.mk中检查有没有注释,空行或者空格 Check there are no comments,no space ,no empty line in the src includes of Android.mk
$ ndk-build clean Android NDK: Could not find application project directory ! Android NDK: Please define the NDK_PROJECT_PATH variable to point to it. /cygdrive/c/android-ndk-r4b/build/core/build-local.mk:85: *** [color=#FF0000]Android NDK: Aborting[/color] . Stop.
Fix: include Android.mk location inside global application.mk and Android.mk Run the command from the parent directory with app.mk and and.mk resides
Please define ANDROID_NDK_ROOT to point to the root of your Android NDK installation. Use case while executing shell script xxx-desktop:~/bin/u/android-ndk-r5/build/tools$ ./rebuild-all-prebuilt.sh Please define ANDROID_NDK_ROOT to point to the root of your Android NDK installation.
// Run the script inside NDK root directory like shown below xxx-desktop:~/bin/u/android-ndk-r5/build/tools$ cd .. xxx-desktop:~/bin/u/android-ndk-r5/build$ cd .. xxxx-desktop:~/bin/u/android-ndk-r5$ ./build/tools/rebuild-all-prebuilt.sh
Android NDK: jni/Android.mk: Cannot find module with tag 'cocos2dx' in import path Android NDK: Are you sure your NDK_MODULE_PATH variable is properly defined ? Android NDK: The following directories were searched: Android NDK: jni/Android.mk:19: *** Android NDK: Aborting. . Stop.
没有设置NDK_MODULE_PATH
E:\workspace\js\cocos2d-x;E:\workspace\js\cocos2d-x\cocos2dx\platform\third_party\android\prebuilt
Cocos2dxActivity cannot be resolved to a type
build_native.sh运行成功后,将项目导入到eclipse中后会出现这个问题,事实上在项目中有一个project.properties文件其中有这么一行配置信息:
android.library.reference.1=../../cocos2dx/platform/android/java
两种做法: