Installing and Using Android Studio
- 0.1 1. System requirements
- 0.2 2. Requirements for using Linux
- 0.3 3. Download Android Studio
- 0.4 4. Installation of Android Studio
- 0.5 5. Configuration
- 1 Android SDK Manager
- 2 Using Eclipse for Android development
- 3 Using Android Virtual Devices or real devices for testing
- 3.1 1. Android emulator and Android Virtual Device
- 3.2 Note
- 3.3 2. Debug certificate and expire date
- 3.4 3. Android device emulator shortcuts
- 3.5 4. Google vs. Android AVD
- 3.6 5. Speed optimization with GPU rendering
- 3.7 Note
- 3.8 6. Speed optimization with the Intel system image
- 3.9 Note
- 3.10 Tip
- 3.11 7. Genymotion as alternative emulator
- 3.12 8. Using a real Android device for testing
- 3.13 Note
1. System requirements
Development for Android can be done on a reasonably sized computer. For a nice experience a modern computer is recommended, for example, a 2.6 GHz CPU with at least 8 GB of memory. An SSD speeds up the start of the Android emulator significantly.
2. Requirements for using Linux
The Android SDK is 32-bit, therefore on a 64-bit 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.
On Ubuntu 13.04 you also have to install the OpenGL support. This can be done on Ubuntu 13.04 via following command.
# install OpenGL support sudo apt-get install libgl1-mesa-dev
Please check your distribution documentation if you are using a different flavor of Linux.
3. Download Android Studio
Download Android Studio from the Android Studio website. The download comes in two flavors, SDK Tools only and Android Studio Packages. You want to download the Android Studio Package for your operation system.
4. Installation of Android Studio
Installation for Windows is simple, just lauch the .exe you downloaded. On Max OSX drag and drop Android Studio into the Applications folder.
On Linux unpack the downloaded ZIP file into an appropriate location for your applications. To launch Android Studio, navigate to the android-studio/bin/ directory in a terminal and execute studio.sh.
The first time you start Android Studio you can select if you want to import your setting from an existing installation.
Afterwards click through the setup guide.
Once you reach the last page, press the Finish button.
Android SDK Manager
1. Using the Android SDK manager
The Android SDK Manager allows you to install specific versions of the Android API.
The Android SDK Manager allows you to install and delete Android packages.
2. Open the Android SDK manager in Android Studio
Select SDK Manager icon in the toolbar of Android Studio to open the Android SDK manager.→ → or the
3. Install selected Android version or library
In the Android SDK manager select the version of Android you would like to develop for from the tree and press the API 18 version of Android.button. The following screenshot shows the selection for the
Press thebutton to start he installation.After the installation is completed the select option is available.
The SDK Platforms tab is used to install API versions, which the SDK Tools is used to install the development tools.
4. Install support library
The support library allows you to use functionality provided by higher Android releases in lower Android versions.
In the Android SDK Manager select Extras and install the Android Support Repository. The Android Support Library is for the usage of the Eclipse ADT tooling.
Android currently has several versions of the library, the v4, v7 and v13 version which are valid as of the respective API level of Android. For example, the support library v7 works as of Android devices with version API 7. Higher versions of the support library require also the lower versions to work. For example, support library v7 requires the v4 library.
Using Eclipse for Android development
The Google development team focus their future development on Android Studio, so this is currently the best development environment for Android applications. At the moment the ADT tooling uses a special Eclipse build system and not the new Gradle build system. This can create inconsistencies in your build. If you want the Gradle support for Eclipse please go toSupport Gradle builds for Eclipse bug report and press the star sign.
The other blocking issue for the usage of Eclipse for future Android development is the missing support for AAR files. Please also vote on Allow Eclipse ADT plugin to work with .AAR files.
Using Android Virtual Devices or real devices for testing
1. Android emulator and Android Virtual Device
The Android tooling contains an Android device emulator. This emulator can be used to run an Android Virtual Device(AVD), which emulates a real Android phone.
AVDs allow you to test your Android applications on different Android versions and configurations without access to the real hardware. Even if you have a real Android device available, you should get familiar with the creation and usage of AVDs. Virtual devices give you the possibility to test your application for selected Android versions and a specific configurations.
During the creation of your AVD you define the configuration for the virtual device. This includes, for example, the resolution, the Android API version and the density of your display.
You can define multiple AVDs with different configurations and start them in parallel. This allows you to test different device configurations at once.
If you stop and AVD during startup process the AVD might get corrupted. The first start may take up to 10 minutes on an older machine. On a modern machine it typically takes 1-3 minutes for a new AVD to start.
After the AVD has started, you can control the GUI with the mouse. The emulator also provides access to the phone buttons via a menu on the right side of the emulator.
Once started, don’t stop the AVD during your development. If you change your application and want to test a new version, you simply re-deploy your application on the AVD.
2. Debug certificate and expire date
Android applications must be signed before they can get installed on an Android device. During development Eclipse signs your application automatically with a self-signed certificate called the debug key.
This debug certificate has an expiration date of 365 days from its creation date. When the certificate expires, you will get a build error that the certificate has been expired.
To fix this problem, delete the
debug.keystore file. The default storage location is in
~/.android/ on OS X and Linux, in
C:\Documents andSettings\[username]\.android\ on Windows XP, and in
C:\Users\[username]]\.android\ on Windows Vista and Windows 7.
The next time you build, the build tools will regenerate a new keystore and debug key.
3. Android device emulator shortcuts
The following table lists useful shortcuts for working with an AVD.
Table 1. Android device emulator shortcuts
|Alt+Enter||Maximizes the emulator.|
|Ctrl+F11||Changes the orientation of the emulator from landscape to portrait and vice versa.|
|F8||Turns the network on and off.|
4. Google vs. Android AVD
During the creation of an AVD you decide if you want to create an Android device or a Google device.
An AVD created for Android contains the programs from the Android Open Source Project. An AVD created for the Google API’s contains additional Google specific code.
AVDs created for the Google API allow you to test applications which use Google Play services, e.g., the new Google maps API or the new location services.
5. Speed optimization with GPU rendering
During the creation of an emulator you can choose if you either want Snapshot or Use Host GPU enabled.
The dialog implies that you can select both options, but if you do, you get an error message that these options can not be selected together.
If you select the Snapshot option, the second time you start the device it is started very fast, because the AVD stores its state if you close it. If you select Use Host GPU the AVD uses the graphics card of your host computer directly which makes the rendering on the emulated device much faster.
6. Speed optimization with the Intel system image
It is possible to run an AVD with an image based on the ARM CPU architecture or based on the Intel CPI architecture.
An Android virtual device which uses the Intel system image is much faster in execution on Intel / AMD hardware compared to the ARM based system image. This is because the emulator does not need to translate the ARM CPU instructions to the Intel / AMD CPU on your computer.
The Intel image for an API can be installed via the Android SDK Manager. In Android Studio this happens automatically if you create an device. If is possible to configure this via the package details.
An Intel image is not available for all API levels.
At the time of this writing your also need to download and install extra drivers for MS windows.
After the download you find the driver in your Android installation directory in the
extras/intel folder. You need to install the drivers by running starting the .exe file. This additional installation step is required on Window to accelerate the Intel emulator. Only downloading the driver via the Android does not make a difference.
After the download you can create a new AVD based on the Intel emulator. The emulator does not start faster but is way faster during the execution of your Android application.
Linux requires a more complex setup. For a detailed installation description see the Intel emulator installation guide which also includes detailed instructions for Windows.
7. Genymotion as alternative emulator
There are alternatives to the default Android emulator available. For example, the Genymotion emulator is relatively fast in startup and execution of Android projects.
8. Using a real Android device for testing
Turn on USB Debugging on your device in the settings. Select → , then enable the USB-Debugging option.
You may also need to install the driver for your mobile phone. Linux and Mac OS usually work out of the box while Windows typically requires the installation of a driver.
For details on the driver installation on Windows please see Google guide for device deployment.
The minimum Android version of your Android application needs to fit to the Android version on your device.
If you have several devices connected to your computer, you can select which one should be used. If only one device is connected, the application is automatically deployed on this device.