![](/uploads/1/2/5/6/125658923/756906564.jpg)
Android Studio is the official Integrated Development Environment (IDE) forAndroid app development, based onIntelliJ IDEA. On top of IntelliJ's powerful code editor and developer tools, AndroidStudio offers even more features that enhance your productivity when buildingAndroid 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 withoutrestarting your app
- Code templates and GitHub integration to help you build common app featuresand import sample code
- Extensive testing tools and frameworks
- Lint tools to catch performance, usability, version compatibility, and otherproblems
- C++ and NDK support
- Built-in support forGoogle Cloud Platform,making it easy to integrate Google Cloud Messaging and App Engine
La aplicacion la pueden buscar entre mis videos y lo descargan, a la mitad se descordina el audio asi que. SW Truss is a finite element analysis app for the analysis of statically determinate and indeterminate plane trusses. This app is useful to civil.
This page provides an introduction to basic Android Studio features.For a summary of the latest changes, seeAndroid Studio release notes.
Project structure
Each project in Android Studio contains one or more modules with source codefiles and resource files. Types of modules include:
- Android app modules
- Library modules
- Google App Engine modules
By default, Android Studio displays your project files in the Android projectview, as shown in figure 1. This view is organized by modules to provide quickaccess to your project's key source files.
All the build files are visible at the top level under Gradle Scripts andeach app module contains the following folders:
- manifests: Contains the
AndroidManifest.xml
file. - java: Contains the Java 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 flattenedrepresentation. To see the actual file structure of the project, selectProject from the Project dropdown (in figure 1, it's showing asAndroid).
You can also customize the view of the project files to focus on specificaspects of your app development. For example, selecting the Problems view ofyour project displays links to the source files containing any recognizedcoding and syntax errors, such as a missing XML element closing tag in a layoutfile.
Figure 2. The project files in Problemsview, showing a layout file with a problem.
For more information, see Projects overview.
The user interface
The Android Studio main window is made up of several logical areas identified infigure 3.
Figure 3. The Android Studio main window.
- The toolbar lets you carry out a wide range of actions, including running your app and launching Android tools.
- The navigation bar helps you navigate through your project and open files for editing. It provides a more compact view of the structure visible in the Project window.
- The editor window is where you 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.
- The tool window bar runs around the outside of the IDE window and contains the buttons that allow you to expand or collapse individual tool windows.
- The tool windows give you access to specific tasks like project management, search, version control, and more. You can expand them and collapse them.
- The status bar displays the status of your project and the IDE itself, as well as any warnings or messages.
You can organize the main window to give yourself more screen space by hidingor moving toolbars and tool windows. You can also use keyboard shortcuts toaccess most IDE features.
At any time, you can search across your source code, databases, actions,elements of the user interface, and so on, by double-pressing the Shift key, orclicking the magnifying glass in the upper right-hand corner of the AndroidStudio window. This can be very useful if, for example, you are trying tolocate a particular IDE action that you have forgotten how to trigger.
Tool windows
Instead of using preset perspectives, Android Studio follows your context andautomatically brings up relevant tool windows as you work. By default, the mostcommonly used tool windows are pinned to the tool window bar at the edges ofthe application window.
- To expand or collapse a tool window, click the tool’s name in the toolwindow bar. You can also drag, pin, unpin, attach, and detach tool windows.
- To return to the current default tool window layout, click Window >Restore Default Layout or customize your default layout by clickingWindow > 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 Studiowindow.
- To locate a specific tool window, hover over the window icon and select thetool window from the menu.
You can also use keyboard shortcuts to open tool windows. Table 1 lists theshortcuts for the most common windows.
Table 1. Keyboard shortcuts for some useful tool windows.
Tool window | Windows and Linux | Mac |
---|---|---|
Project | Alt+1 | Command+1 |
Version Control | Alt+9 | Command+9 |
Run | Shift+F10 | Control+R |
Debug | Shift+F9 | Control+D |
Logcat | Alt+6 | Command+6 |
Return to Editor | Esc | Esc |
Hide All Tool Windows | Control+Shift+F12 | Command+Shift+F12 |
If you want to hide all toolbars, tool windows, and editor tabs, clickView > Enter Distraction Free Mode. This enablesDistraction Free Mode. To exit Distraction Free Mode, clickView > Exit Distraction Free Mode.
You can use Speed Search to search and filter within most tool windowsin Android Studio. To use Speed Search, select the tool window and then typeyour search query.
For more tips, see Keyboard shortcuts.
Code completion
Android Studio has three types of code completion, which you can access usingkeyboard shortcuts.
Table 2. Keyboard shortcuts for code completion.
Type | Description | Windows and Linux | Mac |
---|---|---|---|
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, etc. | Control+Shift+Enter | Shift+Command+Enter |
You can also perform quick fixes and show intention actions by pressingAlt+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 symbolin your project. For more information, seeFind sample code.
Navigation
Here are some tips to help you move around Android Studio.
- Switch between your recently accessed files using the Recent Filesaction. Press Control+E (Command+E on a Mac) to bring up the RecentFiles action. By default, the last accessed file is selected. You can alsoaccess any tool window through the left column in this action.
- View the structure of the current file using the File Structure action.Bring up the File Structure action by pressing Control+F12(Command+F12 on a Mac). Using this action, you can quickly navigate to anypart of your current file.
- Search for and navigate to a specific class in your project using theNavigate to Class action. Bring up the action by pressing Control+N(Command+O on a Mac). Navigate to Class supports sophisticatedexpressions, including camel humps, paths, line navigate to, middle namematching, and many more. If you call it twice in a row, it shows you theresults out of the projectclasses.
- Navigate to a file or folder using the Navigate to File action. Bring upthe Navigate to File action by pressing Control+Shift+N(Command+Shift+O on a Mac). To search for folders rather than files, add a/ at the end of your expression.
- Navigate to a method or field by name using the Navigate to Symbol action.Bring up the Navigate to Symbol action by pressing Control+Shift+Alt+N(Command+Option+O on a Mac).
- Find all the pieces of code referencing the class, method, field, parameter,or statement at the current cursor position by pressing Alt+F7 (Option+F7 on a Mac).
Style and formatting
As you edit, Android Studio automatically applies formatting and styles asspecified in your code style settings. You can customize the code stylesettings by programming language, including specifying conventions for tabs andindents, spaces, wrapping and braces, and blank lines. To customize your codestyle settings, click File > Settings > Editor > Code Style (AndroidStudio > Preferences > Editor > Code Style on a Mac.)
Although the IDE automatically applies formatting as you work, you can alsoexplicitly call the Reformat Code action by pressing Control+Alt+L(Opt+Command+L on a Mac), or auto-indent all lines by pressingControl+Alt+I (Control+Option+I on a Mac).
Figure 4. Code before formatting.
![Una Una](http://www.movilzona.es/app/uploads/2015/12/Recursos-Android-Studio1.png)
Figure 5. Code after formatting.
Version control basics
Android Studio supports a variety of version control systems (VCS’s), includingGit, GitHub, CVS, Mercurial, Subversion, and Google Cloud Source Repositories.
After importing your app into Android Studio, use the Android Studio VCS menuoptions to enable VCS support for the desired version control system, create arepository, import the new files into version control, and perform otherversion control operations:
- From the Android Studio VCS menu, click Enable Version ControlIntegration.
- From the drop-down menu, select a version control system to associate withthe project root, and then click OK.
The VCS menu now displays a number of version control options based on thesystem you selected.
Note: You can also use the File >Settings > Version Control menu option to set up and modify the versioncontrol settings.
Gradle build system
Android Studio uses Gradle as the foundation of the build system, with moreAndroid-specific capabilities provided by theAndroid plugin for Gradle. This buildsystem runs as an integrated tool from the Android Studio menu, andindependently from the command line. You can use the features of the buildsystem to do the following:
- Customize, configure, and extend the build process.
- Create multiple APKs for your app, with different features using the sameproject and modules.
- Reuse code and resources across sourcesets.
By employing the flexibility of Gradle, you can achieve all of this withoutmodifying 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 withelements provided by the Android plugin for Gradle. Each project has onetop-level build file for the entire project and separate module-level buildfiles for each module. When you import an existing project, Android Studioautomatically generates the necessary build files.To learn more about the build system and how to configure, seeConfigure your build.
Build variants
The build system can help you create different versions of the same applicationfrom a single project. This is useful when you have both a free version and apaid version of your app, or if you want to distribute multiple APKs fordifferent device configurations on Google Play.
For more information about configuring build variants, seeConfigure build variants.
Multiple APK support
Multiple APK support allows you to efficiently create multiple APKs based on screen density orABI. For example, you can create separate APKs of an app for the hdpi and mdpi screen densities,while still considering them a single variant and allowing them toshare test APK, javac, dx, and ProGuard settings.
For more information about multiple APK support, readBuild multiple APKs.
Resource shrinking
Resource shrinking in Android Studio automatically removes unused resourcesfrom your packaged app and library dependencies. For example, if yourapplication is using Google Play servicesto access Google Drive functionality, and you are not currently usingGoogle Sign-In, then resource shrinking canremove the various drawable assets for the
SignInButton
buttons.Note: Resource shrinking works in conjunctionwith code shrinking tools, such as ProGuard.
For more information on shrinking code and resources, seeShrink your code and resources.
Managing dependencies
Dependencies for your project are specified by name in the
build.gradle
file.Gradle takes care of finding your dependencies and making them available in yourbuild. You can declare module dependencies, remote binary dependencies, andlocal binary dependencies in your build.gradle
file. Android Studio configuresprojects to use the Maven Central Repository by default. (This configuration isincluded in the top-level build file for the project.) For more informationabout configuring dependencies, readAdd build dependencies.Debug and profile tools
Android Studio assists you in debugging and improving the performance of yourcode, including inline debugging and performance analysis tools.
Inline debugging
Use inline debugging to enhance your code walk-throughs in the debugger viewwith inline verification of references, expressions, and variable values.Inline debug information includes:
- Inline variable values
- Referring objects that reference a selected object
- Method return values
- Lambda and operator expressions
- Tooltip values
Figure 6. An inline variable value.
To enable inline debugging, in the Debug window, click Settingsand select the checkbox for Show Values Inline.
Performance profilers
Android Studio provides performance profilers so you can more easily track yourapp’s memory and CPU usage, find deallocated objects, locate memory leaks,optimize graphics performance, and analyze network requests. With your apprunning on a device or emulator, open the Android Profiler tab.
For more information about performance profilers, seePerformance profiling tools.
Heap dump
When you’re profiling memory usage in Android Studio, you can simultaneouslyinitiate garbage collection and dump the Java heap to a heap snapshot in anAndroid-specific HPROF binary format file. The HPROF viewer displays classes,instances of each class, and a reference tree to help you track memory usageand find memory leaks.
For more informatin about working with heap dumps, seeInspect the heap and allocations.
Memory Profiler
You can use Memory Profiler to track memory allocation and watch where objectsare being allocated when you perform certain actions. Knowing these allocationsenables you to optimize your app’s performance and memory use by adjusting themethod calls related to those actions.
For information about tracking and analyzing allocations, seeInspect the heap and 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. Inthe list of the generated files, double-click a file to view the data.Right-click any
.hprof
files to convert them to the standardInvestigate your RAM usage file format.Code inspections
Whenever you compile your program, Android Studio automatically runs configuredLint and otherIDE inspections to help you easilyidentify and correct problems with the structural quality of your code.
The Lint tool checks your Android project source files for potential bugs andoptimization improvements for correctness, security, performance, usability,accessibility, and internationalization.
Figure 7. The results of a Lint inspection in Android Studio.
In addition to Lint checks, Android Studio also performs IntelliJ codeinspections and validates annotations to streamline your coding workflow.
For more information, seeImprove your code with lint checks.
Annotations in Android Studio
Android Studio supports annotations for variables, parameters, and returnvalues to help you catch bugs, such as null pointer exceptions and resourcetype conflicts. The Android SDK Manager packages the Support-Annotationslibrary in the Android Support Repository for use with Android Studio. AndroidStudio validates the configured annotations during code inspection.
For more details about Android annotations, seeImprove code inspection with annotations.
Log messages
When you build and run your app with Android Studio, you can viewadb output and device log messagesin the Logcat window.
Performance profiling
If you want to profile your app's CPU, memory, and network performance,open the Android Profiler,by clicking View > Tool Windows > Android Profiler.
![](/uploads/1/2/5/6/125658923/756906564.jpg)