Get the most out of Android Studio as an IDE
Android Studio as an IDE provides a lot of features, tricks and useful resources which can help us to improve our efficiency while coding.
Following are some of the things which I use:
Find file location in the project structure
While working and navigating through a codebase we want to know the location in the Project Structure of a file, Android Studio provides a shortcut which will directly take you to the location. It is called Scroll from Source.
Create scratch Files for your experimentation
We all experiment some stuff but not all these experiments are lucky enough to stay in our codebase, we keep on refactoring and change the code in the same file.
Android Studio provides a way to create scratch files which you can use for experimenting.
Command:
Mac: CMD + shift + A
Windows/Linux: Ctrl + Shift + A
Want to use your project dependencies?
Scratch files have the functionality to use your app classpath i.e. giving you access to all the modules that you included in your app module.
Documentation preview for a module function
Android Studio allows seeing the documentation for any third-party module function by enabling hovering over function.
Enable it by going to
Mac: Preferences -> Editor -> General -> Other section -> Show quick documentation on mouse move.
Others: File > Settings > Editor > General -> Other section -> Show quick documentation on mouse move.
Search across your codebase (Find in Path)
Search and find across your complete code base with a preview of the file. Command:
Mac: CMD + Shift + f
Windows/Linux: Ctrl + Shift + f
Use Zsh As your default terminal
Zsh provides with so many functionalities that your default terminal don’t provide so why not integrate zsh with android studio?
There are plenty of tutorial for setting-up zsh but in case you want one, here you go:
https://github.com/robbyrussell/oh-my-zsh#basic-installation
After installing:
1. Enable git plugin for git support
2. Install https://github.com/zsh-users/zsh-autosuggestions. It suggests commands as you type based on history and completions.
Set Zsh as default:
Mac: Preferences -> Tools -> Terminal -> Shell Path -> press browse and select ZSH
Windows/Linux: File -> Settings -> Tools -> Terminal -> Shell Path -> press browse and select ZSH
Reformat code
It should be a habit to reformat code while working.
Command:
Mac: option + CMD + L
Windows/Linux: Ctrl + Alt + L
Connect Wirelessly with Mobile
adb supports to connect wirelessly with your mobile device, the only condition is that both the laptop and mobile should be on the same network.
How?
Connect your device using the usb cable (Just this once 🤦♂️).
adb tcpip 5555
//thenadb connect your.device.ip.address
//or
adb connect your.device.ip.address:5555
Now you can remove your usb and debug wirelessly.
Navigate through the code
Android Studio allows you to navigate through the codebase using keyboards shortcuts.
Command:
Mac: CMD + Option + forward or back.
Windows/Linux: Ctrl + Alt + forward or back.
Switch Between Files
You can switch between the opened files using the keyboard shortcuts.
Command:
Mac: CMD + Option + [or ].
Windows/Linux: Ctrl + Alt + [or ].
IntelliJ Reference Card
IntelliJ provides with a reference card for KeyMaps which you can go through.
https://resources.jetbrains.com/storage/products/intellij-idea/docs/IntelliJIDEA_ReferenceCard.pdf
You can also take a print out of this and stick it on your desk.
Let me know in the comments what other tips, tricks and other useful resources you use.