Trying out Android Studio

logo.gif

Note: this post assumes you have an existing knowledge of Android development, probably using Eclipse. 

The first time you download Android Studio, before you head straight into creating or importing your first project, start by checking for updates. In my case I downloaded Android Studio 0.2.0 from the developer site, but 0.2.6 was available. Definitely update to the latest version!

One of the big fundamental differences between Android Studio and Eclipse + ADT is that you will now be using Gradle for your build system rather than Ant. I'm no expert on build systems, but I do appreciate good build tools (like Rake) and hopefully Gradle. I've only done 20 minutes worth of Googling Ant vs Gradle, so feel free to do the same. Or, if you want just think of Gradle as a more flexible version of Ant with superior certificate signing and command line build tools. Also, its integration with Jenkins is solid, if CI is your sort thing.

configuration.png

With Android Studio updated and a little knowledge of Gradle under your belt, create a new Android project. (The new project wizard is so straight forward my mom could do it.) You'll notice that the project structure is mostly familiar in terms of java packages containing your source code and your res folder containing layout files and image assets. Good, right? One major difference, however, is that you no longer live within a workspace. Each Android Studio instance now belongs to its own project. I haven't gotten used to the multiple projects with dependencies workflow yet, but I trust it will be eons more logical than it is in Eclipse. Okay. now for another new feature look at the top bar towards your configurations (upper right). This is something new. Here you can setup build configurations with specific application/target combinations. It's an easy way to switch between multiple emulators and devices.

Couple other things to point out in Android Studio. The undo functionality is really smart. In addition to all the things you would expect, it can undo file deletions, creations, and its memory is very impressive. Another small thing that makes you happy is that Android Studio will replace @string/label references with the actual string in manifest and layout files. Hover over it to see the code and click to access it. Another cool thing in layout files is that missing files or resources will show up as red! This is huge! For me anyway I would run the my app on the device and only then find out that I had typed in the image name incorrectly. This has the potential to be a major timesaver.

Keyboard shortcuts rock. Far and away my favorite shortcut in Eclipse is cmd+D (or ctrl+D) to delete line. I miss it every day in Xcode. Here are a few tips and tricks I've discovered so far:

  • cmd+backspace - delete line (a little different, but I could get used to it)
  • cmd+d - duplicate line
  • cmd+o - quickly jump to any class in the project
  • cmd++ - fold code
  • cmd+- - expand code
  • ctrl+spacebar - code completion
  • ctrl+r - build and run (using last selected configuration)
keyboardshortcuts.png

It's not all peaches and cream though. Even with just a few hours under my belt, there are already a couple things that slowed me down which I'd like to see improved:

  • When adding a new activity, double click does not move to the next screen (currently you must to click next)
  • Also in the new activity wizard, changing the activity name does not automatically update the layout name (even eclipse did this!)
  • Creating a new activity defaults to a vanilla package (rather than the currently selected package)
  • Double clicking a "error: gradle: no resource found that matches [filename]" doesn't link to the place where the invalid resource is being referenced
  • The Android emulator hasn't changed a bit

Android Studio is still not a perfect solution, but neither is Eclipse. Overall it feels like a solid start and if its progression is anything like the progression of Android (oh boy the dark days of Froyo), it's only going to improve significantly over the next couple years.