Android Studio - Android Developer Tips & Tricks
Today we bring to some useful Android Studio Tips and Tricks which will make every developer's life easy 😎
What is Android Studio?
Android Studio is the only official IDE for Android. It is purpose-built for Android to accelerate your development and help you build the highest-quality apps for every Android/iOS devices. Android Studio built on JetBrains' IntelliJ IDEA.Android Studio is useful for Android Development [using Java, Kotlin & C++] or Flutter Development [using Dart].
Features Of Android Studio:
Hot Reload: Android Studio's Hot Reload feature lets you push code and resource changes to your running app without restarting your app. This flexibility helps you control how much of your app is restarted when you want to deploy and test small, incremental changes while preserving your device's current state.Intelligent Suggestions: As you type, Android Studio provides suggestions that are very helpful for writing better code, work faster, and be more productive.
Emulator: Android Studio Emulator installs and starts your apps faster than a real device and allows you to prototype and test your app on various Android device configurations. The emulator supports Phones, Tablets, Android Wear, and Android TV devices. The emulator can also simulate a variety of hardware features such as GPS location, network latency, motion sensors, and multi-touch input, and may more. If you are using a Flutter, the emulator shows how your app will look like on the iPhone
Example Code: There are lots of code templates and samples provided by android. Which helpful for covering basics & make it easy to add well-established patterns such as a navigation drawer and view pager. you can import fully functional apps from GitHub provided by android.
Teamwork Support: Android Studio integrates with version control tools, such as GitHub, GitLab, Bitbucket etc. so you can keep your team in sync with the project and build changes.
Optimization: Android Studio provides a unified environment where you can build apps for Android Phones, Tablets, Android Wear, Android TV, and Android Auto. You can divide the project into units of functionality that you can independently build, test, and debug.
Helpful Tips & Tricks for Android Studio:
1. Modes: If you are planning to give a presentation and you want to show your code. It will be painful for you to close all small widgets one by one. Even after that, your code might not be visible properly on the projector. So, Android Studio comes with 2 special modes.
Distraction-Free Mode & Presentation Mode
For Windows & Mac: View + Appearance + Enter Distraction Free Mode
For Windows & Mac: View + Appearance + Enter Presentation Mode
Step 1: Select all occurrences of “//”, Select any “//” then press
For Windows: Ctrl + Shift + Alt + J [Use Alt + J for selecting one by one]
For Mac: Ctrl + Command + G
Step 2: To select complete next line
Shift + End for Windows and MAC.
Step3: To delete all selected lines
Backspace
This trick can use for comments in the .yaml file in Flutter, only select "#" instead of "//"
Search History: When you have backup online on GitHub, GitLab, etc. reverting to last commit is possible. Real problems arrive offline. You make quite a few changes or replacement or sometime commit mistakes but cannot revert back to code present half an hour ago or revert back to code state of last session.
Android studio solves your problem with Version Control System, in short VSC menu in Android.
VCS > Local History > Show history
Find Anything: It is quite a pain to search when everything is new. Just Press Shift + Shift, you will get a window to search for anything you want. Not just a class or file. You can find the setting, shortcuts, widget anything which is part of Android Studio.
Theme: Change your theme to Dracula. Dracula themes can reduce eye strain in low-light conditions (night time or dimmer workspaces). High contrast between text and background reduces eye strain. Syntax highlighting can be easier to see with light-on-dark themes.
For Windows: File > Setting > Appearance & Behavior > Appearance > Theme
For MAC: Android Studio > Preferences > Appearance & Behavior > Appearance > Theme
Find Anything: It is quite a pain to search when everything is new. Just Press Shift + Shift, you will get a window to search for anything you want. Not just a class or file. You can find the setting, shortcuts, widget anything which is part of Android Studio.
Theme: Change your theme to Dracula. Dracula themes can reduce eye strain in low-light conditions (night time or dimmer workspaces). High contrast between text and background reduces eye strain. Syntax highlighting can be easier to see with light-on-dark themes.
For Windows: File > Setting > Appearance & Behavior > Appearance > Theme
For MAC: Android Studio > Preferences > Appearance & Behavior > Appearance > Theme
For windows: File > Setting > Editor > Font Size
For MAC: Android Studio > Preferences > Editor > Font Size
Logcat: Logcat is where you can find all logs of your application. By default, the only error is visible in red color but It is better to have our Logcat personalized i.e. you can set the color for different messages like info, debug, assert, error, verbose, and warning so you can read Logcat easily. To change you need to uncheck the “Inherit values from”
For Windows: File > Settings > Editor > Color Scheme > Android Logcat
For Mac: Android Studio > Preferences > Editor > Color Scheme > Android Logcat
Auto formatting: Android Studio can Format code & Organize imports.
For Windows: Ctrl + Alt + L [User Ctrl + Alt + Shift + L to get Reformat setting]
For Mac: Command + Option + L & Command + Option + O
For flutter development, Android Studio provides a much easier option so both code formatting and organizing import can be done of Ctrl + S [saving], Just select “Format code on save” and “Organize import on save” in Language & Frameworks.
For Mac: Android Studio > Preferences > Language & Frameworks > Flutter
Firebase Integration: Android Studio give you all the help for the integration of firebase in your android project. Got to Tools > Firebase. From here you can add all firebase dependencies directly into your project. Android studio will do all the file updating, formatting, and redirect you to the browser to create a project if you don’t have one, even ask you which project you want to integrate of you have more than one. [Make sure you are already login in Android studio]
Tools: Android studio has lots of tools like SDK manager, AVD Manager, APK analyzer, Profiler, Flutter Inspector to help you before, while & after the development process completes so you can produce a fine product. The team behind Android Studio still Introducing new tools every year to stop the developer’s dependency on other services.
Important shortcuts for Android Studio:
Android has a tone of shortcuts it is impossible to remember them all so I adding few which you can use to increase your productivityRename Variable/File: You can Right Click on the name of variable and file and select on Refractor > Rename or Press Shift + F6 for both Windows and Mac.
Code Completion: Some format is fixed, For example, if you want to print Logs or show Toast. Type “T” or “L” respectively then type Ctrl + J on Windows or Command + G on Mac You will get a possible Suggestion List, Select the appropriate option. By saving your effort for such small tasks you can increase your productive time.
Extended Selection: You can select a single word like variable/function/class name or complete code block use Ctrl + W on Windows or Option + Up Arrow on MAC. If you keep pressing this key than the selection span will go on increasing to the point you select all content in file.
Find method info: Put the cursor on the required method and then pressing the Ctrl + Q in Windows or Ctrl + J in Mac. Ctrl + P works similarly but give less info.
Get Last Copied Text: You can get a text to paste from list of texts which you copied in the current session just clicking Ctrl + Shift + V in Windows or Command + Shift +V in Mac.
Androids Stable & official version is also here. Google took whole 1 year to release a new version. Android 10 was released in September 3, 2019. Android Latest Version which is Android 11 was released on September 11, 2020. There are few new features introduce by android. Only selective models of Pixel & Xiaomi are compatible with this new change.
And New Updates means new challenges.
Android studio is constantly changing the way, how things are done. And the learning curve makes us want to grow more. We will need to do extensive reading and code rewriting as we stumble upon new issues. But the truth is Experience is the name everyone gives to their mistakes so keep coding.
References:
https://developer.android.com/studio/features
https://www.raywenderlich.com/2807578-android-studio-tips-and-tricks
https://medium.com/@mmbialas/50-android-studio-tips-tricks-resources-you-should-be-familiar-with-as-an-android-developer-af86e7cf56d2
Author:
Er. Hemant Mochemadkar
(Sr. Android Developer)
Have you also read?
Comments
Post a Comment