Android Studio
Contents
Links & Resources
Importing
Importing projects into studio:
Run studio.sh to start android studio
Import the project, e.g. pointing it at ~/android/src/android_core as a gradle project.
- Import project from external model - gradle.
- 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.
Building
See the faq above about incremental compilations. It doesn't do them, but intelligently updates the ide with knowledge about changes without actually compiling.
To compile, right click a build.gradle file somewhere (e.g. some subproject) and tell it to make or compile, or go to the Build dropdown in the upper menu. To clean your projects Build->Rebuild Project.
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).
Troubleshooting
v0.1.7 Build Errors
No ANDROID_HOME, duplicate classes, not found - all sorts of errors introduced in 0.1.7 when it disabled external builds. Simply re-enable them in File->Settings->Compiler.