SlideShare a Scribd company logo
Android Studio Tips And Tricks
Mazhukin Oleg
Senior Android Developer
• UI
• Shortcuts
• Speed
• Debug
• Plugins
• Smart file templates
• Random Tips
The topics
View
→ Appearance
→ Enter Presentation Mode
or
ctrl+shift+a
→ Enter Presentation Mode
UI - Presentation Mode
UI - Presentation Mode
ctrl+shift+a
→ Exit Presentation Mode
UI - Exit Presentation Mode
Windows / Linux
→ ctrl + n
Mac
→ cmd + o
Shortcuts for navigation - Open class
Windows / Linux
→ ctrl + shift + n
Mac
→ cmd + shift + o
Open file
Windows / Linux
→ ctrl + e
Mac
→ cmd + e
Recently Opened Files
Windows / Linux
→ ctrl + f
Mac
→ cmd + f
Search in file
Windows / Linux
→ ctrl + shift + f
Mac
→ cmd + shift + f
Search Everywhere
Windows / Linux
→ ctrl + b
Mac
→ cmd + b
Go to declaration class
Windows / Linux
→ ctrl + b
Mac
→ cmd + b
Go to declaration variable
Windows / Linux
→ ctrl + alt + b
Mac
→ cmd + option + b
Go to implementation
Windows / Linux
→ ctrl+ w
Mac
→ cmd + w
Writing code - Selecting
Windows / Linux
→ ctrl+ o
Mac
→ cmd + o
Writing code - Overriding Methods
Windows / Linux
→ alt + insert
Mac
→ cmd + n
Writing code - Generating Methods
Windows / Linux
→ alt + shift + m
Mac
→ cmd + shift + m
Writing code - Creating Methods
Windows / Linux
→ ctrl+ space
→ tab
Mac
→ cmd + space
→ tab
Writing code - Autoreplace
Refactor
→ rename
→ extract/inline
→ change signature
→ safe delete
Writing code - Refactor
Preferences
→ Code Style
Writing code - Using code style
VCS
→ Git
Writing code - Git in Studio
Windows / Linux
→ ctrl+ K
Mac
→ cmd + K
Writing code - Git Commit
Best way to learn shortcuts
Tracking your progress
Help
→ Productivity Guide
Other useful info
Preferences (Settings)
→ Plugins
→ /enabled
Plugins - Disable unused plugins
Plugins - Enable useful plugins
Plugins - Enable useful plugins
Plugins – Live templates
Gradle
→ Toggle offline mode
Or
--offline
Build Speed Tips - Offline mode
Reuse Java between Android Studio and terminal
Use custom JDK Location
Limit Gradle workers
to real processors count
org.gradle.workers.max=«N»
Build Speed Tips - Worker count
Stopping gradle daemon
→ gradle --status
→ gradle --stop
Build Speed Tips - Stopping daemons
Using terminal
→ gradlew app:assembleDebug
→ gradlew app:installDebug
app - module name
Debug - buildType
Build Speed Tips - Using Terminal
→ gradlew clean
→ gradlew --profile
[--offline]
--rerun-tasks assembleFlavorDebug
→ open report
Build Speed - Local Statistics
gradlew assembleDebug --scan
Build Speed Debugging - Scan Plugin
→ Tasks Execution
→ Cache
→ Dependency resolution
Build Speed Statistics
gradlew clean
~/.gradle/caches/build-cache-1/ or ~/.gradle/caches/
~/.android/cache and/or ~/.android/build-cache
~/.idea/libraries
Clean Up Caches
→ 5.1" WVGA - 800*480: mdpi
→ 512 MB RAM/Internal storage 1.5 GB
→ Core Count 2х
Fast Emulator
Select expression
→ alt+F8
Debugging Check Expression
→ alt+F8
→ change result
Debugging Changing Behavior
Breakpoints
→ Log
Debugging Breakpoint Settings - Log
Console
→ Breakpoint reached
Debugging Breakpoint Settings - Log
Breakpoints
→ Disable until
→ Remove once hit
Debugging Breakpoint Settings Condition
Right click
→ Check RegEx
Debugging - Check RegEx
New
→ Edit live templates
Predefined file templates
Default Params
→ ${NAME}
→ ${PACKAGE_NAME}
→ ${DATE}
Predefined file templates - Interface Example
Default Params
→ ${Input}
→ ${Output}
Predefined Custom File Templates
Custom Params
→ ${Input}
→ ${Output}
Predefined Custom File In Action
New
→ file groups
Predefined Default File Group
Combines template with params
AS Version has limited abilities
Apache Freemarker
~/plugins/android/lib/templates/
Note the common folder
Predefined Default File Group Location
~/plugins/android/lib/templates/
→ Create any folder
→ Create template.xml.ftl
→ Describes your template
→ name/description
→ category
→ input params - string/boolean/enum
File Group Template
~/plugins/android/lib/templates/
→ /Custom/ViewModelActivity/template.xml.ftl
→ create ViewModel
→ create Activity
→ create layout
→ add activity to manifest
View Model Activity
New
→ Activity
→ View Model Activity
Template Result
Create [root]srcapp_package
→ Create recipe.xml.ftl
→ create ViewModel
→ create Activity
→ create layout
→ add activity to manifest ( merge only works with xml)
Recipe
Create globals.xml.ftl
→ reused variables in recipes
Example
Global variables
ViewModelActivitysrcapp_package
→ ViewModel.kt.ftl (or java.ftl )
→ define class preset
Default params
→ packageName - current package
→ activityToLayout - activity_className
Custom params - className
Recipe ViewModel
ViewModelActivitysrcapp_package
→ ViewModel.kt.ftl
→ define class preset
Recipe ViewModel
ViewModelActivitysrcapp_package
→ create ViewActivity.kt.ftl
→ define class preset
Recipe Activity
ViewModelActivitysrcapp_package
→ create Layout.kt.ftl
→ define layout
Recipe Layout
ViewModelActivity/
→ create AndroidManifest.xml.ftl
→ define activity
Recipe Manifest
template.xml – This will contain information about the template (Name,
minSdkVersion, etc)
recipe.xml.ftl – This will contain instructions explaining how to create the
template, including what variables to ask the user for and what should be
done with those variables.
globals.xml.ftl – This defines global variables
src (root/src or root/res) folder – this will contain the template code.
Structure
Debugging
Debugging
Result
Possibilities
- Learn different params types
→ boolean
→ list
→ etc
- Reuse existing recipes - add dependencies or strings
- Create your own file groups
What’s next?
- You have to re-import custom templates after Android Studio update
- Documentation is the source code
- No easy way to debug
Known Issues
→ Learn shortcuts to maximize your performance
→ Experiment and debug your gradle build speed
→ Use smart debug tools for better debugging
→ Create custom file templates to automate boilerplate code
Quick Recap
Android Studio Shortcuts → https://developer.android.com/studio/intro/keyboard-shortcuts
Android Studio for Experts → https://www.youtube.com/watch?v=Y2GC6P5hPeA
Mouseless Driven Development→ https://vimeo.com/98922030
File templates → https://riggaroo.dev/custom-file-templates-android-studio/
File group templates
→ https://medium.com/codequest/file-group-templates-in-android-studio-unofficial-guide-85dfa0a0c1ec
→ https://medium.com/gits-apps-insight/tutorial-create-your-own-template-for-android-studio-1aaa9b4cb18
Reuse gradle daemon → https://medium.com/@mydogtom/tip-how-to-reuse-gradle-daemon-between-
android-studio-and-terminal-df5232d63f38
Resources

