Ubuntu10.04下Android開發環境搭建

來源:互聯網
上載者:User

轉載地址:http://www.cnblogs.com/nju-dwk/archive/2012/03/01/2376136.html

轉載原因:裡面的不錯,用的時候直接下。

1.  卸載OpenJDK

     新立得軟體中心中徹底刪除包含OpenJDK的包

2.  安裝Sun JDK1.6

[1] 從http://www.oracle.com/technetwork/java/javase/downloads/jdk-6u31-download-1501634.html

     下載jdk-6u31-linux-i586.bin檔案

[2] 將jdk-6u31-linux-i586.bin檔案移動到想要安裝JDK的位置,這裡移動到/usr/local/java中,當然也可以不移動

     $ mv jdk-6u31-linux-i586.bin /usr/local/java

[3] 運行該檔案

     $ cd /usr/local/java

     $ ./jdk-6u31-linux-i586.bin

[4] 修改環境變數

     $ sudo gedit /etc/profile

     在檔案最後添加以下內容:

     export JAVA_HOME=/usr/local/java/jdk1.6.0_31
   export JRE_HOME=/usr/local/java/jdk1.6.0_31/jre
     export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
     export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH

3.  安裝eclipse

[1] eclipse的安裝有兩種方法,從Ubuntu軟體中心安裝和手動下載安裝。這裡選擇手動下載安裝,這樣可以將eclipse放在想要的位置。

從http://www.eclipse.org/downloads下載Eclipse IDE For Java Developers,即eclipse-java-indigo-SR2-linux-gtk.tar.gz檔案。至於多

個eclipse的版本,包括Eclipse Classic,Eclipse IDE For Java Developers,Eclipse IDE For Java EE Developers的選擇問題。個人

認為不需要太糾結,應該是都可以,但Android教材上推薦安裝Eclipse IDE For Java Developers,因為它已經整合了幾個Android需要

的外掛程式。

[2] 解壓檔案eclipse-java-indigo-SR2-linux-gtk.tar.gz

     $ tar zxvf eclipse-java-indigo-SR2-linux-gtk.tar.gz

[3] 將解壓後得到的檔案夾移動到期望位置即可

[4] 建立eclipse的捷徑

     $ sudo gedit /usr/share/applications

     $ sudo gedit eclipse.desktop

     在eclipse.desktop中添加以下內容:

     [Desktop Entry] 

     Encoding=UTF-8 

     Name=Eclipse Platfrom 

     Comment=Eclipse IDE 

     Exec=your_eclipse_dir/eclipse 

     Icon=your_eclipse_dir/icon.xpm 

     Terminal=false 

     StartupNotify=true 

     Type=Application 

     Categories=Application;Development;  

     給檔案賦予許可權

     $ sudo chmod u+x eclipse.desktop

     注意去掉每一行前後的空格。這樣,eclipse的捷徑便出現在系統的菜單中。

4. 安裝Android SDK

    不得不說Android環境的搭建過程還是很繁,主要因為線上安裝在國內基本不現實,而採用離線安裝則要分別下載多個組件,還要注意版本對應問題。這裡採用的原   則為,能離線安裝的組件就不要線上安裝。經過昨天的摸索,Android環境需要的組件主要有:Android SDK,SDK tools,Platforms,Platform tools,ADT

[1]首先安裝Android SDK,可以從http://developer.android.com/sdk/index.html下載到。這裡下載android-sdk_r16-linux.tgz

[2]解壓android-sdk_r16-linux.tgz

$ tar zxvf android-sdk_r16-linux.tgz

[3]將解壓得到的檔案夾放在想要的位置即可

5.安裝SDK tools

目前的版本中,SDK tools已經包含在Android SDK中,其位置為your_android_sdk_dir/tools

6.離線安裝Platforms,Platform tools,ADT

這三個組件的安裝是最浪費時間的也是最麻煩的,正統的線上安裝方式是使用SDK tools裡的SDK Manager來下載安裝,但在天朝,此路不通。離線安裝方法如下:

[1]首先注意版本問題,目前發現SDK tools版本和ADT版本是必須要一樣的。因為下載的Android SDK版本是最新的16,它裡邊包含的SDK tools版本也就是16。因此ADT版本也就必須下載16。其實除了Platforms,其他組件均下載最新的是最保險的。要想查看各組件的最新版本,這時候SDK Manager倒是起作用了,運行之後可以看到Platform tools和ADT的最新版本。運行SDK Manager的方法:

