Ultimate Guide to Using Android Studio

Source: Focus on APP Development – JianShu

Link: www.jianshu.com/p/7d9f91e86989

Introduction

Development Tool: Android Studio 2.1.2 (Mac version) Development Environment: OS X EI Capitan Version 10.11.5

1. Common Shortcuts

There are many shortcuts introduced online, I will only write a few that I often use: Ctrl+R to run APP, Ctrl+Alt(Option)+O to remove unused jar packages, Alt(Option)+Command+L to format code, Ctrl+N to find class, Ctrl+Shift+N to find file, Alt(Option)+Enter to import missing jar packages.

Ultimate Guide to Using Android Studio

Paste_Image.png

2. Common Plugins

First, let’s talk about how to install plugins

Ultimate Guide to Using Android Studio

Paste_Image.png

Ultimate Guide to Using Android Studio

Paste_Image.png

Ultimate Guide to Using Android Studio

Paste_Image.png

Recommended Useful Plugins

Plugin Name Plugin Function
Android ButterKnife Zelezny ButterKnife auto-generates annotation plugins, including holder
Android Parcelable code generator Parcelable auto-generation plugin
Android Property Initializer findViewById generation plugin
GsonFormat Paste JSON data to the clipboard, automatically generate Bean, significantly improve generation efficiency.

Using the Annotation Plugin ButterKnife (it is really a powerful tool that greatly improves efficiency)

Ultimate Guide to Using Android Studio

Paste_Image.png

Ultimate Guide to Using Android Studio

Paste_Image.png

Ultimate Guide to Using Android Studio

Paste_Image.png

Ultimate Guide to Using Android Studio

Paste_Image.png

3. Some Configuration Tips

1. How to set the font size of the code text

Ultimate Guide to Using Android Studio

Paste_Image.png

2. How to set the theme

Install a theme plugin, this theme I like more

Ultimate Guide to Using Android Studio

Paste_Image.png

https://meedamian.com/post/deuglifying-android-studio/?hi

3. Disable spell check

Ultimate Guide to Using Android Studio

Paste_Image.png

4. Check the current version of Gradle

Right-click on app, show package name

Ultimate Guide to Using Android Studio

Paste_Image.png

5. Display code line numbers

Ultimate Guide to Using Android Studio

Paste_Image.png

6. Using comment templates

Requirements are as follows:

Ultimate Guide to Using Android Studio

Paste_Image.png

Ultimate Guide to Using Android Studio

Paste_Image.png

Operation steps are as follows:

Just customize the comment template

Ultimate Guide to Using Android Studio

Paste_Image.png

Reference document: http://www.tuicool.com/articles/JNNFrym

7. How to create an empty Activity

Ultimate Guide to Using Android Studio

Paste_Image.png

8. Set the prefix for file names

Ultimate Guide to Using Android Studio

Paste_Image.png

9. How to generate an internal class into a separate file

Ultimate Guide to Using Android Studio

Paste_Image.png

Ultimate Guide to Using Android Studio

Paste_Image.png

Ultimate Guide to Using Android Studio

Paste_Image.png

10. How to import jar packages

Ultimate Guide to Using Android Studio

Paste_Image.png

11. Gradle Optimization

a. Increase memory

Go into the app package content

Ultimate Guide to Using Android Studio

Paste_Image.png

Configure according to your machine’s specifications (the more memory the better)

-Xms1024m   
-Xmx2048m   
-XX:MaxPermSize=350m   
-XX:ReservedCodeCacheSize=225m   
-XX:+UseCompressedOops

b. Increase gradle.properties

Ultimate Guide to Using Android Studio

Paste_Image.png

The content is as follows:

# Project-wide Gradle settings.   
# IDE (e.g. Android Studio) users:   
# Settings specified in this file will override any Gradle settings   
# configured through the IDE.   
# For more details on how to configure your build environment visit   
# http://www.gradle.org/docs/current/userguide/build_environment.html   
# The Gradle daemon aims to improve the startup and execution time of Gradle.   
# When set to true the Gradle daemon is to run the build.   
# TODO: disable daemon on CI, since builds should be clean and reliable on servers   
org.gradle.daemon=true   
# Specifies the JVM arguments used for the daemon process.   # The setting is particularly useful for tweaking memory settings.   # Default value: -Xmx10248m -XX:MaxPermSize=256m   
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -    XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8   
# When configured, Gradle will run in incubating parallel mode.   # This option should only be used with decoupled projects. More details, visit   #     http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects   
org.gradle.parallel=true   
# Enables new incubating mode that makes Gradle selective when configuring projects.   
# Only relevant projects are configured which results in faster builds for large multi-projects.   
#     http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:configuration_on_demand   
org.gradle.configureondemand=true

12. SVN commit code, ignore file configuration

1. .idea folder   
2. .gradle folder   
3. All build folders   
4. All .iml files   
5. local.properties file.

Ultimate Guide to Using Android Studio

Paste_Image.png

Submission method:

Click the “+” on the right to add, “-” to delete; Android Studio created Android projects generally need to ignore the .idea folder, .gradle folder, all build folders, all .iml files and local.properties file.

After ignoring the files, we will associate the project with SVN, select VCS->Import into Version Control->Share Project (Subversion); here I should note that under Import into Version Control there are Import into Subversion and Share Project (Subversion) two options [In studio 1.3 there is no second option only Share Project on GitHub]:

Import into Subversion The first is to directly import the project into the SVN server, but this way the local project does not establish a connection with the SVN server, after importing all project files will turn red, and when submitting to the SVN server it will prompt that the project is not an SVN working copy;

Share Project (Subversion) The second is to associate the current Android Studio project with the SVN server, but it does not import the project into the SVN server, need to submit the project to the SVN server again after establishing the connection.

Ultimate Guide to Using Android Studio

Paste_Image.png

13. Configuration Backup and Import

Ultimate Guide to Using Android Studio

Paste_Image.png

14. Keyword Mouse Hover Tips

Ultimate Guide to Using Android Studio

Paste_Image.png

15. How to create an assets directory in the project

Ultimate Guide to Using Android Studio

New assets1.png

Ultimate Guide to Using Android Studio

New assets2.png

References

Android Studio Tips and Tricks (Official Document Translation) http://www.open-open.com/lib/view/open1462930766027.html Android Studio Advanced Configuration http://www.2cto.com/kf/201605/504903.html Using Gradle https://services.gradle.org/distributions New Android Studio Template File Creation http://www.2cto.com/kf/201604/502599.html Speeding Up Gradle Compilation http://www.jcodecraeer.com/a/anzhuokaifa/Android_Studio/2015/0324/2637.html Introduction to Common Functions http://www.androidchina.net/3601.html Android Studio Error Code Not Prompting BUG (Power Saving Mode Explanation) http://m.blog.csdn.net/article/details?id=48708459 Android Studio Chinese Community http://forum.android-studio.org/forum.php?mod=forumdisplay&fid=40 Installation Video Tutorial http://www.jikexueyuan.com/course/396.html Video Tutorial (English Version) http://ask.android-studio.org/?/explore/category-video

Ultimate Guide to Using Android Studio

Leave a Comment

×