More Related Content

PDF
Grails Simple Login
PDF
Switch to React.js from AngularJS developer
PPTX
ReactJs presentation
PPTX
Introduction to react and redux
PDF
React for Dummies
PDF
Idiomatic Gradle Plugin Writing - GradleSummit 2016
PDF
React on es6+
PPTX
Better React state management with Redux
Grails Simple Login
Switch to React.js from AngularJS developer
ReactJs presentation
Introduction to react and redux
React for Dummies
Idiomatic Gradle Plugin Writing - GradleSummit 2016
React on es6+
Better React state management with Redux

What's hot (19)

PDF
Making the Most of Your Gradle Builds
KEY
groovy & grails - lecture 10
KEY
groovy & grails - lecture 9
PDF
Introduction to ReactJS
PDF
React, Redux, ES2015 by Max Petruck
PDF
Advanced redux
KEY
groovy & grails - lecture 13
PDF
Creating a WYSIWYG Editor with React
PDF
Easy tests with Selenide and Easyb
PDF
Lecture 8 - Qooxdoo - Rap Course At The University Of Szeged
PPTX
Gradle build capabilities
ODP
Eclipse Mars News @JUG HH
PDF
Enter the gradle
PPTX
PPTX
Webdriver with Thucydides - TdT@Cluj #18
PDF
Redux vs Alt
PDF
Introduction to Redux
PDF
React.js or why DOM finally makes sense
PDF
Angular2 & ngrx/store: Game of States
Making the Most of Your Gradle Builds
groovy & grails - lecture 10
groovy & grails - lecture 9
Introduction to ReactJS
React, Redux, ES2015 by Max Petruck
Advanced redux
groovy & grails - lecture 13
Creating a WYSIWYG Editor with React
Easy tests with Selenide and Easyb
Lecture 8 - Qooxdoo - Rap Course At The University Of Szeged
Gradle build capabilities
Eclipse Mars News @JUG HH
Enter the gradle
Webdriver with Thucydides - TdT@Cluj #18
Redux vs Alt
Introduction to Redux
React.js or why DOM finally makes sense
Angular2 & ngrx/store: Game of States
Ad

