Android Studio is the official Integrated Development Environment (IDE) for Android app development. Based on the powerful code editor and developer tools from IntelliJ IDEA , Android Studio offers even more features that enhance your productivity when building Android apps, such as:
- A flexible Gradle-based build system
- A fast and feature-rich emulator
- A unified environment where you can develop for all Android devices
- Apply Changes to push code and resource changes to your running app without restarting your app
- Code templates and GitHub integration to help you build common app features and import sample code
- Extensive testing tools and frameworks
- Lint tools to catch performance, usability, version compatibility, and other problems
- C++ and NDK support
- Built-in support for Google Cloud Platform, making it easy to integrate Google Cloud Messaging and App Engine
This page provides an introduction to basic Android Studio features. For a summary of the latest changes, see the Android Studio release notes.
Each project in Android Studio contains one or more modules with source code files and resource files. The types of modules include:
- Android app modules
- Library modules
- Google App Engine modules
By default, Android Studio displays your project files in the Android project view, as shown in figure 1. This view is organized by modules to provide quick access to your project's key source files. All the build files are visible at the top level, under Gradle Scripts.
Each app module contains the following folders:
- manifests: Contains the
- java: Contains the Java and Kotlin source code files, including JUnit test code.
- res: Contains all non-code resources such as XML layouts, UI strings, and bitmap images.
The Android project structure on disk differs from this flattened representation. To see the actual file structure of the project, select Project instead of Android from the Project menu.
You can also customize the view of the project files to focus on specific aspects of your app development. For example, select the Problems view of your project to display links to the source files containing any recognized coding and syntax errors, such as a missing XML element closing tag in a layout file.
For more information, see Projects overview.
The user interface
The Android Studio main window consists of several logical areas, shown in figure 3.
- Toolbar: Carry out a wide range of actions, including running your app and launching Android tools.
- Navigation bar: Navigate through your project and open files for editing. It provides a more compact view of the structure visible in the Project window.
- Editor window: Create and modify code. Depending on the current file type, the editor can change. For example, when viewing a layout file, the editor displays the Layout Editor.
- Tool window bar: Use the buttons on the outside of the IDE window to expand or collapse individual tool windows.
- Tool windows: Access specific tasks like project management, search, version control, and more. You can expand them and collapse them.
- Status bar: Display the status of your project and the IDE itself, as well as any warnings or messages.
To organize the main window for more screen space, hide or move the toolbars and tool windows. You can also use keyboard shortcuts to access most IDE features.
To search across your source code, databases, actions, elements of the user interface, and more, do one of the following:
- Double-press the Shift key.
- Click the magnifying glass in the upper right-hand corner of the Android Studio window.
This can be very useful if, for example, you are trying to locate a particular IDE action that you have forgotten how to trigger.
Instead of using preset perspectives, Android Studio follows your context and automatically brings up relevant tool windows as you work. By default, the most commonly used tool windows are pinned to the tool window bar at the edges of the application window.
Navigate the tool window using the following:
- To expand or collapse a tool window, click the tool’s name in the tool window bar. You can also drag, pin, unpin, attach, and detach tool windows.
- To return to the default layout of the current tool window, click Window > Restore Default Layout. To customize your default layout, click Window > Store Current Layout as Default.
- To show or hide the entire tool window bar, click the window icon in the bottom left-hand corner of the Android Studio window.
- To locate a specific tool window, hover over the window icon and select the tool window from the menu.
You can also use keyboard shortcuts to open tool windows. Table 1 lists the shortcuts for the most common tool windows.
|Tool window||Windows and Linux||macos|
|Return to Editor||Esc||Esc|
|Hide All Tool Windows||Control+Shift+F12||Command+Shift+F12|
To hide all toolbars, tool windows, and editor tabs, click View > Enter Distraction Free Mode. To exit Distraction Free Mode, click View > Exit Distraction Free Mode.
Use Speed Search to search and filter within most tool windows in Android Studio. To use Speed Search, select the tool window and then type your search query.
Android Studio has three types of code completion, which you can access using keyboard shortcuts.
|Type||Description||Windows and Linux||macOS|
|Basic Completion||Displays basic suggestions for variables, types, methods, expressions, and so on. If you call basic completion twice in a row, you see more results, including private members and non-imported static members.||Control+Space||Control+Space|
|Smart Completion||Displays relevant options based on the context. Smart completion is aware of the expected type and data flows. If you call Smart Completion twice in a row, you see more results, including chains.||Control+Shift+Space||Control+Shift+Space|
|Statement Completion||Completes the current statement for you, adding missing parentheses, brackets, braces, formatting, and so on.||Control+Shift+Enter||Command+Shift+Enter|
To perform quickfixes and show intention actions, press Alt+Enter.
Find sample code
The Code Sample Browser in Android Studio helps you find high-quality, Google-provided Android code samples based on the currently highlighted symbol in your project. For more information, see Find sample code.
Here are some tips to help you navigate Android Studio.
Use the Recent Files action to switch between your recently accessed files:
To bring up the Recent Files action, press Control+E (Command+E on macOS). By default, the last accessed file is selected. With this action, you can also access any tool window through the left column.
Use the File Structure action to view the structure of the current file and quickly navigate to any part of your current file:
To bring up the File Structure action, press Control+F12 (Command+F12 on macOS).
Use the Navigate to Class action to search for and navigate to a specific class in your project. Navigate to Class supports sophisticated expressions, including camel humps (which lets you search by the capitalized letters in an element's camel-cased name), paths, line navigate to (which lets you navigate to a specific line within the file), middle name matching (which lets you search for a part of the class name), and many more. If you call it twice in a row, it shows you the results out of the project classes.
To bring up the Navigate to Class action, press Control+N (Command+O on macOS).
Use the Navigate to File action to navigate to a file or folder:
To bring up Navigate to File action, press Control+Shift+N (Command+Shift+O on macOS). To search for folders rather than files, add a "/" at the end of your expression.
Use the Navigate to Symbol action to navigate to a method or field by name:
To bring up the Navigate to Symbol action, press Control+Shift+Alt+N (Command+Option+O on macOS).
To find all the pieces of code referencing the class, method, field, parameter, or statement at the current cursor position, press Alt+F7 (Option+F7 on macOS).
Style and formatting
As you edit, Android Studio automatically applies formatting and styles as specified in your code style settings. You can customize the code style settings by programming language, including specifying conventions for tabs and indents, spaces, wrapping and braces, and blank lines.
To customize your code style settings, click File > Settings > Editor > Code Style (Android Studio > Preferences > Editor > Code Style on macOS.)
Although the IDE automatically applies formatting as you work, you can also explicitly call the Reformat Code action. To call the action, press Control+Alt+L (Opt+Command+L on macOS). To auto-indent all lines, press Control+Alt+I (Control+Option+I on macOS).
Version control basics
Android Studio supports a variety of version control systems (VCSs), including Git, GitHub, CVS, Mercurial, Subversion, and Google Cloud Source Repositories.
After importing your app into Android Studio, use the Android Studio VCS menu options to enable VCS support for the desired system, create a repository, import the new files into version control, and perform other version control operations.
To enable VCS support, follow these steps:
- From the Android Studio VCS menu, select Enable Version Control Integration.
- From the menu, select a VCS to associate with the project root.
- Click OK.
The VCS menu now displays a number of version control options based on the system you selected.
Note: You can also use the File > Settings > Version Control menu option to set up and modify the version control settings.
Gradle build system
Android Studio uses Gradle as the foundation of the build system, with more Android-specific capabilities provided by the Android Gradle plugin. This build system runs as an integrated tool from the Android Studio menu and independently from the command line. You can use the features of the build system to do the following:
- Customize, configure, and extend the build process.
- Create multiple APKs for your app with different features, using the same project and modules.
- Reuse code and resources across source sets.
By employing the flexibility of Gradle, you can achieve all of this without modifying your app's core source files.
Android Studio build files are named
build.gradle. They are plain text files
that use Groovy syntax to configure the build with
elements provided by the Android Gradle plugin. Each project has one
top-level build file for the entire project and separate module-level build
files for each module. When you import an existing project, Android Studio
automatically generates the necessary build files.
To learn more about the build system and how to configure your build, see Configure your build.
The build system can help you create different versions of the same app from a single project. This is useful when you have both a free version and a paid version of your app or if you want to distribute multiple APKs for different device configurations on Google Play.
For more information about configuring build variants, see Configure build variants.
Multiple APK support
Multiple APK support lets you efficiently create multiple APKs based on screen
density or ABI. For example, you can create separate APKs of an app for the
mdpi screen densities, while still considering them a single
variant and letting them share test APK,
dx, and ProGuard settings.
For more information about multiple APK support, read Build multiple APKs.
Resource shrinking in Android Studio automatically removes unused resources
from your packaged app and library dependencies. For example, if your
Google Play services
to access Google Drive functionality, and you are not currently using
Google Sign-In, then resource shrinking can
remove the various drawable assets for the
Note: Resource shrinking works in conjunction with code shrinking tools, such as ProGuard.
For more information on shrinking code and resources, see Shrink, obfuscate, and optimize your app.
Dependencies for your project are specified by name in the
Gradle finds dependencies and makes them available in your
build. You can declare module dependencies, remote binary dependencies, and
local binary dependencies in your
Android Studio configures projects to use the Maven Central Repository by default. This configuration is included in the top-level build file for the project.
For more information about configuring dependencies, read Add build dependencies.
Debug and profile tools
Android Studio helps you debug and improve the performance of your code, including inline debugging and performance analysis tools.
Use inline debugging to enhance your code walkthroughs in the debugger view with inline verification of references, expressions, and variable values.
Inline debug information includes:
- Inline variable values
- Objects that reference a selected object
- Method return values
- Lambda and operator expressions
- Tooltip values
To enable inline debugging, in the Debug window, click Settings and select Show Values Inline.
Android Studio provides performance profilers so you can easily track your app’s memory and CPU usage, find deallocated objects, locate memory leaks, optimize graphics performance, and analyze network requests.
To use performance profilers, with your app running on a device or emulator, open the Android Profiler by selecting View > Tool Windows > Profiler.
For more information about performance profilers, see Profile your app performance.
When profiling memory usage in Android Studio, you can simultaneously
initiate garbage collection and dump the Java heap to a heap snapshot in an
HPROF binary format file. The HPROF viewer displays classes,
instances of each class, and a reference tree to help you track memory usage
and find memory leaks.
For more information about working with heap dumps, see Capture a heap dump.
Use Memory Profiler to track memory allocation and watch where objects are being allocated when you perform certain actions. These allocations help you optimize your app’s performance and memory use by adjusting the method calls related to those actions.
For information about tracking and analyzing allocations, see View memory allocations.
Data file access
The Android SDK tools, such as Systrace and Logcat, generate performance and debugging data for detailed app analysis.
To view the available generated data files:
- Open the Captures tool window.
- In the list of the generated files, double-click a file to view the data.
- Right-click any HPROF files to convert them to the standard.
- Investigate your RAM usage file format.
Whenever you compile your program, Android Studio automatically runs configured lint checks and other IDE inspections to help you easily identify and correct problems with the structural quality of your code.
The lint tool checks your Android project source files for potential bugs and optimization improvements for correctness, security, performance, usability, accessibility, and internationalization.
In addition to lint checks, Android Studio performs IntelliJ code inspections and validates annotations to streamline your coding workflow.
For more information, see Improve your code with lint checks.
Annotations in Android Studio
Android Studio supports annotations for variables, parameters, and return values to help you catch bugs, such as null pointer exceptions and resource type conflicts.
The Android SDK Manager packages the Jetpack Annotations library in the Android Support Repository for use with Android Studio. Android Studio validates the configured annotations during code inspection.
For more details about Android annotations, see Improve code inspection with annotations.
When you build and run your app with Android Studio, you can view
adb output and device log messages
in the Logcat window.
Sign in to your developer account
Sign in to your developer account in Android Studio to access additional tools that require authentication, such as Firebase. By signing in, you give those tools permission to view and manage your data across Google services.
Once you open a project in Android Studio, you can sign in to your developer account or switch developer accounts as follows:
Click the profile icon at the end of the toolbar, as shown in figure 8.
In the window that appears, do one of the following:
- If you're not yet signed in, click Sign In and allow Android Studio to access the listed services.
If you're already signed in, click Add Account to sign in with another Google account.
Alternatively, you can click Sign Out and repeat the previous steps to sign in to a different account.