When you write Android applications, you typically write them in Java source code.
That Java source code is then turned into the stuff that Android actually runs (Dalvik bytecode in an APK file).
Hence, the first thing you need to do is get set up with a Java development
environment and be ready to start writing Java classes.
Step #1: Install the JDK
You need to obtain and install the official Sun/Oracle Java SE SDK (JDK).
Step #2: Learn Java
You should consider spending a bit of time on Java fundamentals, before you dive into Android. Otherwise, you may find the experience to be frustrating.
The Java concepts that you would require in android are :
- Language fundamentals
- Classes and objects
- Methods and data members
- Public, private, and protected
- Static and instance scope
- Exceptions
- Threads and concurrency control
- Collections
- Generics
- File I/O
- Reflection
- Interfaces
Install the Android SDK
The Android SDK gives you all the tools you need to create and test
Android applications.
The two parts of SDK are:
- the base tools
- version specific SDKs and related add-ons.
The Android developer tools can be found on the Android Developers Web
site (http://developer.android.com/sdk/index.html).
Download the ZIP file appropriate for your platform and unZIP it in some likely spot – there is no specific path that is required.
Step #2: Install the SDKs and Add-Ons
Inside the tools/ directory of your Android SDK installation from the previous step, you will see an android batch file or shell script.
If you run that, you will be presented with the Android SDK and AVD Manager.
At this point, while you have some of the build tools, you lack the Java files necessary to compile an Android application.
You also lack a few additional build tools, plus the files necessary to run an Android emulator.
To address this, click on the Available Packages option on the left. This brings up a tree. Open the Android Repository branch of the tree.
You will check the following items:
- "SDK Platform" for all Android SDK releases you want to test against
- "Documentation for Android SDK" for the latest Android SDK release
- "Samples for SDK" for the latest Android SDK release, and perhaps for older releases if you wish
Most likely, you will want to check the "Google APIs by Google Inc." items that match up with the SDK versions you selected in the Android Repository branch. The "Google APIs" include support for Google Maps, both from your code and in the Android emulator. When you have checked all of the items you want to download, click the Install Selected button, which brings up a license confirmation dialog box.
Review and accept all the licenses, then click the Install button. Downloading all of this data and unpacking it will take a fair bit of time.
Install the ADT for Eclipse
If you will not be using Eclipse for your Android development, you can skip to the next section.
If you have not yet installed Eclipse, you will need to do that first. Eclipse can be downloaded from the Eclipse Web site. The "Eclipse IDE for Java Developers" package will work fine.
Next, you need to install the Android Developer Tools (ADT) plug-in. To do this, go to Help -> Install New Software in the Eclipse main menu. Then, click the Add button to add a new source of plug-ins. Give it some name (e.g., Android) and supply the following URL: https://dlssl.
google.com/android/eclipse/. That should trigger Eclipse to download the roster of plug-ins available from that site.
Check the checkbox to the left of "Developer Tools" and click the Next button. Follow the rest of the wizard to review the tools to be downloaded and their respective license agreements. When the Finish button is enabled, click it, and Eclipse will download and install the plug-ins. When done, Eclipse will ask to restart – please let it. Then, you need to teach ADT where your Android SDK installation is from the preceding section. To do this, choose Window -> Preferences from the Eclipse main menu. Click on the Android entry in the list on the left.
Then, click the Browse button to find the directory where you installed the SDK. After choosing it, click Apply on the Preferences window, and you should see the Android SDK versions you installed previously. Then, click OK, and the ADT will be ready for use.
Set Up the Emulator
The Android tools include an emulator, a piece of software that pretends to be an Android device. This is very useful for development – not only does it mean you can get started on Android without a device, but the emulator can help test device configurations that you do not own. The Android emulator can emulate one or several Android devices. Each configuration you want is stored in an "Android Virtual Device". The SDK and AVD Manager, which you used to download the SDK components earlier is where you create these AVDs. If you do not have the SDK and AVD Manager running, you can run it via the android command from your SDK's tools -> directory or via Window -> SDK and AVD Manager from Eclipse. It starts up on a screen listing the AVDs you have available. Initially, the list will be empty.
Click the New button to create a new AVD file. This brings up a dialog where you can configure what this AVD should look and work like.
You need to provide the following:
- A name for the AVD.
- The Android version you want the emulator to run.
- Details about the SD card the emulator should emulate.
- The "skin" or resolution the emulator should run in.
No comments:
Post a Comment