Android Studio

Some of this may no longer be relevant given how fast Android Studio releases have been happening.

Overview

  • Based off intellij's java ide.
  • Synchronised with the command line execution of the new android gradle plugin.

Importing

Two ways to import projects from the android studio welcome window:

  1. Open an existing project
    • Point at the settings.gradle file, not the root directory of your gradle project.

  2. Import project (Gradle)
    • Point at the root directory of your gradle project.
    • Don't change any of the gradle settings away from the gradle wrapper configuration.

Refer to the troubleshooting section if you are having Android Studio woes.

Indexing

  • Right click on the symbol you want to index, e.g. AbstractNodeMain.

  • This will take you to the class file in the .jar or .aar.
  • Top right of the window, 'Attach Sources'.
  • Find the sources for this class, attach them and indexing will start for the whole jar.

Running

  • Run->Edit Configurations->+->Android Application

  • Rename the configuration
  • Choose the module (package) you want to take from
  • Usually just launching the default activity works.
  • Select the USB device.
  • Apply

For convenience, I usually setup two or three variations on the configuration for an android application - make/deploy/launch, deploy/launch and deploy only. Connect your device and then choose your configuration from the mini run menu on the toolbar at the top.

Debugging

Logcat

Use the monitor via the android studio menu, Tools->Monitor. Here you can filter logcat by application name (e.g. org.rocon.android.apps.robot_remocon).

Debugger

The toolbar at the top of the ide lets you define configurations for debug/run executions. Debug execution lets you set breakpoints and move through as usual. However, if you have code which is in binary compiled .aar's (of which there is alot), you'll need to associate those .aar's with source locations.

  • Click on the 'Project' view
  • Click on 'External Libraries'
  • Right click on the .aar you want to associate and 'Open Library Settings'
  • Click on the '+' symbol
    • Select 'Attach files or directories'
  • Point it at your sources (more specifically, at the src/main/java subfolder in the corresponding module).

Wiki: android/Android Studio (last edited 2015-03-01 15:04:35 by DanielStonier)