Similar to Android studio tips and tricks (20)

PDF
Android studio
PDF
Next Step, Android Studio!
PPTX
Using Android Studio and Genymotion for improved productivity
PPTX
Android
PPTX
Shortcut keys of Android Studio , Complete about android studio
PDF
Michal Havryluk: How To Speed Up Android Gradle Builds
PDF
Android_Programming_Cookbook.pdf
PPTX
Android-studio-reporting ntrue.pptx.....
PPTX
Android Studio - Tips, Tricks & little known features
PDF
Getting the Most from Xamarin Studio - Michael Hutchinson
PPTX
Introduction to Android and Java.pptx
PDF
Head first android apps dev tools
PPTX
Exploring the power of Gradle in android studio - Basics & Beyond
PPTX
Android Studio development model and.pptx
PPTX
Android app development lesson 1
PDF
Android Cookbook Problems And Solutions For Android Developers Darwin
PDF
Android studio
PDF
Emergency androidstudiochapter
PDF
Effective Android Development
PDF
Android best practices 2015
Android studio
Next Step, Android Studio!
Using Android Studio and Genymotion for improved productivity
Android
Shortcut keys of Android Studio , Complete about android studio
Michal Havryluk: How To Speed Up Android Gradle Builds
Android_Programming_Cookbook.pdf
Android-studio-reporting ntrue.pptx.....
Android Studio - Tips, Tricks & little known features
Getting the Most from Xamarin Studio - Michael Hutchinson
Introduction to Android and Java.pptx
Head first android apps dev tools
Exploring the power of Gradle in android studio - Basics & Beyond
Android Studio development model and.pptx
Android app development lesson 1
Android Cookbook Problems And Solutions For Android Developers Darwin
Android studio
Emergency androidstudiochapter
Effective Android Development
Android best practices 2015
Ad

Recently uploaded (6)

PDF
6-UseCfgfhgfhgfhgfhgfhfhhaseActivity.pdf
PDF
heheheueueyeyeyegehehehhehshMedia-Literacy.pdf
DOC
证书学历UoA毕业证,澳大利亚中汇学院毕业证国外大学毕业证
DOC
Camb毕业证学历认证,格罗斯泰斯特主教大学毕业证仿冒文凭毕业证
PDF
Lesson 13- HEREDITY _ pedSAWEREGFVCXZDSASEWFigree.pdf
PPTX
ASMS Telecommunication company Profile
6-UseCfgfhgfhgfhgfhgfhfhhaseActivity.pdf
heheheueueyeyeyegehehehhehshMedia-Literacy.pdf
证书学历UoA毕业证,澳大利亚中汇学院毕业证国外大学毕业证
Camb毕业证学历认证,格罗斯泰斯特主教大学毕业证仿冒文凭毕业证
Lesson 13- HEREDITY _ pedSAWEREGFVCXZDSASEWFigree.pdf
ASMS Telecommunication company Profile

Android studio tips and tricks