標籤:
1.安裝JDK
2.安裝eclipse,安卓官方現在不提供eclipse for android,只好自己配置了。首先安裝一個eclipse,在Help——Install New SoftWare中安裝ADT
地址為http://dl-ssl.google.com/android/eclipse
可能需要漫長的等待。
3.建立AVD。根據http://www.cocos2d-x.org/boards/6/topics/12563 所說,需要安裝4.0.3以上的虛擬機器。
4.在eclipse中匯入proj.android工程,會自動編譯,需要等待幾分鐘。
編譯完成後,發現有一個錯誤提示,從工程——cocos2d——cocos——platform——android——java——src中將org和com檔案夾拷貝到當前工程中,錯誤提示消失。
5.在虛擬機器啟動並執行時候,又遇到了另一個錯誤:
java.lang.IllegalArgumentException: No configs match configSpec
解決方案:
①在AndroidMainfest檔案中將<uses-feature android:glEsVersion="0x00020000">改為
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
②在android-sdk安裝目錄下的 \samples\android-16\ApiDemos\src\com\example\android\apis\graphics裡
GLES20Activity.java中的方法detectOpenGLES20,修改成
import android.os.Build; private boolean detectOpenGLES20() { ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); ConfigurationInfo info = am.getDeviceConfigurationInfo(); return (info.reqGlEsVersion >= 0x20000 || Build.FINGERPRINT.startsWith(‘generic‘)); }
③在AVD設定中勾選Use Host GPU
6.終於正常運行了!另:在manifest中修改為android:screenOrientation="portrait"可以設為豎屏,預設為橫屏。
Cocos2d-x 3.x 如何編譯成安卓程式