fedora20 下配置cocos2d-x3.2开发环境 just for android

注:上篇日志没写完,是因为没时间搞那么复杂,做android又不是做linux的开发.因此在这篇日志中,只记录android环境的配置.


当前环境

系统:fedora20
cocos2d-x版本:3.2
C++ IDE:CLion
目标平台:Android
ANT:apache-ant-1.9.4-bin.tar.gz
NDK:android-ndk-r9d
ADT:adt-bundle-linux-x86_64-20140321
JDK:jdk-7u67-linux-x64.rpm

配置cocos2dx开发环境

新建目录,如cocos2dxenv,将需要的配置全部放进去.
cocos2dx3.2
ANT:apache-ant-1.9.4-bin.tar.gz
NDK:android-ndk-r9d
ADT:adt-bundle-linux-x86_64-20140321
JDK:jdk-7u67-linux-x64.rpm
进入目录:cocos2d-x-3.2,终端执行setup.py,会出现各种环境配置的输入.
./setup.py 

Setting up cocos2d-x...
->Check environment variable COCOS_CONSOLE_ROOT
  ->Search for environment variable COCOS_CONSOLE_ROOT...
    ->COCOS_CONSOLE_ROOT not found

  -> Add COCOS_CONSOLE_ROOT environment variable...
    ->Added COCOS_CONSOLE_ROOT=/root/cocos2denv/cocos2d-x-3.2/cocos2d-x-3.2/tools/cocos2d-console/bin

->Configuration for Android platform only, you can also skip and manually edit "/root/.bashrc"

->Check environment variable NDK_ROOT
  ->Search for environment variable NDK_ROOT...
    ->NDK_ROOT not found

  ->Search for command ndk-build in system...
    ->Command ndk-build not found

  ->Please enter the path of NDK_ROOT (or press Enter to skip):
输入对应的NDK根目录,如 我的是:
/root/cocos2denv/android-ndk-r9d

回车继续:
 -> Add NDK_ROOT environment variable...
    ->Added NDK_ROOT=/root/cocos2denv/android-ndk-r9d

->Check environment variable ANDROID_SDK_ROOT
  ->Search for environment variable ANDROID_SDK_ROOT...
    ->ANDROID_SDK_ROOT not found

  ->Search for command android in system...
    ->Command android not found

  ->Please enter the path of ANDROID_SDK_ROOT (or press Enter to skip):
输入SDK环境目录:
/root/cocos2denv/adt-bundle-linux-x86_64-20140321/sdk

回车继续:
->Check environment variable ANT_ROOT
  ->Search for environment variable ANT_ROOT...
    ->ANT_ROOT not found

  ->Search for command ant in system...
    ->Command ant not found

  ->Please enter the path of ANT_ROOT (or press Enter to skip):
ANT环境目录
ant是
apache-ant-1.9.4-bin.tar.gz
的解压结果, 我输入的是:/root/cocos2denv/apache-ant-1.9.4/bin
出现以下结果说明cocos2dx的第一步配置完成了(如果没有error的话,有error就是目录输入的不对):
A backup file "/root/.bashrc.backup1" is created for "/root/.bashrc".

Please execute command: "source /root/.bashrc" to make added system variables take effect

因为之前没有配置linux的cocos2dx开发环境,因此我们需要再配置JAVA-HOME的环境
首先安装JDK:
yum install jdk-7u67-linux-x64.rpm 
配置JAVA_HOME环境:
export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.65-2.5.2.5.fc20.x86_64



执行以下命令,生效环境配置:
source /root/.bashrc
验证结果:
cocos -v
0.7
OK

配置cocos2dx需要的链接库:

<pre name="code" class="cpp">yum install glibc-2.18-14.fc20.i686
yum install zlib-1.2.8-3.fc20.i686 libstdc++-4.8.3-1.fc20.i686 
 
    


创建Android项目:

在项目目录中执行创建命令:
cocos new hello -p com.hello.mygame -l cpp -d .
cd hello
cocos run -p android -j 
完成!


问题及解决:

1 编译android项目时出现如下问题:
/root/cocos2denv/adt-bundle-linux-x86_64-20140321/sdk/tools/ant/build.xml:698: Execute failed: java.io.IOException: Cannot run program "/root/cocos2denv/adt-bundle-linux-x86_64-20140321/sdk/build-tools/android-4.4.2/aapt" (in directory "/root/code_source/cocos2dx/hello/cocos2d/cocos/platform/android/java"): error=2, 没有那个文件或目录
Caused by: java.io.IOException: error=2, 没有那个文件或目录

解决办法:
此问题的原因是缺少库:
ld-linux.so.2
执行如下命令解决:
yum install glibc-2.18-14.fc20.i686

2 问题:
/root/cocos2denv/adt-bundle-linux-x86_64_20140321/sdk/build-tools/android-4.4.2/aapt: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory

BUILD FAILED
/root/cocos2denv/adt-bundle-linux-x86_64_20140321/sdk/tools/ant/build.xml:601: The following error occurred while executing this line:
/root/cocos2denv/adt-bundle-linux-x86_64_20140321/sdk/tools/ant/build.xml:653: The following error occurred while executing this line:
/root/cocos2denv/adt-bundle-linux-x86_64_20140321/sdk/tools/ant/build.xml:698: null returned: 127

解决办法:
<pre name="code" class="cpp" style="font-size: 13.63636302948px;">yum install zlib-1.2.8-3.fc20.i686
 
    
3 问题:
aapt] /root/cocos2denv/adt-bundle-linux-x86_64_20140321/sdk/build-tools/android-4.4.2/aapt: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory

BUILD FAILED
解决办法:
yum install libstdc++-4.8.3-1.fc20.i686

如遇其他问题再补充.





你可能感兴趣的:(android,python,解决方案,fedora,cocos2d-x)