Trang

Thứ Sáu, 21 tháng 6, 2013

2. Android Installation


1. Installation of the Android development tools
Android provides a standalone customized Eclipse download for Android development or the possibility to update an existing Eclipse installation with additional plug-ins.


This guide describes both approaches.

2. Standalone ADT installation
2.1. Download
Google provides a pre-packaged and configured Eclipse based Android development environment. The following link allows to download a archive file which includes all required tools for Android development.
http://developer.android.com/sdk/index.html 

2.2. Standalone ADT installation
Extract the zip file and start Eclipse from the eclipse folder via the eclipse native launcher, e.g. eclipse.exe under Windows.

3. Installing Android API version and the source code
3.1. Install a specific Android version
The Android SDK Manager allows you to install specific versions of Android. Select Window → Android SDK Manager from the Eclipse menu.


The dialog allows you to install and delete packages.

Select Available packages and open the Third Party Add-ons. Select the latest Google API (highest number) of the SDK and press the Install button. The following screenshot shows the API 16 but if there is a never version available install this version.


Press the Install button and confirm the license for all packages. After the installation completes, restart Eclipse.

3.2. Install support library
In the Android SDK Manager select Extras and install the Android support library.

4. Updating an existing Eclipse installation
4.1. Eclipse
The following assumes that you have already Java and Eclipse installed and know how to use Eclipse.

4.2. Pre-requisites for using a 64bit Linux
The Android SDK is 32bit, therefore on a 64bit Linux system you need to have the package ia32-libs installed. For Ubuntu you can do this via the following command.

apt-get install ia32-libs 

Please check your distribution documentation, if you are using a different flavor of Linux.

4.3. Install ADT Plug-ins and Android SDK
Use the Eclipse update manager via Help → Install new software to install all available components for the Android Development Tools (ADT) from the following URL:

https://dl-ssl.google.com/android/eclipse/ 

After the new Android development components are installed, you will be prompted to install the Android SDK. You can use the following wizard or go to the next section to learn how to do it manually.




4.4. Manual installation of the Android SDK
After the installation of the ADT the Eclipse tooling allows to download the Android SDK automatically. Alternatively you can also manually download the Android SDK from the Android SDK download page.

http://developer.android.com/sdk/index.html 

The download contains a zip file, which you can extract to any place in your file system, e.g. on my Linux system I placed it into the /home/vogella/android-sdks folder. Avoid using spaces in the path name, otherwise you may experience problems with the usage of the Android SDK.

You also have to define the location of the Android SDK in the Eclipse Preferences. In Eclipse open the Preferences dialog via the menu Window → Preferences. Select Android and enter the installation path of the Android SDK.


5. Android installation verification
The best way to verify that your installation did work correctly is to create an Android Virtual device. Please follow the instructions below and make sure that the device actually can start otherwise you will face issues during the training.

6. Tutorial: Create and run Android Virtual Device
6.1. Create AVD
To define an Android Virtual Device (ADV) open the AVD Manager dialog via Window → Android Virtual Device Manager and press the New button.


Enter the values similar to the following screenshot.


Ensure that the Use Host GPU option is selected. This makes the AVD use the graphical processing unit of your computer and this makes rendering on the AVD much faster.

Afterwards press the OK button. This will create the AVD configuration and display it under the list of available virtual devices.

6.2. Run AVD
To test if your setup is correct, select your new entry and press the Start button


After some time your AVD starts. Do not interrupt this startup process, as this might corrupt the AVD.

After the AVD started, you can use the AVD via the mouse and via the virtual keyboard of the emulator.


6.3. Stopping the emulator
During development you don't stop the AVD, you just re-deploy your application.

7. Accessing the Android source code in Eclipse
During Android development it is useful to have access to the Android source code.

You can download the Android source code via the Android SDK Manager by selecting the Sources for Android SDK.


The sources are stored in the path_to_android_sdk/sources/android-xx directory. . xx is the API level of Android, e.g. 17 for the Android 4.2 version.

To connect the sources with the your android.jar file in your Android project, right-click on your android.jar in the Package Explorer view and select Properties → Java Source Attachment. Select External location and press the External Folder button. Browser to the path_to_android_sdk/sources/android-xx location and press the OK button.

Không có nhận xét nào: