命令列方式建立和編譯android應用程式

來源:互聯網
上載者:User

android為不喜歡用eclipse的同志提供了命令列建立project,編譯的方式。

建立project
android create project \--target <target_ID> \--name <your_project_name> \--path path/to/your/project \--activity <your_activity_name> \--package <your_package_namespace>

如下是一個例子

android create  project --target 4 --name test --path test --activity testactivity --package com.dlmu2001.android

可以執行如下命令擷取當前可用的target對應的ID

android list targets


參考http://developer.android.com/guide/developing/projects/projects-cmdline.html

問題:

Error: Error parsing the sdk.
Error: /home/tom/froyo/out/host/linux-x86/platforms is missing.
Error: Unable to parse SDK content.

原因:沒有編譯sdk,直接在編譯的android source中運行這些命令,需要在sdk中運行這兩個命令


建立project

Debug模式編譯可以自動簽名,執行ant debug就可以

release模式預設產生沒有簽名的,不能安裝。先執行keytool產生keystore,再修改build.properities,編譯後自動簽名。例:

keytool -genkey -alias test.keystore -keyalg RSA -validity 40000 -keystore test.keysotre

build.properties中加入如下兩句

key.store=/home/tom/android-sdk-linux_x86/exercise/test/test.keystorekey.alias=test.keystore

第一個設定的是key儲存的位置

編譯:

ant release

產生test-release.apk,在bin目錄下

參考:http://developer.android.com/guide/developing/building/building-cmdline.html#ManualReleaseMode

常見問題:

The Android Ant-based build system requires Ant 1.8.0 or later.Current version is ...

解決:到網站(http://ant.apache.org)下載最新版本,解壓到使用者根目錄,然後

cd /usr/sharemv ant ant_1.7mv ~/ant_1.8.2 ant

這樣再執行ant -version,已經是1.8.2的版本


簽名不成功

一般是path錯了,或者名字錯了,好好檢查下


編譯完以後,用adb install命令安裝到emulator或者device

如果要覆蓋安裝,加上-r選項



相關文章

聯繫我們

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