$ cd your_android_sdk_dir/tools

$ ./android

這裡觀察到最新的Platform tools版本是10,ADT版本是16。OK,下面就是離線下載這些包。

[2]上述組件的為:

Android SDK Tools, revision 10 http://dl-ssl.google.com/android/repository/tools_r10-windows.zip
Android SDK Platform-tools, revision 3 http://dl-ssl.google.com/android/repository/platform-tools_r03-windows.zip
Android SDK Docs for Android API 11, revision 1 http://dl-ssl.google.com/android/repository/docs-3.0_r01-linux.zip
Android SDK Platform 3.0, revision 1 http://dl-ssl.google.com/android/repository/android-3.0_r01-linux.zip
Android SDK Platform 2.3.3._r1 Revision 1 http://dl-ssl.google.com/android/repository/android-2.3.3_r01-linux.zip
Android SDK Platform 2.3.1_r2 Revision 2 (Obsolete) http://dl-ssl.google.com/android/repository/android-2.3.1_r02-linux.zip
Android SDK Platform 2.2_r1 Revision 2 http://dl-ssl.google.com/android/repository/android-2.2_r02-windows.zip
Android SDK Platform 2.1_r2 Revision 2 http://dl-ssl.google.com/android/repository/android-2.1_r02-windows.zip
Android SDK Platform 1.6_r2 Revision 3 http://dl-ssl.google.com/android/repository/android-1.6_r03-windows.zip
Android SDK Platform 1.5_r3 Revision 4 http://dl-ssl.google.com/android/repository/android-1.5_r04-windows.zip
Android SDK Samples for Android API 11, revision 1 http://dl-ssl.google.com/android/repository/samples-3.0_r01-linux.zip
Android SDK Samples for Android API 10, revision 1 http://dl-ssl.google.com/android/repository/samples-2.3.3_r01-linux.zip
Android SDK Samples for Android API 9, revision 1 http://dl-ssl.google.com/android/repository/samples-2.3_r01-linux.zip
Android SDK Samples for Android API 8, revision 1 http://dl-ssl.google.com/android/repository/samples-2.2_r01-linux.zip
Android SDK Samples for Android API 7, revision 1 http://dl-ssl.google.com/android/repository/samples-2.1_r01-linux.zip
Android + Google APIs, API 11, revision 1 http://dl-ssl.google.com/android/repository/google_apis-11_r01.zip
Android + Google APIs, API 10, revision 1 http://dl-ssl.google.com/android/repository/google_apis-10_r01.zip
Android + Google APIs, API 9, revision 2 http://dl-ssl.google.com/android/repository/google_apis-9_r02.zip
Android + Google APIs, API 8, revision 2 http://dl-ssl.google.com/android/repository/google_apis-8_r02.zip
Android + Google APIs, API 7, revision 1 http://dl-ssl.google.com/android/repository/google_apis-7_r01.zip
Android + Google APIs, API 4, revision 2 http://dl-ssl.google.com/android/repository/google_apis-4_r02.zip
Android + Google APIs, API 3, revision 3 http://dl-ssl.google.com/android/repository/google_apis-3-r03.zip
Google USB Driver package, revision 4 https://dl-ssl.google.com/android/repository/usb_driver_r04-windows.zip

這裡的地址只是作為參考,而且此處必須下載的只是Platforms和Platform tools,其他的視需要下載。下載時只要將版本改為你想要的數字,Linux下將windows改為linux即可。而ADT為:http://developer.android.com/sdk/eclipse-adt.html#downloading,檔案名稱為ADT 16.0.1.zip(不區分作業系統)。

[3]將Platform tools解壓後放到先前的SDK目錄下,與tools檔案夾平行。

[4]將Platforms,這裡下載了2.2版本,解壓後放到SDK目錄下的platforms檔案夾內。

[5]運行eclipse,離線安裝ADT。eclipse->Help->Install New Software->Add->Archive,找到ADT 16.0.1.zip,OK即可。此處即便是這種離線安裝,仍然需要較長時間,可能在安裝過程裡還是包括了自動到官網下載一些檔案。

[6]配置

eclipse->Window->Preferences->Android,選擇Android SDK所在路徑,OK

相關文章

聯繫我們

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