SlideShare ist ein Scribd-Unternehmen logo
1 von 71
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

Weitere ähnliche Inhalte

Was ist angesagt?

React.js or why DOM finally makes sense
React.js or why DOM finally makes senseReact.js or why DOM finally makes sense
React.js or why DOM finally makes sense
Eldar Djafarov
 

Was ist angesagt? (19)

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

Ähnlich wie Android studio tips and tricks

Gradle - time for a new build
Gradle - time for a new buildGradle - time for a new build
Gradle - time for a new build
Igor Khotin
 

Ähnlich wie Android studio tips and tricks (20)

[DEPRECATED]Gradle the android
[DEPRECATED]Gradle the android[DEPRECATED]Gradle the android
[DEPRECATED]Gradle the android
 
Gradle - the Enterprise Automation Tool
Gradle  - the Enterprise Automation ToolGradle  - the Enterprise Automation Tool
Gradle - the Enterprise Automation Tool
 
Why gradle
Why gradle Why gradle
Why gradle
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to Django
 
Single Page JavaScript WebApps... A Gradle Story
Single Page JavaScript WebApps... A Gradle StorySingle Page JavaScript WebApps... A Gradle Story
Single Page JavaScript WebApps... A Gradle Story
 
Gradle - time for another build
Gradle - time for another buildGradle - time for another build
Gradle - time for another build
 
Gradle - time for a new build
Gradle - time for a new buildGradle - time for a new build
Gradle - time for a new build
 
Make Your Build Great Again (DroidConSF 2017)
Make Your Build Great Again (DroidConSF 2017)Make Your Build Great Again (DroidConSF 2017)
Make Your Build Great Again (DroidConSF 2017)
 
Why Gradle?
Why Gradle?Why Gradle?
Why Gradle?
 
Building and Maintaining a Distribution in Drupal 7 with Features
Building and Maintaining a  Distribution in Drupal 7 with FeaturesBuilding and Maintaining a  Distribution in Drupal 7 with Features
Building and Maintaining a Distribution in Drupal 7 with Features
 
Config BuildConfig
Config BuildConfigConfig BuildConfig
Config BuildConfig
 
Grails beginners workshop
Grails beginners workshopGrails beginners workshop
Grails beginners workshop
 
Introduction to Magento 2 module development - PHP Antwerp Meetup 2017
Introduction to Magento 2 module development - PHP Antwerp Meetup 2017Introduction to Magento 2 module development - PHP Antwerp Meetup 2017
Introduction to Magento 2 module development - PHP Antwerp Meetup 2017
 
Drupal 8 Every Day: An Intro to Developing With Drupal 8
Drupal 8 Every Day: An Intro to Developing With Drupal 8Drupal 8 Every Day: An Intro to Developing With Drupal 8
Drupal 8 Every Day: An Intro to Developing With Drupal 8
 
Open event presentation.3 2
Open event presentation.3 2Open event presentation.3 2
Open event presentation.3 2
 
Behaviour Driven Development con Behat & Drupal
Behaviour Driven Development con Behat & DrupalBehaviour Driven Development con Behat & Drupal
Behaviour Driven Development con Behat & Drupal
 
Behaviour Driven Development con Behat & Drupal
Behaviour Driven Development con Behat & DrupalBehaviour Driven Development con Behat & Drupal
Behaviour Driven Development con Behat & Drupal
 
Gradle: The Build System you have been waiting for!
Gradle: The Build System you have been waiting for!Gradle: The Build System you have been waiting for!
Gradle: The Build System you have been waiting for!
 
Config/BuildConfig
Config/BuildConfigConfig/BuildConfig
Config/BuildConfig
 
Config BuildConfig
Config BuildConfigConfig BuildConfig
Config BuildConfig
 

Kürzlich hochgeladen

Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
Cara Menggugurkan Kandungan 087776558899
 

Kürzlich hochgeladen (6)

Mobile Application Development-Android and It’s Tools
Mobile Application Development-Android and It’s ToolsMobile Application Development-Android and It’s Tools
Mobile Application Development-Android and It’s Tools
 
Satara Call girl escort *74796//13122* Call me punam call girls 24*7hour avai...
Satara Call girl escort *74796//13122* Call me punam call girls 24*7hour avai...Satara Call girl escort *74796//13122* Call me punam call girls 24*7hour avai...
Satara Call girl escort *74796//13122* Call me punam call girls 24*7hour avai...
 
Mobile App Penetration Testing Bsides312
Mobile App Penetration Testing Bsides312Mobile App Penetration Testing Bsides312
Mobile App Penetration Testing Bsides312
 
Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
 
Android Application Components with Implementation & Examples
Android Application Components with Implementation & ExamplesAndroid Application Components with Implementation & Examples
Android Application Components with Implementation & Examples
 
Mobile Application Development-Components and Layouts
Mobile Application Development-Components and LayoutsMobile Application Development-Components and Layouts
Mobile Application Development-Components and Layouts
 

Android studio tips and tricks