Android Emulator 不能运行cocos2dx的解决方案

这两天搞跨平台的东西,发现cocos2dx不能在模拟器上运行,在网上查了查竟然没有这样的问题,最后还是靠stackoverflow定位到cocos2dx英文论坛中,最终找到了解决方案。

1.使用的引擎版本 cocos2d-2.0-rc0a-x-2.0

2.创建一个android工程后,打开项目,比如项目名称为test,就打开test.java

修改如下(默认有detectOpenGLES20函数,在return中添加Build.FINGERPRINT.startsWith("generic") )

[java]  view plain copy print ?
  1. private boolean detectOpenGLES20()   
  2.  {  
  3.      ActivityManager am =  
  4.             (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);  
  5.      ConfigurationInfo info = am.getDeviceConfigurationInfo();  
  6.      return (info.reqGlEsVersion >= 0x20000|| <span style="color:#ff0000;">Build.FINGERPRINT.startsWith("generic")</span>);  
  7.  }  

3.编辑AndroidManifest.xml如下,在最后添加

<uses-feature android:glEsVersion="0x00020000" android:required="true" />

[html]  view plain copy print ?
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <manifest xmlns:android="http://schemas.android.com/apk/res/android"  
  3.       package="com.sx.test3"  
  4.       android:versionCode="1"  
  5.       android:versionName="1.0">  
  6.   
  7.     <uses-sdk android:minSdkVersion="8"/>  
  8.   
  9.     <application android:label="@string/app_name"  
  10.         android:debuggable="true"  
  11.         android:icon="@drawable/ic_launcher">  
  12.   
  13.         <activity android:name=".test3"  
  14.                   android:label="@string/app_name"  
  15.                   android:screenOrientation="landscape"  
  16.                   android:theme="@android:style/Theme.NoTitleBar.Fullscreen"  
  17.                   android:configChanges="orientation">  
  18.             <intent-filter>  
  19.                 <action android:name="android.intent.action.MAIN" />  
  20.                 <category android:name="android.intent.category.LAUNCHER" />  
  21.             </intent-filter>  
  22.         </activity>  
  23.     </application>  
  24.     <supports-screens android:largeScreens="true"  
  25.                       android:smallScreens="true"  
  26.                       android:anyDensity="true"  
  27.                       android:normalScreens="true"/>  
  28.       
  29.      <span style="color:#ff0000;"><uses-feature android:glEsVersion="0x00020000" android:required="true" /></span>  
  30. </manifest>   

4.编辑Emulator,如下需要开启GPU



5.运行cocos2dx的android工程,如下


参考地址:

http://www.cocos2d-x.org/boards/6/topics/12563  (最终解决方案)

http://stackoverflow.com/questions/12203918/failure-in-running-helloworld-cocos2dx?rq=1

https://github.com/cocos2d/cocos2d-x/issues/1080


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值