Android Studio, new IDE from Google
13 min read
Yesterday, on their I/O 2013 event held at San Francisco, Google reveled brand new IDE for Android Developers. It is significant change in direction made to radically improve and overall simplify process of developing applications for Android platform.
Concerning previous dedication to Eclipse based ADT switching to this new IDE, based on IntelliJ IDE platform is very surprising move. Technically speaking Android Studio is bunch of plugins – extension bundled together with IntelliJ IDEA Community Edition which is JetBrain’s free and open source Java IDE resulting in final product also being open source to broader community of skilled coders and possible maintainers. Guys from JetBrains did great job with IntelliJ which is core for their other fantastic product and following statement might be taken as personal expression (I’m not related to JetBrains in any way) but they set really high standards for IDE quality with it’s surprisingly well speed of execution even though it is Java based which is essentially core problem that Eclipse struggles with and fails to solving it for pretty long period of time without any or at least strong future hopes because of architecture design quirks. Speed surely attracts new developers but there is quite loyal user base Eclipse ADT (plugin) gained since it’s public release. Skilled developers tend to stick to reliable and tested stuff and Early Access Preview probably would not trigger the global shift to new IDE. However this time we are dealing with IDE specialists from JetBrains coupled with skilled and innovative Google guys resulting in feature filled and smart product giving great insight in brighter developer future.
In this section I’ll give quick intro how to setup Android Studio and smoothly get to the working point where creativity should dominant developer’s interaction/battle with IDE and other possible technology layers.
Where to get it?
I saw huge amount of comments on YouTube and Google+ containing only this tiny title question. Seems that googling skills are first and though barrier towards brighter future. Simple search like
google studio site:android.com reveals download site at following uri: http://developer.android.com/sdk/installing/studio.html There is large blue download button that links to setup binary for detected OS (probably guessed from user-agent) and in case targeting some other platform there is drop-down with different options below the main one. Download the setup and proceed to next step.
Setting up JDK
Android Studio requires that JavaSE Development Kit is installed and also
JAVA_HOME must been set and point to JDK home directory. In case JDK is not previously installed You can get it from the following location: Download site Choose Your platform (OS) and download appropriate setup binary. Usually it takes some time to install it but with newer and SSD powered machines it is commonly less than a minute. After that You should set
JDK_HOME environment variable. There are many ways how to do it, and keeping in mind that Android Studio is cross platform solution things get even more different. Web is full of useful tutorials bearing with that subject so I’ll point you to the “all mighty Google” and “even mightier StackOverflow” how to do it on specific platform. However because I’m primarily a Windows user (not a fanboy, business requirement) I’ll point You to the free and fantastic utility called Rapid Environment Editor. This neat little app is developer’s final solution to environment editing disturbment on Windows. From my *nix experience Linux users should done it easily with terminal and for OS X ones I think there is some plist editing way. After this step go back to the Studio setup and run it.
During the installation You’ll be shown info about Java platform that Android Studio found locally and marked for latter usage. It should be JDK package installed few moments ago (eventually some other old installation). Check the path to the JDK installation, validate it and proceed further. Few “Nexts” after You’ll be prompted to import any existing configuration files leftover of some previous installations of the same product. Of course in case this is first time installing skip it by marking alternate option. Finish the setup and mark Android Studio for test run.
Introductory window is shown with various options for first time usage including:
- Opening new project
- Creating existing one
- Changing settings of IDE
This window is shown only once but all operations listed here are accessible later from products inner GUI.
Tweaking stuff at very early phase of usage is extremely bad habit. I’m serious about that one. Learn the stuff than make (necessary) modifications. Reverse order leads to
How to ...? questions that flood social sites like StackOverflow and Quora and present classical problem of reverted perspective between Yours serious issue and someones harsh answer on your dummy question. However ’cause I’m fairly experienced in using other IntelliJ based products I’ll suggest You to change your IDE look to new and fancy dark theme called Darcula. This is not aesthetic move instead it is based on thought that more polished UI could and should lead to higher level of satisfaction and in final increase Your productivity. It could be done through
Settings (IDE Settings group) > Appearance tab.
Tip for Windows users
Android Studio uses default monospaced font found on system. In case of having Windows XP or higher it is (ugly) Courier New. If You have Consolas on Your system use it instead or find alternative in some other (maybe even FOSS) programmers font. To do that create new theme based on Darcula (I call it “Dark”.) and override
Editor Font and
Console Font respectively.
IDE in Action
Time to get hands dirty. Create new project with the blank main activity using project creation wizard. First thing you’ll notice in project’s structure after UI is rendered is absence of
build.xml file and presence of few
build.gradle files. One empty for the project, and one generated for it’s main module i.e. Your app. For those of You not familiar with Gradle take a look at http://www.gradle.org/ It is replacement for Apache Ant used in Eclipse ADT. Essentially, Gradle is build system originated from Groovy world so lets spend few lines describing it…
Gradle is enterprise class build system for all kind of Java based projects. It is viable and modern replacement for old Apache Ant build system. Also it is Groovy based, meaning that
.gradle recipes are actually Groovy files but there is no need to worry of learning something new and esoteric because the syntax of those files is hash like with some JSON-ish touch rather than XML based Ant. It is definitely more readable and starter friendly than before (+1 for Google for this one). Also it is fairly simple to edit and create new ones just by looking at provided example. In case You have some unfinished Android project started in Eclipse, thus Ant based, You can convert it to Gradle one and import to new IDE. Exact procedure is constructed of simple 8 steps and detail described at http://developer.android.com/sdk/installing/migrate.html
Important part of developing an Android application is working with it’s resources. Android Studio simplifies that task by various means.
In case of
String resources it virtually switches resource extraction code with calculated values according to corresponding XML file and selected translation. This approach works also with code suggestion meaning that You can select target
String resource and generate appropriate Java code for its extraction.
Image resources are displayed as mini icons on gutter space near corresponding line of code. Also they can be selected through code suggestion dropdowns. Similair approach is used in case of Colors where color sample is shown on gutter.
I’ve mentioned code suggestion in Resource part but that’s not the only improvement made in the field. For classic Java typing also significant steps forward have been made. Most notably suggestions are context sensitive. What I mean by that is that IDE narrows possible suggestions by Package and Method name and their respective types. This is not regular dropdown menu with all possible values instead it is list of AI calculated, valid, entries.
Annotations are somehow invisible part of this fantastic product but they are responsible for lot of good stuff bundled in it. Annotations feature means that Android Studio is extracting valuable info about Android API methods through consuming Java annotations buried in it’s source code. Extracted informations enable really cool stuff like:
- hints for possible
- determining validity of constant parameters not just by type, but the name also
- You name it…
This is very interesting feature obviously not present in Eclipse ADT that could be decision breaker for code guys. Coupled with fantastic arsenal of IntelliJ re-factoring abilities and embedded Android Lint creates rock solid base Environment for producing nice and error prone code in smallest possible amount of time. Comparing that with Eclipse is just impossible.
Besides improvement in writing code this release gives developers decent tool to design their apps with. Most of online previews of Studio promote thesis that its GUI designer is behind current Eclipse one but to be as much fair as possible correct statement would be: Android Studio has far better and far less stable GUI design tools than their Eclipse’s counterparts. However stuff looks generally similar. There is GUI elements Palette drawer, drop-in design canvas, property editor. Switching to text mode (writing XML directly) reveals interesting dynamic preview that is real time 2way synced with written stuff. It is also clickable/markable which points text editor to target definition and reverse. Besides navigation and layouting helpers preview window consists of initially hidden information area that holds design suggestions and applicable typo fixes. It is neat little feature that helps You from writing same boilerplate code over and over again and prevents You from making stupid errors. Also it is really really fast, rendering without delays and glitches even on entry level configurations.
Besides these neat additions design tool is heavily equipped with great support for multi-layout development and application translating. Multiple layouts can be shown simultaneously with or without decorative device frames and also live synced with code. Same is possible for multiple languages giving developers insight in design actions needed to adapt to different culturological needs.
This is definitely not full finished product but it is valid and possibly preferred Eclipse alternative even at its present state. Incorporated with whole bunch of small but significant features that make life easier for developers producing great design and code this smart new IDE makes really bright vision of incoming Android future. Stay tuned for upcoming updates from Google and while waiting take a look on this neat video presentation from DevBytes http://youtu.be/e0fXuyL0xVU
We shape our core capabilities around lean product teams capable of delivering immense value to organisations worldwide