Linux命令列下編譯Android NDK的範例程式碼

來源:互聯網
上載者:User

標籤:android   cantk   ndk   

這幾天琢磨寫一個Android的Runtime用來加速HTML5 Canvas,讓GameBuilder+CanTK 不但開發速度快,運行速度也能接近原生應用。所以花了點時間研究
Android NDK,網上的資料都是講IDE裡的編譯方法,這裡記錄一下命令列下的編譯方法,供有需要的朋友參考。

這裡以編譯hello-gl2為例:

  • 0.安裝Android NDK/SDK,設定PATH變數(根據具體情況調整)
PATH=$PATH:/work/android/android-sdk-linux/platform-tools/:/work/android/android-sdk-linux/tools/PATH=$PATH:/work/android/android-ndk-r8/build/tools:/work/android/android-ndk-r8/export PATH
  • 1.用android建立一個新工程
cd /work/android/android-ndk-r8/samplesandroid create project -n Hello -p hello -a Main -k com.hello -t 1

建立這個工程的目的是產生ant編譯需要的檔案:

build.xml local.properties project.properties
  • 2.現在需要編譯那個NDK例子,就把這幾個檔案拷貝到對應的目錄下。這裡編譯hello-gl2:
[lixianjing@lixianjing samples]$ cp hello/build.xml hello-gl2/[lixianjing@lixianjing samples]$ cp hello/local.properties hello-gl2/[lixianjing@lixianjing samples]$ cp hello/project.properties hello-gl2/
  • 3.然後編譯,先用ndk-build編譯原生代碼,再用ant debug生產apk。
[lixianjing@lixianjing hello-gl2]$ ndk-build [lixianjing@lixianjing hello-gl2]$ ant debug

Linux命令列下編譯Android NDK的範例程式碼

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.