Android SDK安裝

來源:互聯網
上載者:User

本文描述 Android SDK 安裝過程,包括:Android SDK 2.2, Eclipse 3.5.2(galileo), 和 Andoid Development Tools (ADT) plugin。

  一個前提是使用者已經安裝了 JDK5.0 或 JDK 6.0。並且在系統內容變數設定了 Path 包含 JDK 的 bin 目錄。

  [安裝 Android 2.2]

  1. 下載Android 2.2 “開始包”

  地址:http://developer.android.com/sdk/index.html 或者 http://androidappdocs.appspot.com/sdk/index.html。連結:android-sdk_r06-windows.zip。

  需要知道的是這個 zip 包並不是一個完整的軟體包。Android 軟體包採用“組件”的形式,使用者可以根據需要選取組件。上述zip檔案只包含了一個組件管理工具和一個基本的工具組件。

  2. 運行 Android SDK and AVD Manager.

  解壓縮上面的 zip 包,可以運行 SDK Setup.exe, 即啟動了Andoid SDK and AVD Manager。這個工具不但對Android SDK 組件進行管理,同時也是 Android 虛擬裝置管理器。(關於後者,參見後面樣本)。

  然後,可以用這個工具下載完整的 Android SDK 開發包。需要注意的如果網路使用了Proxy 伺服器,則(有可能)需在這個工具裡配置Proxy 伺服器網域名稱和連接埠。

  (本節內容參考:http://developer.android.com/sdk/installing.html 或 http://androidappdocs.appspot.com/sdk/installing.html)

  [安裝 Eclipse]

  地址:http://www.eclipse.org/downloads/ 下載Eclipse 3.5.2 ,同樣,只需解壓縮即可。

  [安裝 ADT]

  ADT 版本:

  ADT 0.9.7 (May 2010)

  ADT 0.9.6 (March 2010)

  ADT 0.9.5 (December 2009)

  ADT 0.9.4 (October 2009)

  使用 Eclipse 的升級管理器來安裝ADT:

  1. 啟動 Eclipse, 然後進入 Help > Install New Software.

  2. 在 Available Software 對話方塊裡,點擊 Add....

  3. 出現 Add Site 對話方塊,在 Name 域裡面輸入一個名字 (例如, "Android Plugin") ,在 "Location" 域裡面輸入 URL: https://dl-ssl.google.com/android/eclipse/

  4. 注意:如果有問題,可以把 https 換成 http 試一下。點擊 OK.

  5. 回到 Available Software 介面,你應該看到 "Developer Tools" 。選取 checkbox 。點擊 Next,

接受 license agreement, 然後點擊 Finish。

  6. 重起 Eclipse.

  [配置 ADT]

  配置 Eclipse 裡的 ADT,使其指向 Android SDK 。

  1. 選取 Eclipse Window > Preferences...

  2. 選擇 Android

  3. 點擊 Browse... 定位 Android SDK 目錄。

  4. 點擊 Apply, 然後 OK.

  (本節內容參考:http://androidappdocs.appspot.com/sdk/eclipse-adt.html)

  [建立虛擬設備]

  開發環境建立好了,就可以寫一個“Hello World”應用。但在之前,還需建立一個虛擬設備。

  運行 Eclipse, 選取 Window > Android SDK and AVD Manager.

  在左側面板選擇 Virtual Devices

  點擊 New.

  出現 Create New AVD 對話方塊

  輸入 AVD 名字, 例如 "my_avd".

  選取一個目標。目標是一個平台 (即,Android SDK 的版本,如 2.2)

  暫時忽略其他設定

  點擊 Create AVD.

  [Hello World]

  1). 建立一個新的 Android project

  在建立 AVD 之後, 下個步驟就是在 Eclipse 裡開始一個新的 Android 項目。

  運行 Eclipse, 選取 File > New > Project.

  如果 ADT 外掛程式正確安裝了,應該在 "Android Project" 裡面有一項:"Android" 。(在你建立了一個或多個Android 項目後,一個 "Android XML File" 入口也應該可見。)

  選擇 "Android Project" 並點擊 Next.

  填寫項目資訊如下:

  Project name: HelloAndroid

  Application name: Hello, Android

  Package name: com.example.helloandroid (or your own private namespace)

  Create Activity: HelloAndroid

  點擊 Finish.

  2). 編寫代碼:列印 Hello Android

  package com.android.helloandroid;

  import android.app.Activity;

  import android.os.Bundle;

  import android.widget.TextView;

  public class HelloAndroid extends Activity {

    @Override

    public void onCreate(Bundle savedInstanceState) {

      super.onCreate(savedInstanceState);

      TextView tv = new TextView(this);

        tv.setText("Hello, Android");

      setContentView(tv);

    }

  }

  3)運行

  ADT 使運行非常簡單:

  選取 Run > Run.

  選取 "Android Application".

  (Hello World, 參見:http://androidappdocs.appspot.com/resources/tutorials/hello-world.html )

  附:Android SDK release number:

  Android SDK 2.2 Revision 1 (May 2010) API Level: 8 Requires SDK Tools r6 or higher. FroYo

  Android SDK 2.1 Revision 2 (May 2010) API Level: 7 Requires SDK Tools r6 or higher. Eclair

  Android SDK 2.1 Revision 1 (Jan 2010) API Level: 7 Requires SDK Tools r6 or higher. Eclair

  Android SDK 2.0.1 API Level: 6 Requires SDK Tools r6 or higher. Eclair

  Android SDK 2.0 API Level: 5 Requires SDK Tools r6 or higher. Eclair

  Android SDK 1.6 Revision 3 (May 2010) API Level: 4 Requires SDK Tools r6 or higher. Donut

  Android SDK 1.6 Revision 2 (Dec 2009) API Level: 4 Requires SDK Tools r6 or higher. Donut

  Android SDK 1.6 Revision 1 (Sep 2009) API Level: 4 Requires SDK Tools r6 or higher. Donut

  Android SDK 1.5 Revision 3 (Jul 2009) API Level: 3 Requires SDK Tools r6 or higher. Cupcake

  Android SDK 1.5 Revision 2 (May 2009) API Level: 3 Requires SDK Tools r6 or higher. Cupcake

  Android SDK 1.5 Revision 1 (Api 2009) API Level: 3 Requires SDK Tools r6 or higher. Cupcake

  Android SDK 1.1 API Level: 2

  Android SDK 1.0 API Level: 1

相關文章

聯繫我們

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