This document will prepare an overview of the steps you will take to install and configure Android on your Ubuntu Linux system. You must have Oracle Java JDK or OpenJDK on your system before installing Android SDK. OpenJDK (aka Open Java Development Kit) is a free and open source implementation of the Java programming language Moreover, you will learn how to:
- Prepare your development environment and ensure it meets the system requirements.
- Install the Android Software Development Kit (SDK)
- Configure the Eclipse Integrated Development Environment (IDE)
- Install the Android Development Tool (ADT) Plugin for Eclipse IDE
- Add Android platforms and other components to your SDK
- Create your Android Virtual Device (AVD)
EditSteps
Prepare your Development Environment
- 1Prepare your Ubuntu Linux development environment and ensure it meets the system requirements. First, boot up Ubuntu Linux,make sure you have an implementation of the Java JDK installed on your system, whether it is OpenJDK or Oracle Java JDK, which lays the foundation for the Android SDK. If you don't have the Java JDK installed on your system please install it, you can obtain the Oracle Java JDK from Download the Oracle Java JDK,for more information on how to install Oracle Java on your Ubuntu Linux system, see the following How to Install Oracle Java on Ubuntu Linux or to install the OpenJDK and OpenJRE open up a terminal on your system and run the following command
- Type/Copy/Paste: sudo apt-get install openjdk-7-jdk
- This command installs OpenJDK on your system
- Type/Copy/Paste: sudo apt-get install openjdk-7-jre
- this command installs OpenJDK JRE( Java Runtime Environment ) on your system
- You have choice between installing OpenJDK or installing Oracle Java. I strongly recommend installing Oracle Java because it is usually the most well maintained and up to date version of Java.
- 2If you are running a 64-bit distribution of Android SDK on your development machine, you need to install the ia32-libs:
- Type/Copy/Paste: sudo apt-get install ia32-libs
- This command installs additional libraries needed for development with the Android SDK
- Type/Copy/Paste: javac -version
- this command checks for the Java JDK on your system:
- It should respond back with:
- javac 1.7.0
- or something very similiar
- It should respond back with:
- Type/Copy/Paste: java -version
- this command checks for the Java JRE ( Java Runtine Environment ) on your system
Configure Eclipse Integrated Development Environment (IDE)
- 1You want to make sure you have the Eclipse Integrated Development Environment (IDE) installed on your system,for example select Eclipse Classic, and download the version for your system architecture such as 32bit or 64 bit version for Linux. If your computer system has 4GB or more of memory most likely it is a 64 bit computer. The Eclipse IDE will download into your /home/"your_user_name"/Downloads
- 2This is an example of an Eclipse IDE setup on Ubuntu Linux
- Type/Copy/Paste: cd /home/"your_user_name"/Downloads
- this will change you in your Downloads directory
- Type/Copy/Paste: sudo -s cp -r eclipse-SDK-3.7-linux-gtk-x86_64.tar.gz /usr/local
- Type/Copy/Paste: cd /usr/local
- this will change you into the eclipse directory
- Type/Copy/Paste: sudo -s chmod a+x eclipse-SDK-3.7-linux-gtk-x86_64.tar.gz
- this command makes the eclipse binaries executable for all on the system
- Type/Copy/Paste: sudo -s tar xvzf eclipse-SDK-3.7-linux-gtk-x86_64.tar.gz
- this unpacks your Eclipse IDE compressed binaries
- Type/Copy/Paste: exit
- this command takes you out of root user
- Type/Copy/Paste: cd /home/"your_user_name"/Desktop
- this will change you into your user Desktop, make sure you are not root
- Type/Copy/Paste: ln -s /usr/local/eclipse/eclipse
- Important, make sure you are not root when you create this symbolic link from your Eclipse IDE /usr/local/eclipse directory to your Desktop /home/"your_user_name"/Desktop
Download, Install and Configure the Android SDK
- 1Download the Android SDK, click on the Linux tarball, android-sdk_r20.0.3-linux.tgz and save it to your /home/"your_user_directory"/Downloads directory, open up a terminal and run the following commands:
- Type/Copy/Paste: cd /home/"your_user_name"/Downloads
- this will change you into your Downloads directory
- Type/Copy/Paste: sudo -s cp -r android-sdk_r20.0.3-linux.tgz /opt
- this will copy the android sdk to /opt
- Type/Copy/Paste: cd /opt
- this will change you into the Android working directory
- Type/Copy/Paste: sudo -s tar xvzf android-sdk_r20.0.3-linux.tgz
- this will unpack your Android SDK
- Type/Copy/Paste: sudo -s chmod -R 755 /opt/android-sdk-linux
- this will make the /opt directory and the Android SDK writable and executable for all users on the system.
- 2When these steps are complete you will have Android SDK located at:/opt/android-sdk-linux on your Ubuntu Linux system.
- 3Also, open up a terminal and add Android SDK to your system wide PATH on Ubuntu Linux
- Type/Copy/Paste: sudo -s nano /etc/profile
- or
- Type/Copy/Paste: sudo -s gedit /etc/profile
- Add the following lines below to the end of the system PATH file
- export PATH=${PATH}:/opt/android-sdk-linux/tools
- export PATH=${PATH}:/opt/android-sdk-linux/platform-tools
- 4Save the /etc/profile file and exit
- 5Reload your system PATH /etc/profile by issuing the following command
- Type/Copy/Paste: . /etc/profile
- this informs the Linux system of the location of the Android SDK development tools
- Type/Copy/Paste: . /etc/profile
Install the Android Development Tool (ADT) Plugin for Eclipse IDE
- 1Install the ADT Plugin for Eclipse, the ADT is a plugin for the Eclipse IDE. Before you can install or use ADT, you must have a compatible version of Eclipse installed on your development computer. Start Eclipse, then select Help > Install New Software. Click Add, in the top-right corner. In the Add Repository dialog that appears, enter "ADT Plugin" for the Name and the following URL for the Location
- 2Type/Copy/Paste: https://dl-ssl.google.com/android/eclipse/
- Click OK
- Note: If you have trouble acquiring the plugin, try using "http" in the Location URL, instead of "https" (https is preferred for security reasons)
- 3In the Available Software dialog, select the checkbox next to Developer Tools and click Next. In the next window, you'll see a list of the tools to be downloaded and Click Next. Read and accept the license agreements, then click Finish.
- Note: If you get a security warning saying that the authenticity or validity of the software can't be established, click OK.
- 4When the installation completes, restart Eclipse. Configuring the ADT Plugin, after you've successfully downloaded the ADT as described above, the next step is to modify your ADT preferences in Eclipse to point to the Android SDK directory:
- Select Window > Preferences... to open the Preferences panel
- Select Android from the left panel. You may see a dialog asking whether you want to send usage statistics to Google. If so, make your choice and click Proceed. You cannot continue with this procedure until you click Proceed.
- Select Window > Preferences... to open the Preferences panel
- 5For the SDK Location in the main panel, click Browse... and locate your downloaded SDK directory, which should be /opt/android-sdk-linux
- Click Apply, then OK.
Add Android platforms and other components to your SDK
- 1Adding Platforms and Other Component,in setting up your SDK is using the Android SDK and AVD Manager (a tool included in the SDK starter package) to download essential SDK components into your development environment. The SDK starter package, which you've already downloaded, includes only a single component: the latest version of the SDK Tools. To develop an Android application, you also need to download at least one Android platform and the associated platform tools. You can add other components and platforms as well, which is highly recommended.
- 2Open Eclipse and click Window->Android SDK and AVD Manager->Installed packages and click update all. Simply click Install to accept the recommended set of components and install them
- 3On Linux, open a terminal and navigate to the /opt/android-sdk-linux/tools directory in the Android SDK.
- Type/Copy/Paste: sudo -s
- Type/Copy/Paste: cd /opt/android-sdk-linux/tools
- this will change you into the android sdk tools directory
- Type/Copy/Paste: ./android
- this command will run the Android graphical user interface, in most cases you will have to be root user in order for the Android SDK to download updated components to the opt/android-sdk-linux directory.To download components, use the graphical UI of the Android SDK and AVD Manager to browse the SDK repository and select new or updated components. The Android SDK and AVD Manager installs the selected components in your SDK environment.
Create your Android Virtual Device (AVD)
- 1Once all the components for Android have been updated you will need to create an Android Virtual Device.
- Click on Window->Android SDK and AVD Manager->Virtual Devices in order to create a Android Virtual Device ( emulator ).
- Click New, scroll down to the box that says name and assign an Android Virtual Device name such as: My_AVD
- Next click on the box that says target and use the arrow button and scroll down and select appropriate Android version you want to develop with such as, Android 3.2-API Level 13.
- Next scroll down to the box that says Skin and Click on Resolution, enter the numbers 420x580 and select Create AVD, this will create your Android Virtual Device ( emulator ), for program testing.
- 2Congratulations, you should now have the Android SDK setup to work with Eclipse IDE and you can begin developing Android Applications.
沒有留言:
張貼留言