How to Use SDK Tools for Everyday Development
The SDK tools are the building blocks you use in developing Android apps. New features packed into every release enable you to develop for the latest version of Android.
Saying hello to the emulator
Google provides not only the tools you need to develop apps but also an awesome little emulator to test your app. The emulator has some limitations (for example, it cannot emulate certain hardware components, such as the accelerometer) but not to worry — plenty of apps can be developed and tested using only an emulator.
When you’re developing an app that uses Bluetooth, for example, you should use a physical device that has Bluetooth on it. If you develop on a speedy computer, testing on an emulator is fast; on slower machines, however, the emulator can take a long time to complete a seemingly simple task. If you’re developing on an older machine, use a physical device. When you’re developing on a newer, faster machine, use the emulator.
The emulator is handy for testing apps at different screen sizes and resolutions. It isn’t always practical or possible to have several devices connected to your computer at the same time, but you can run multiple emulators with varying screen sizes and resolutions.
Getting physical with a real Android device [Windows]
If you develop on a Windows machine and you want to test your app on a real-life device, you need to install a driver. If you’re on a Mac or Linux machine, you don’t need to install the USB driver.
When you downloaded the SDK, you also downloaded the USB driver that you need. To install it, do the following:
Plug in your device.
Choose Control Panel→Device Manager.
Expand Other Devices, right-click your device, and select Update Driver Software.
Select Browse my computer for driver software.
Type C:Users<user>AppDataLocalAndroidandroid-studiosdkextrasgoogleusb_driver (replacing <user> with your username), and click Next.
If you can’t find the AppData directory on your computer, it’s because it’s hidden by default. What you can do is type %appdata% in the location field and then click Browse. That unhides the directory and allows you to navigate the rest of the way there.
When asked if you would like to install this device, click Install.
Debugging your work
The Android Device Monitor equips you with the necessary tools to find those pesky bugs, allowing you to go behind the scenes as your app is running to see the state of its hardware, such as the wireless radio. But wait — there’s more!
The Device Monitor also simulates actions normally reserved for physical devices, such as sending global positioning system (GPS) coordinates manually, simulating phone calls, or simulating text messages.
Trying out the API and SDK samples
The API and SDK samples are provided to demonstrate how to use the functionality provided by the API and SDK. If you’re ever stuck and can’t figure out how to make something work, visit Android’s website to find samples of almost anything, from using Bluetooth to making a two-way text application or a 2D game.
You also have a few samples in your Android SDK. Simply open the Android SDK and navigate to the samples directory, which contains various samples that range from interacting with services to manipulating local databases. Spend some time playing with the samples — the best way to learn to develop Android applications is to look at existing working code bases and then experiment with them in Android Studio.
Giving the API demos a spin
The API demos inside the samples folder in the SDK are a collection of apps that demonstrate how to use the included APIs. You can find sample apps with a ton of examples, such as