Welcome to Android Studio (Meet Android Studio) 1, preface
Android Studio is an Android application development environment based on IntelliJ idea under the official whole. Based on IntelliJ's powerful code editor and development tools, Android Studio offers more features to increase your efficiency in developing Android applications, as follows:
- A flexible, Gradle-based build system
- Fast and feature-rich simulators
- Provides a unified environment for developing Android devices
- Instant run push changes no need to recompile new APK to run your application
- Integration of code templates and GitHub to help you build common application features and import sample code
- Provides a wide range of testing tools and frameworks
- Use the lint tool to capture performance, availability, version compatibility, and other issues
- Support for C + + and NDK development
- Built-in support for Google Cloud Platform makes it easy to integrate Google Cloud messaging and application engine
This page provides an introduction to basic Android Studio features. For a summary of the latest release changes, see the Android studio release notes.
2. Engineering structure (Project Structure)
In Android studio, each project contains one or more modules source files and resource files. Modules includes the following major types:
- Android app Modules
- Library Modules
- Google App Engine modules
By default, Android studio displays your project files in Android drawing view:
。
All generated files are visible at the top level of the Gradle script, and each application module contains the following folders:
- Manifests: Contains the Androidmanifest.xml file.
- Java: Contains Java source code files, including JUnit test code.
- Res: contains all non-code resources, such as XML layout, UI strings, and bitmap images
You can also customize the view of project files to focus on specific aspects of application development. For example, selecting the project's problem view displays links to source files that contain any recognized encoding and syntax errors, such as missing XML element closing tags in the layout file.
For more information, see the Managing Projects section.
3. UI (the user Interface)
The main windows of Android Studio are made up of several logical regions identified in Figure 3,
(1) The toolbar allows you to do a wide range of actions, including running your application and launching Android tools.
(2) The navigation bar can help you navigate through your projects and open file edits. It provides a more compact view of the structure visible in the Project Tools window.
(3) The editor window is where you create and modify code. Depending on the current file type, this window can be changed. For example, when you view a layout file, the editing window displays the Layout editor and provides options to view the corresponding XML file.
(4) tool windows give you access to specific tasks such as project management, search, versioning, and more. You can unfold them, and shrink to hide them.
(5) The status bar displays the status of your project and the IDE itself, as well as any warnings or information.
You can organize the main window, give yourself more screen space to be hidden or move the toolbars and tool windows. You can also use keyboard shortcuts to access most IDE features. At any time, you can search your source code, database, action, user interface elements, etc., by double pressing the SHIFT key, or click Magnifier in the upper right corner of the Android Studio window. This can be very useful, for example, you are trying to find a specific IDE action that you have forgotten how to trigger.
4. tool window (Tools windows)
Android Studio follows your background and automatically provides you with relevant tool windows to let you work instead of using a preset window. By default, the most commonly used tool window is pinned to the tool window at the edge of the application window.
- To expand or collapse a tool window, click the tool name in the Tools window. You can also drag, press, release, fit, and detach the tool window.
- Return to the current Default tool window layout, click Window > Restore default layout or customize the default layouts for default settings by clicking Window > Store Current layout.
- To show or hide the entire tool window bar, click the icon in the lower-left corner of the Android Studio window.
- To find a specific tool window, hover over the window icon and choose the Tools window from the menu.
You can also use keyboard shortcuts to open tool windows. Table 1 lists the most common shortcuts for Windows.
If you want to hide all toolbars, tool windows, and Edit tabs, click View > Enter distraction free Mode. This goes into no-interference mode. To exit the no-interference mode, click View > Exit Distraction free.
In Android Studio you can use the Quick Search search and filter in most tool windows. To use Quick Search, select the Tools window, and then type your search query.
5. Code completion
Android Studio has three types of code completion that you can access using keyboard shortcuts.
Table 2, keyboard shortcuts for code hints.
category |
Description |
Windows and Linux platforms |
Mac Platform |
Basic code hints |
Basic recommendations for variables, types, methods, expressions, and so on. If you call basic completion in a row two times, you can see more results, including private members and non-imported static members. |
Control+space |
Control+space |
Smart Perfection |
Displays related options based on context. Intelligent completion is aware of the expected type and flow of data. If you call smart completion in a row two times, you see more results, including the chain. |
Control+shift+space |
Control+shift+space |
Statement refinement |
Complete your current statement by adding the missing brackets, parentheses, parentheses, formatting, and so on. |
Control+shift+enter |
Shift+command+enter |
You can also perform a quick fix by pressing ALT + ENTER to display the behavior.
6. Navigation (Navigation)
Here are some tips to help you switch workspaces in Android Studio.
- Use the most recent file operation to switch between your most recently accessed files. Press Control+e (Control+e on a Mac) to present the most recent file action. By default, the last accessed file is selected. You can also access any tool window by using the left column in this action.
- Use the file structure action to view the structure of the current file. Take the file structure action by pressing CONTROL+F12 (COMMAND+F12 on Mac). With this action, you can quickly browse to any part of the current file.
- Search and navigate to a specific class in your project by using the Navigate to class action. Act by pressing Control+n (Command+o on Mac). Navigating to a class supports complex expressions, including camel hump, path, line navigation, middle name matching, and more. If you call it two times in a row, it will show the result of the project class.
- Navigate to a file or folder and use the Navigate to file operation. Navigate to file operations by pressing CONTROL+SHIFT+N (Command+shift+o on Mac). To search for a folder, not a file, add a/At the end of your expression.
- Navigate to a method or field by using the name of the navigation to symbol action. Turn navigation by CONTROL + SHIFT + ALT + N symbol action (COMMAND + SHIFT + ALT + O on Mac).
- Locate all the fragment code that references the class, method, field, parameter, or declaration at the current cursor position by pressing ALT + F7.
7. Style and format (style and formatting)
When you edit, Android Studio automatically applies the formatting and style that you specify in your code style settings. You can customize settings through the code style of the programming language, including specifying tabs and indents, meeting spaces, packages and braces, and blank lines. Customize your code styling settings, click File > Settings > Editor > Code Style (Android Studio > Preferences > Editor > Code style On Mac.)
Although the IDE automatically applies the formatting to your work, you can also explicitly call the format code action by pressing CONTROL+ALT+L (OPT+COMMAND+L), or automatically indenting all lines by pressing Control+alt+i (Alt+option+i on Mac).
Figure 5, after the formatted code.
8. Basic knowledge of versioning (version control Basics)
Android Studio supports a variety of version control systems (VCS), including Git,github,cvs,subversion,mercurial, and the Google Cloud Source library.
When importing your app into Android studio, use the Android studio VCS menu option to make VC support the required version control system, create a repository, import new files to version control, and perform other versioning operations:
From the Android Studio VCs menu, click Enable Version Control integration.
From the drop-down menu, select a version control system to associate with the project root, and then click OK.
The VCs menu now shows some of the system versioning options that are based on your choice.
Note: You can also use the File > Settings > Version Control menu option to set and modify versioning settings.
9. Gradle build System (Gradle build systems)
Android Studio uses the Gradle tool as the basis for building systems and provides more Android-specific capabilities through the Android Gradle plugin. This build system acts as an integrated tool in the Android Studio menu bar and runs independently of the command line. You can use the capabilities of the build system to accomplish the following functions:
- Customize, configure, and extend the build process.
- Use the same project to create multiple applications for your application, different function modules.
- Reuse code and resources in Sourcesets.
With the flexibility of the tool, you can do all this without needing to modify the application's kernel source files. The files generated by Android Studio are named Build.gradle. They are plain text files that use groovy's syntax to configure the tool elements provided by the Android plugin. Each project has a top-level build file that builds files for each module for the entire project and for individual module levels. When you import an existing project, Android Studio automatically generates the required build files.
To learn more about building systems and how to configure them, see the "Configure Your Build" section.
(1) Build variant version (build variants)
Building systems can help you create different versions of applications for the same project. This is useful when you have a free version and a paid version of the app, or if you want to put multiple apps on Google Play for different devices.
For more information about configuring variables, see the Configuring Gradle builds section.
(2) APK distribution version (APK splits)
APK will allow you to effectively create a multi-program based on screen density or ABI. For example, APK will allow you to create separate hdpi and mdpi density versions while still considering one of their variants, allowing them to share a test program, JAVAC,DX and obfuscation settings.
(3) resource compression (Resource Shrinking)
Resource compression in Android Studio automatically removes unused resources from dependencies of your packaged applications and libraries. For example, if the app uses Google Play service to access Google Drive features instead of you currently using Google's login, then resource compression can eliminate a variety of extra button resources under drawable.
Note: A resource shrinking work is combined with a code shrinking tool, such as a obfuscation device.
(4) Management dependency (managing Dependencies)
In the Build.gradle file, specify the dependencies for your project. Gradle is more concerned about your reliance on building effective. You can declare module dependencies, dependencies, and remote binaries, and you build.gradle file local binary dependencies. The Android Studio configuration project uses Maven's central repository by default. (This configuration is included in the top-level build file for the project.) For more information about configuring dependencies, read configuration generation variants.
10. Debugging and Configuration tool (Debug and profile tools)
Android Studio assists you in debugging and improving the performance of your code, including inline debugging and performance analysis tools.
(1) Online commissioning
Use inline debugging to improve your code walk-through in the debugger view with references, inline validation of expressions, and variable values. Inline debugging information includes:
- Inline Variable Value
- Object referencing the selected object
- The return value of the method
- Lambda arithmetic expressions
- Skill description
Figure 6, inline variable values.
(2) Performance Monitor
Android Studio provides performance Monitor that makes it easier for you to track your application's memory and CPU usage, find freed objects, find memory leaks, optimize graphics performance, and analyze network requests.
In your application running on a device or emulator, open the Android Monitor Monitor tool window and click on the "Monitor" tab.
For more information about Performance Monitor, see Android Monitor.
(3) Heap memory analysis
When you monitor memory usage in Android Studio, you can start a heap snapshot of garbage collection and garbage on the Java heap in an Android-specific hprof binary format file
The Hprof Viewer displays classes, instances of each class, and helps you track memory usage and find memory leaks in the reference tree.
For more information about heap dump work, see dumping and analyzing the Java heap.
(4) Configuration tracking
Android Studio allows you to track memory allocations because it monitors memory usage. Trace memory allocation allows you to monitor the location of an object while performing certain operations. Knowing these allocations enables you to optimize the performance of your application and memory usage by adjusting the method calls related to these actions.
For information on tracking and analyzing allocations, see the Allocation Tracker section.
(5) Accessing data files
Android SDK tools such as Systrace,logcat, and TraceView, generate performance and debug data for detailed application analysis. To view the data files that are available for the build, open the Capture tool window. In the list of generated files, double-click a file to view the data. Right-click any. The hprof file is converted to the standard hprof file format.
(6) Code check
When you compile your program, Android studio automatically runs configuration lint and other IDE checks to help you easily identify and correct problems with the quality of your code structure.
The tool examines your Android project source files for potential errors and optimizations for correctness, security, performance, usability, accessibility and internationalization improvements.
Figure 7, the results of a check in Android studio.
In addition to the lint check, Android Studio makes code checks and validates IntelliJ annotations to streamline your workflow.
For more information, see improving Your Code with Lint and Lint tool.
(7) Comments in Android Studio
Android Studio supports comments on variables, parameters, and return values to help catch errors such as null pointer exceptions and resource type conflicts. The Android SDK Manager package supports the comment library in Android studio using the Android support library.
Android Studio validates the configuration comments during the code review process.
(8) Log messages
When you build and run your program in Android Studio, you can view the log information output device (ADB logcat) by clicking Android Monitor at the bottom of the window. If you want to use your Android device monitor to debug your app, you can start device monitor by tapping Tools > Android > Android devices Monitor. The monitoring device is where you can analyze the behavior of your application to discover the full set of controls for DDMS tools, and more. It also includes the Hierarchy Browser tool to help optimize your layout.
If there is translation is not the place also want to correct!
I hope your donation will help the translation team to constantly work on translating more content.
Android Official development documentation for Android Studio (Meet Android Studio) Chapter