Click here to Skip to main content
15,886,075 members
Articles / Mobile Apps / Android
Tip/Trick

Gearing Up for Android Studio 2.0

Rate me:
Please Sign up or sign in to vote.
4.95/5 (6 votes)
17 Jan 2016CPOL5 min read 17K   8   5
Prepare your Android dev environment for the next awesome release. Android Studio 2.0 preview.

Introduction

Android Studio has been the IDE for Android development for quite some time. It has travelled a long way since the early beta release of Android Studio. This tip explains some of the new features introduced in 2.0 release and how to setup your dev environment. If you are still using Eclipse, this might be the right time to switch to Android Studio.

Background

A little recap about Android Studio if you don't already know it.

  • Google's IDE for Android development
  • Built in support for Google's cloud platform (create GAE backend in the same IDE)
  • Flexible Gradle based build system
  • It is built on top of Latest IntelliJ platform
  • Multi-screen app development
  • Latest stable version available is 1.5.1 (DEC-2015)
  • Available for free on Android developer site (https://developer.android.com/sdk/index.html)

Where To Get It

Android Studio 2.0 preview is available on canary channel and stable build channel for download.

You can update your current IDE to 2.0 preview (currently preview 5), but it is not recommended. Instead, you should keep two separate copies of IDEs.

IDE Setup for Automatic Updates

This step is optional but set it so you get any new updates pushed by Google.

Change the updates dialogue in your IDE settings to get studio updates from canary channel and sdk tools update from preview channel. (Click on help-> Check for updates. In the dialogue that opens, click on updates hyperlink).

And you are done setting your Android Studio 2.0 preview.

What's New in Android Studio 2.0 Preview?

Now that you have your latest Android dev environment setup, it might be a good time to import a sample app and explore the features. Here is almost everything you need to know about the new preview:

The new changes can be categorised into three categories:

  • Build system
  • IDE enhancements
  • Android emulators

Build System

  • Improved dx merger (Build tools 23.0.2+, Gradle plugin 2.0+)
    • Pre-dexes dependencies
    • resulting in gradle build being 2.0-2.5 times faster
    • One of my apps that has 20k+ lines of code used to take 2 min 53 sec to build, now it takes only 23 seconds. So in my case, it is more than 6 times faster.
  • New experimental shrinker for debug mode
    • We all use proguard for release. It is awesome. It shrinks, optimizes and obfuscates the code. But we never get its benefit for debug mode. With the new experimental shrinker, we can get the shrinking benefit right in debug mode.
    • To enable it, just set minifyEnabled to true and useProguard to false in debug build type.
    • overall build deploy cycle is ~1.5 times faster (Not great but still cool)
  • New protocol for ADB push / pull
    • huge speed improvement in adb push n pull
  • Instant Run (My personal favourite, requires Gradle 2.0-alpha5+ and gradlew 2.10)
    • It is the process of deploying code changes on the fly without having to build the whole app.
    • You can see your changes in a matter of seconds in an emulator or a connected device.
    • Instant run is available in almost all
      • Android versions (4.0+)
      • physical devices
      • emulators (2.0+ of course)
    • Hot swap (supported in 2.0 preview 2+)
      • Swap code changes on the fly
    • Cold swap (supported in 2.0 preview 5+)
      • Deploy deltas for code changes that cannot be hot swapped.
      • Not tested this, but according to release notes, it is supported
    • Freeze swap (supported in 2.0 preview 5)
      • Build changes incrementally even if the app is not running on device or emulator.
      • Not tested this, but according to release notes, it is supported.

IDE Enhancements

  • Latest IntelliJ 15 support (15.0.2)
    • built on top of IntelliJ 15.0.2 (released sometime in NOV 2015)
  • New GPU profiler (experimental preview)
    • It is available in studio 1.5.1 as well, but with 2.0 preview you can save the entire graphic stream and play it frame by frame in emulator and device to figure out why your Open GL app crashed or ANR.
    • This is also in experimental state, but still very powerful tool for open GL.
  • In built support for Google search deep linking
    • Deeplinks means how your app comes up in devices’ Google search when your app is installed and when not installed.
    • Deeplinks have been present for a long time now. With studio 2.0, you get one click support for creating deep links.
    • Just open manifest file and click on that yellow bulb icon on the left of the editor.
  • Lot of UI improvements
    • Download it to see the UI improvements

Android Emulators

  • I know, a lot of us prefer real devices for testing over laggy emulators. But I believe with emulators 2.0, you would prefer emulators over the actual device.
  • Completely new UI with extended controls
    • Control almost every feature of emulated device
  • Drag and drop apks and files to install and copy
  • Send sms, receive calls
  • System keyboard support
    • Directly type in from system keyboard
  • Finger printing support
    • If you don’t have Nexus 5X or 6P, you can test finger printing API using emulators 2.0. It features a set of 10 fake finger prints to test the API.
  • Resize emulators
  • Emulate GPS locations via kml and gpx files

The mentioned points cover some of the new features introduced in Android studio 2.0 preview. One important part that I left out here is the testing support. There is a new way to test various product flavours. I still don’t know much about it, I think it is called hermetic testing. You can test instrumentation and Android test simultaneously.

Happy coding!!!

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
India India
Just another software developer trying to connect the dots.

Comments and Discussions

 
QuestionC++ debugging Pin
BadJerry21-Jan-16 1:23
BadJerry21-Jan-16 1:23 
AnswerRe: C++ debugging Pin
Kaushal Dhruw21-Jan-16 14:34
Kaushal Dhruw21-Jan-16 14:34 
GeneralRe: C++ debugging Pin
BadJerry22-Jan-16 2:30
BadJerry22-Jan-16 2:30 
GeneralDetails Pin
Kaushal Dhruw17-Jan-16 19:12
Kaushal Dhruw17-Jan-16 19:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.