Cocos2d-x 3.x 如何編譯成安卓程式

來源:互聯網
上載者:User

標籤:

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 如何編譯成安卓程式

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.