Android Studio

Android Studio

Android Development Environments

  • Google didn't create their own IDE when launching Android
  • Chose the open source platform Eclipse and created plugin to it instead
  • Eclipse common for many types of Java development
  • Still not as polished and stable as commercial IDEs
  • Google announced at Google I/O 2013 that they are switching to Intellij IDEA

Android Studio

  • Created by JetBrains
    • Same application as IntelliJ IDEA for a lot of other development tasks
  • Free and Open Source
    • The core development environment is free and open source. Most applications sold by JetBrains are actually plugins to the core.
  • Alpha version (currently 0.4.2)
    • Base environment IntelliJ IDEA is very stable and has been around for a lot longer
    • Recommend Android Studio for beginners while it works
    • Recommend Eclipse for professional developers that can't suffer downtime/reinstall


  • Download from the Android web site
  • Let it auto update when you start it (or "Help, Check for Update")
  • More help with the development environment
    • Remember that the core application is IntelliJ IDEA, so if you want to know more about the IDE, you can also look for information on that product.


  • Android now uses the Gradle build system
  • Gradle is an open source build system written in Java
  • Not just for Android
  • Basically a clever configuration file that defines what to include, compile and build to produce a resulting asp file
  • Gradle files contains both declarations/settings and custom code in Groovy language built on Java
  • The part of Android Studio that has failed for me, requiring major reinstall

Create project

  • File, New project (or from start screen)
  • Application name
    • This is the human readable name that you want to use when promoting your app
  • Module name
    • This is the IDE name of the first (and often only) module. Use same as Application name.
  • Package name
    • Important for Java and globally identifying your app. Use any made up domain name (in reverse), like com.masterofandroid.test1
  • Project location
    • The place on disk where the project and all files will be stored. This folder can be copied between computers to move your project.

Create project - Android versions

  • Minimum required SDK
    • This is the oldest Android version that any user of your app must have. Recommend API 7 for very simple apps, but API 15 for more modern apps.
  • Target SDK
    • This is the Android version that you are aware of and which features you would like access to, assuming that you know not to call/use any features between "Minimum required SDK" and this version when running on older devices. Recommend the latest.
  • Compile with
    • The Android version to build your app with. Recommend the latest. I've never used anything else.
  • Language level
    • Some newer Java features can be turned on here. Recommend keep at 6.0.
  • Theme
    • The default look of your first activity. Can easily be changed later on and for additional activities.

Create project - Complete

  • You can leave all other options at their defaults for this course

Tool windows

  • The panes that make up the user interface of Android Studio
  • Control all of them from icon in bottom left corner
  • Project
    • Shows your project tree with all the files that are part of the project
  • Preview
    • Displayed when a layout XML file is active. See how your app will (probably) look.
  • Other tool windows are automatcially displayed when needed, like for errors and debugging

Navigation shortcuts

  • Alt+Up/Down move between methods in Java or elements in XML
  • Ctrl+N search for class by name and show it
  • Ctrl+Shift+N search for file by name and open it

Editing shortcuts

  • Ctrl+Space for code completion, show a list of names that contains the part you've already written
  • Alt+Enter show list of intention actions, a way to fix your code automatically
    • Be sure to look at what it suggests when the small light bumb icon appears. The editor has probably found something that you should fix.

Helper visuals

  • Referenced images are shown in left margin
  • Referenced strings are shown as the value, not the reference
    • Beware when trying to edit. A bit confusing if you thing you start edit the text, and then it changes to the R reference.

Intention actions

  • Invoke with Alt+Enter
  • Import namespace for class
  • Implement methods for interface
  • Create string value from reference
  • Create click handler from attribute
  • Surround statement with try-catch
  • And many more...

Building and launching

  • Build app with Ctrl+F9, showing any compile time errors
  • Build and launch app for debugging with Shift+F9
  • Select what device to run the app on
  • Use same device for future launches within this session
    • Android Studio seems to forget this the first time, select again
  • Wait for emulator to start and launch your app
    • Will to slow the first time so Android Studio might give up. Go back to Android Studio and do Shift+F9 again once the emulator has booted completely and it should work fine.


  • Keep your eye at the Logcat window, which is output from the Android operting system running in the emulator.


  • View exceptions thrown in your app
  • Set breakpoint(s) and pause app
  • Run one statement at a time
    • Step into your own methods
    • Step over your own methods
  • Run at full speed until next breakpoint