1. 程式人生 > >為Eclipse安裝安卓開發外掛ADT

為Eclipse安裝安卓開發外掛ADT

Android offers a custom plugin for the Eclipse IDE, called AndroidDevelopment Tools (ADT). This plugin is designed to give you a powerful, integratedenvironment in which to develop Android apps. It extends the capabilitiesof Eclipse to let you quickly set up new Android projects, build an appUI, debug your app, and export signed (or unsigned) app packages (APKs) for distribution.

If you will be developing in Eclipse with the ADT Plugin, first make sure that you have asuitable version of Eclipseinstalled on your computer as described by thesystem requirements.

If you need to install Eclipse, you can download it from http://www.eclipse.org/downloads/.We recommend the "Eclipse Classic" version. Otherwise, you should use a Java orRCP version of Eclipse.

Note: If you prefer to work in a different IDE, you do not need toinstall Eclipse or ADT. Instead, you can directly use the SDK tools to build anddebug your application. So if you're not using Eclipse, continue to the next page by clickingthe Next link on the right.

Download the ADT Plugin    //下載ADT外掛
,你可以讓Eclipse幫你下載ADT,也可以自己下載ADT外掛

//以下這種安裝ADT外掛的方式就是讓Eclipse幫你下載ADT,然後安裝ADT,網上 有很多介紹ADT的安裝方法,用的就是

//這種方法,剛開始我裝ADT時用的也是這種方法,不過我安裝失敗了,如果網路不好的話,建議不要用這種方法,

//我比較推薦使用第二種安裝方法,即先用迅雷下載ADT外掛,然後再用Eclipse安裝,該方法請見文章的後半部分。

  1. Start Eclipse, then select Help > Install NewSoftware.  
  2. //啟動Eclipse,在選單欄選擇Help-->在彈出來的選單中選擇Install NewSoftWare
  3. Click Add, in the top-right corner.
  4. In the Add Repository dialog that appears, enter "ADT Plugin" for the Name and thefollowing URL for theLocation:
    https://dl-ssl.google.com/android/eclipse/
  5. //在Add Repository對話方塊中,在Name欄輸入 ADT Plugin,在Location欄輸入網址:
    //https://dl-ssl.google.com/android/eclipse/
  6. Click OK.

    If you have trouble acquiring the plugin, try using "http" in the Location URL,instead of "https" (https is preferred for security reasons).

  7. //點OK後,如果你在安裝ADT外掛時遇到錯誤,請將以上網址中的https該為http
  8. In the Available Software dialog, select the checkbox next to Developer Tools and clickNext.
  9. //在可用軟體的對話方塊中,選擇Developer Tools前的複選框,然後點下一步
  10. In the next window, you'll see a list of the tools to be downloaded. ClickNext.
  11. //在接下來的視窗中,你會看到將要下載的所有工具的列表,然後點下一步
  12. Read and accept the license agreements, then click Finish.

    If you get a security warning saying that the authenticity or validity ofthe software can't be established, clickOK.

  13. //閱讀和接受許可協議,然後點Finish,如果彈出安全警告,點OK即可
  14. When the installation completes, restart Eclipse.
  15. //安裝完成時,重啟Eclipse

Configure the ADT Plugin

Once Eclipse restarts, you must specify the location of your Android SDK directory:

  1. In the "Welcome to Android Development" window that appears, select Useexisting SDKs.
  2. Browse and select the location of the Android SDK directory you recentlydownloaded.
  3. Click Next.

If you haven't encountered any errors, you're done setting up ADT and can continue toNext Steps.

Updating the ADT Plugin

From time to time, a new revision of the ADT Plugin becomes available, withnew features and bug fixes. Generally, when a new revision of ADT is available,you should update to it as soon as convenient.

In some cases, a new revision of ADT will have a dependency on a specificrevision of the Android SDK Tools. If such dependencies exist, you will need toupdate the SDK Tools package of the SDK after installing the new revision ofADT. To update the SDK Tools package, use the Android SDK Manager, asdescribed in Exploring the SDK.

To learn about new features of each ADT revision and also any dependencies onthe SDK Tools, see the listings in theRevisionssection. To determine the version currently installed, open theEclipse Installed Software window usingHelp> Software Updates and refer to the version listed for"Android Development Tools".

Follow the steps below to check whether an update is available and, if so,to install it.

  1. Select Help > Check for Updates.

    If there are no updates available, a dialog will say so and you're done.

  2. If there are updates available, select Android DDMS, Android Development Tools, and Android Hierarchy Viewer, then clickNext.
  3. In the Update Details dialog, click Next.
  4. Read and accept the license agreement and then click Finish. This will download and install the latest version of Android DDMS and Android Development Tools.
  5. Restart Eclipse.

If you encounter problems during the update, remove the existing ADT plugin from Eclipse, thenperform a fresh installation, using the instructions forInstalling the ADTPlugin.

Troubleshooting

If you are having trouble downloading the ADT plugin after following thesteps above, here are some suggestions:

  • If Eclipse can not find the remote update site containing the ADT plugin,try changing the remote site URL to use http, rather than https. That is, setthe Location for the remote site to:
    http://dl-ssl.google.com/android/eclipse/
  • If you are behind a firewall (such as a corporate firewall), make sure thatyou have properly configured your proxy settings in Eclipse. In Eclipse,you can configure proxy information from the main Eclipse menu inWindow (on Mac OS X,Eclipse) >Preferences > General >NetworkConnections.

//當用以上那種方式安裝不了ADT時,我們可以用下面這種方式,

//我就是根據下面這種方式自己下載ADT,然後安裝成功的

If you are still unable to use Eclipse to download the ADT plugin as aremote update site, you can download the ADT zip file to your local machine andmanually install it:

  1. Download the ADT Plugin zip file (do not unpack it): //這是官方給出的ADT下載地址,需要的朋友上其官方檢視即可
    PackageSizeMD5 Checksum
    12390954 bytes869a536b1c56d0cd920ed9ae259ae619
  2. Start Eclipse, then select Help > Install NewSoftware. //安裝方法跟上面的大同小異,不再敖述
  3. Click Add, in the top-right corner.
  4. In the Add Repository dialog, click Archive.
  5. Select the downloaded ADT-20.0.3.zip file and click OK.
  6. Enter "ADT Plugin" for the name and click OK.
  7. In the Available Software dialog, select the checkbox next to Developer Tools and clickNext.
  8. In the next window, you'll see a list of the tools to be downloaded. ClickNext.
  9. Read and accept the license agreements, then click Finish.

    If you get a security warning saying that the authenticity or validity ofthe software can't be established, clickOK.

  10. When the installation completes, restart Eclipse.

To update your plugin once you've installed using the zip file, you will haveto follow these steps again instead of the default update instructions.

Other install errors

Note that there are features of ADT that require some optionalEclipse packages (for example, WST). If you encounter an error wheninstalling ADT, your Eclipse installion might not include these packages.For information about how to quickly add the necessary packages to yourEclipse installation, see the troubleshooting topicADTInstallation Error: "requires plug-in org.eclipse.wst.sse.ui".

For Linux users

If you encounter this error when installing the ADT Plugin for Eclipse:

An error occurred during provisioning.Cannot connect to keystore.JKS

...then your development machine lacks a suitable Java VM. Installing SunJava 6 will resolve this issue and you can then reinstall the ADTPlugin.