Home | History | Annotate | Download | only in studio
      1 page.title=Android Studio Overview
      2 @jd:body
      3 
      4 <div id="qv-wrapper">
      5 <div id="qv">
      6 
      7     <h2>In this document</h2>
      8     <ol>
      9       <li><a href="#project-structure">Project and File Structure</a></li>
     10       <li><a href="#build-system">Android Build System</a></li>
     11       <li><a href="#debug-perf">Debug and Performance</a></li>
     12       <li><a href="#install-updates">Installation, Setup, and Update Management</a></li>
     13       <li><a href="#other">Other Highlights</a></li>
     14 
     15 
     16     </ol>
     17 
     18   <h2>See also</h2>
     19   <ol>
     20     <li><a href="http://confluence.jetbrains.com/display/IntelliJIDEA/FAQ+on+Migrating+to+IntelliJ+IDEA">IntelliJ FAQ on migrating to IntelliJ IDEA</a></li>
     21   </ol>
     22 
     23 </div>
     24 </div>
     25 
     26 
     27 <p>Android Studio is the official IDE for Android application development,
     28 based on <a href="https://www.jetbrains.com/idea/" class="external-link"
     29 target="_blank">IntelliJ IDEA</a>.
     30 On top of the capabilities you expect from IntelliJ,
     31 Android Studio offers:</p>
     32 
     33 <ul>
     34   <li>Flexible Gradle-based build system</li>
     35   <li>Build variants and multiple <code>apk</code> file generation</li>
     36   <li>Code templates to help you build common app features</li>
     37   <li>Rich layout editor with support for drag and drop theme editing</li>
     38   <li>Lint tools to catch performance, usability, version compatibility, and other problems</li>
     39   <li>ProGuard and app-signing capabilities</li>
     40   <li>Built-in support for <a
     41   href="http://developers.google.com/cloud/devtools/android_studio_templates/"
     42   class="external-link">Google Cloud Platform</a>, making it easy to integrate Google Cloud
     43   Messaging and App Engine</li>
     44   <li>And much more</li>
     45 </ul>
     46 
     47 <p><b><a href="{@docRoot}sdk/index.html">Download Android Studio now</a></b>. </p>
     48 
     49 <p>If you're new to Android Studio or the IntelliJ IDEA interface, this
     50 page provides an introduction to some key Android
     51 Studio features.</p>
     52 
     53 <p>For specific Android Studio how-to documentation, see the pages in the <a href=
     54 "{@docRoot}tools/workflow/index.html">Workflow</a> section, such as <a href=
     55 "{@docRoot}tools/projects/projects-studio.html">Managing Projects from Android Studio</a> and
     56 <a href="{@docRoot}tools/building/building-studio.html">Building and Running from Android
     57 Studio</a>.</p>
     58 
     59 
     60 
     61 
     62 <h2 id="project-structure">Project and File Structure</h2>
     63 
     64 <h3 id="project-view"><em>Android</em> Project View</h3>
     65 <p>By default, Android Studio displays your profile files in the <em>Android</em> project view. This
     66 view shows a flattened version of your project's structure that provides quick access to the key
     67 source files of Android projects and helps you work with the new
     68 <a href="{@docRoot}sdk/installing/studio-build.html">Gradle-based build system</a>.
     69 The Android project view:</p>
     70 
     71 <ul>
     72   <li>Groups the build files for all modules at the top level of the project hierarchy.</li>
     73   <li>Shows the most important source directories at the top level of the module hierarchy.</li>
     74   <li>Groups all the manifest files for each module.</li>
     75   <li>Shows resource files from all Gradle source sets.</li>
     76   <li>Groups resource files for different locales, orientations, and screen types in a single
     77   group per resource type.</li>
     78 </ul>
     79 
     80      <img src="{@docRoot}images/tools/projectview01.png" />
     81      <p class="img-caption"><strong>Figure 1.</strong> Show the Android project view.</p>
     82      <img src="{@docRoot}images/tools/studio-projectview_scripts.png"  />
     83      <p class="img-caption"><strong>Figure 2.</strong> Project Build Files.</p>
     84 
     85 <p>The <em>Android</em> project view shows all the build files at the top level of the project
     86 hierarchy under <strong>Gradle Scripts</strong>. Each project module appears as a folder at the
     87 top level of the project hierarchy and contains these three elements at the top level:</p>
     88 
     89 <ul>
     90   <li><code>java/</code> - Source files for the module.</li>
     91   <li><code>manifests/</code> - Manifest files for the module.</li>
     92   <li><code>res/</code> - Resource files for the module.</li>
     93 </ul>
     94 
     95 <p>For example, <em>Android</em> project view groups all the instances of the
     96 <code>ic_launcher.png</code> resource for different screen densities under the same element.</p>
     97 
     98 <p class="note"><strong>Note:</strong> The project structure on disk differs from this flattened
     99 representation. To switch to back the segregated project view, select <strong>Project</strong> from
    100 the <strong>Project</strong drop-down. </p>
    101 
    102 
    103 
    104 <h3>New Project and Directory Structure</h3>
    105 <p>When you use the <em>Project</em> view of a new project in Android Studio, you
    106 should notice that the project structure appears different than you may be used to in Eclipse. Each
    107 instance of Android Studio contains a project with one or more application modules. Each
    108 application module folder contains the complete source sets for that module, including
    109 {@code src/main} and {@code src/androidTest} directories, resources, build
    110 file and the Android manifest. For the most part, you will need to modify the files under each
    111 module's {@code src/main} directory for source code updates, the gradle.build file for build
    112 specification and the files under {@code src/androidTest} directory for test case creation.
    113 
    114     <p>  <img src="{@docRoot}images/tools/studio-project-layout.png" alt="" /></p>
    115     <p>  <class="img-caption"><strong>Figure 3.</strong> Android Studio project structure</p>
    116 
    117 <p>For more information, see
    118 <a href="http://confluence.jetbrains.com/display/IntelliJIDEA/Project+Organization"class="external-link">IntelliJ project organization</a> and
    119 <a href="{@docRoot}tools/projects/index.html">Managing Projects</a>.</p>
    120 
    121 
    122 <h3>Creating new files</h3>
    123 <p>You can quickly add new code and resource files by clicking the appropriate directory in the
    124 <strong>Project</strong> pane and pressing <code>ALT + INSERT</code> on Windows and Linux or
    125 <code>COMMAND + N</code> on Mac. Based on the type of directory selected, Android Studio
    126 offers to create the appropriate file type.</p>
    127 
    128 <p>For example, if you select a layout directory, press <code>ALT + INSERT</code> on Windows,
    129 and select <strong>Layout resource file</strong>, a dialog opens so you can name the file
    130 (you can exclude the {@code .xml} suffix) and choose a root view element. The editor then
    131 switches to the layout design editor so you can begin designing your layout.</p>
    132 
    133 
    134 
    135 <h2 id="build-system">Android Build System</h2>
    136 
    137 <h3>Android Build System</h3>
    138 <p>The Android build system is the toolkit you use to build, test, run and package
    139 your apps. This build system replaces the Ant system used with Eclipse ADT. It can run as an
    140 integrated tool from the Android Studio menu and independently from the command line. You can use
    141 the features of the build system to:</p>
    142 
    143 <ul>
    144     <li>Customize, configure, and extend the build process.</li>
    145     <li>Create multiple APKs for your app with different features using the same project and
    146     modules.</li>
    147     <li>Reuse code and resources across source sets.</li>
    148 </ul>
    149 
    150 <p>The flexibility of the Android build system enables you to achieve all of this without
    151 modifying your app's core source files. To build an Android Studio project, see
    152 <a href="{@docRoot}tools/building/building-studio.html">Building and Running from Android Studio</a>.
    153 To configure custom build settings in an Android Studio project, see
    154 <a href="{@docRoot}tools/building/configuring-gradle.html">Configuring Gradle Builds</a>.</p>
    155 
    156 
    157 <h3>Application ID for Package Identification </h3>
    158 <p>With the Android build system, the <em>applicationId</em> attribute is used to
    159 uniquely identify application packages for publishing. The application ID is set in the
    160 <em>android</em> section of the <code>build.gradle</code> file.
    161 </p>
    162 
    163     <pre>
    164     apply plugin: 'com.android.application'
    165 
    166     android {
    167         compileSdkVersion 19
    168         buildToolsVersion "19.1"
    169 
    170     defaultConfig {
    171         <strong>applicationId "com.example.my.app"</strong>
    172         minSdkVersion 15
    173         targetSdkVersion 19
    174         versionCode 1
    175         versionName "1.0"
    176     }
    177     ...
    178     </pre>
    179 
    180 <p class="note"><strong>Note:</strong> The <em>applicationId</em> is specified only in your
    181 build.gradle file, and not in the AndroidManifest.xml file.</p>
    182 
    183 <p>When using build variants, the build system enables you to to uniquely identify different
    184 packages for each product flavors and build types. The application ID in the build type is added as
    185 a suffix to those specified for the product flavors. </p>
    186 
    187    <pre>
    188    productFlavors {
    189         pro {
    190             applicationId = "com.example.my.pkg.pro"
    191         }
    192         free {
    193             applicationId = "com.example.my.pkg.free"
    194         }
    195     }
    196 
    197     buildTypes {
    198         debug {
    199             applicationIdSuffix ".debug"
    200         }
    201     }
    202     ....
    203    </pre>
    204 
    205 <p>The package name must still be specified in the manifest file. It is used in your source code
    206 to refer to your R class and to resolve any relative activity/service registrations. </p>
    207 
    208    <pre>
    209    <?xml version="1.0" encoding="utf-8"?>
    210    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    211    <strong>package="com.example.app"</strong>>
    212    </pre>
    213 
    214 <p class="note"><strong>Note:</strong> If you have multiple manifests (for example, a product
    215 flavor specific manifest and a build type manifest), the package name is optional in those manifests.
    216 If it is specified in those manifests, the package name must be identical to the package name
    217 specified in the manifest in the <code>src/main/</code> folder. </p>
    218 
    219 <p>For more information about the build files and process, see
    220 <a href="{@docRoot}sdk/installing/studio-build.html">Build System Overview</a>.</p>
    221 
    222 
    223 
    224 
    225 <h2 id="debug-perf">Debug and Performance</h2>
    226 
    227 
    228 <h3>Android Virtual Device (AVD) Manager</h3>
    229 <p>AVD Manager has updated screens with links to help you select the most popular device
    230 configurations, screen sizes and resolutions for your app previews.</p>
    231 Click the <strong>Android Virtual Device Manager</strong>
    232 <img src="{@docRoot}images/tools/avd-manager-studio.png"
    233 style="vertical-align:bottom;margin:0;height:19px" /> in the toolbar to open it and create
    234 new virtual devices for running your app in the emulator.</p>
    235 
    236 <p>The AVD Manager comes with emulators for Nexus 6 and Nexus 9 devices and also supports
    237 creating custom Android device skins based on specific emulator properties and assigning those
    238 skins to hardware profiles. Android Studio installs the Intel&#174; x86 Hardware Accelerated Execution
    239 Manager (HAXM) emulator accelerator and creates a default emulator for quick app prototyping.</p>
    240 
    241 <p>For more information, see <a href="{@docRoot}tools/devices/managing-avds.html">Managing AVDs</a>.</p>
    242 
    243 
    244 
    245 <h3> Memory Monitor</h3>
    246 <p>Android Studio provides a memory monitor view so you can more easily monitor your
    247 app's memory usage to find deallocated objects, locate memory leaks and track the amount of
    248 memory the connected device is using. With your app running on a device or emulator, click the
    249 <strong>Memory Monitor</strong> tab in the lower right corner to launch the memory monitor. </p>
    250 
    251     <img src="{@docRoot}images/tools/studio-memory-monitor.png" />
    252     <p class="img-caption"><strong>Figure 4.</strong> Memory Monitor</p>
    253 
    254 
    255 
    256 <h3> New Lint inspections</h3>
    257 <p>Lint has several new checks to ensure:
    258 <ul>
    259   <li><code> Cipher.getInstance()</code> is used with safe values</li>
    260   <li>In custom Views, the associated declare-styleable for the custom view uses the same
    261   base name as the class name.</li>
    262   <li>Security check for fragment injection.</li>
    263   <li>Where ever property assignment no longer works as expected.</li>
    264   <li>Gradle plugin version is compatible with the SDK.</li>
    265   <li>Right to left validation </li>
    266   <li>Required API version</li>
    267   <li>many others</li>
    268 </ul>
    269 
    270 <p>Hovering over a Lint error displays the full issue explanation inline for easy error
    271 resolution. There is also a helpful hyperlink at the end of the error message for additional
    272 error information.</p>
    273 
    274 <p>With Android Studio, you can run Lint for a specific build variant, or for all build variants.
    275 You can configure Lint by adding a <em>lintOptions</em> property to the Android settings in the
    276 build.gradle file.  </p>
    277 
    278     <pre>
    279     android {
    280         lintOptions {
    281            // set to true to turn off analysis progress reporting by lint
    282            quiet true
    283            // if true, stop the gradle build if errors are found
    284            abortOnError false
    285            // if true, only report errors
    286            ignoreWarnings true
    287     </pre>
    288 
    289 <p>For more information, see
    290 <a href="{@docRoot}tools/debugging/improving-w-lint.html">Improving Your Code with Lint</a>.</p>
    291 
    292 
    293 <h3>Dynamic layout preview</h3>
    294 <p>Android Studio allows you to work with layouts in both a <em>Design View</em> </p>
    295 <p><img src="{@docRoot}images/tools/studio-helloworld-design.png" alt="" />
    296 </p>
    297     <p class="img-caption"><strong>Figure 5.</strong> Hello World App with Design View</p>
    298 
    299 <p>and a <em>Text View</em>. </p>
    300 
    301     <p><img src="{@docRoot}images/tools/studio-helloworld-text.png" alt="" />
    302     <pclass="img-caption"><strong>Figure 6.</strong> Hello World App with Text View</p>
    303 
    304 <p>Easily select and preview layout changes for different device images, display
    305 densities, UI modes, locales, and Android versions (multi-API version rendering).
    306     <p><img src="{@docRoot}images/tools/studio-api-version-rendering.png" /></p>
    307     <p class="img-caption"><strong>Figure 7.</strong> API Version Rendering</p>
    308 
    309 
    310 <p>From the Design View, you can drag and drop elements from the Palette to the Preview or
    311 Component Tree. The Text View allows you to directly edit the XML settings, while previewing
    312 the device display. </p>
    313 
    314 
    315 <h3>Log messages</h3>
    316 <p>When you build and run your app with Android Studio, you can view adb and device log messages
    317 (logcat) in the DDMS pane by clicking <strong>Android</strong> at the bottom of the window.</p>
    318 
    319 <p>If you want to debug your app with the
    320 <a href="{@docRoot}tools/help/monitor.html">Android Debug Monitor</a>, you can launch it by
    321 clicking <strong>Monitor</strong>
    322 <img src="{@docRoot}images/tools/monitor-studio.png" style="vertical-align:bottom;margin:0;height:19px"/>
    323 in the toolbar. The Debug Monitor is where you can find the complete set of
    324 <a href="{@docRoot}tools/debugging/ddms.html">DDMS</a> tools for profiling your app,
    325 controlling device behaviors, and more. It also includes the Hierarchy Viewer tools to help
    326 <a href="{@docRoot}tools/debugging/debugging-ui.html"> optimize your layouts</a>.</p>
    327 
    328 
    329 
    330 
    331 <h2 id="install-updates">Installation, Setup, and Update Management</h2>
    332 
    333 <h3>Android Studio installation and setup wizards</h3>
    334 <p>An updated installation and setup wizards walk you through a step-by-step installation
    335 and setup process as the wizard checks for system requirements, such as the Java Development
    336 Kit (JDK) and available RAM, and then prompts for optional installation options, such as the
    337 Intel&#174; HAXM emulator accelerator.</p>
    338 
    339 <p>An updated setup wizard walks you through the setup processes as
    340 the wizard updates your system image and emulation requirements, such GPU, and then creates
    341 an optimized default Android Virtual Device (AVD) based on Android 5 (Lollipop) for speedy and
    342 reliable emulation. </p>
    343 <p><img src="{@docRoot}images/tools/studio-setup-wizard.png" /></p>
    344 <p class="img-caption"><strong>Figure 8.</strong> Setup Wizard</p>
    345 
    346 
    347 <h3>Expanded template and form factor support</h3>
    348 <p>Android Studio supports new templates for Google Services and expands the available device
    349 types. </p>
    350 
    351     <h4> Android Wear and TV support</h4>
    352     <p>For easy cross-platform development, the Project Wizard provides new templates for
    353     creating your apps for Android Wear and TV. </p>
    354     <p><img src="{@docRoot}images/tools/studio-tvwearsupport.png"  />
    355       <p class="img-caption"><strong>Figure 9.</strong> New Form Factors</p>
    356     <p>During app creation, the Project Wizard also displays an API Level dialog to help you choose
    357     the best <em>minSdkVersion</em> for your project.</p>
    358 
    359 
    360     <h4> Google App Engine integration (Google Cloud Platform/Messaging)</h4>
    361     <p>Quick cloud integration. Using Google App Engine to connect to the Google cloud
    362     and create a cloud end-point is as easy as selecting <em>File > New Module > App Engine Java
    363     Servlet Module</em> and specifying the module, package, and client names. </p>
    364     <p><img src="{@docRoot}images/tools/studio-cloudmodule.png" /></p>
    365     <p class="img-caption"><strong>Figure 10.</strong> Setup Wizard</p>
    366 
    367 
    368 
    369 <h3>Update channels</h3>
    370 <p>Android Studio provides four update channels to keep Android Studio up-to-date based on your
    371 code-level preference:
    372 <ul>
    373   <li><strong>Canary channel</strong>: Canary builds provide bleeding edge releases, updated
    374   about weekly. While these builds do get tested, they are still subject to bugs, as we want
    375   people to see what's new as soon as possible. This is not recommended for production.</li>
    376   <li><strong>Dev channel</strong>: Dev builds are hand-picked older canary builds that survived
    377   the test of time. They are updated roughly bi-weekly or monthly.</li>
    378   <li><strong>Beta channel</strong>: Beta builds are used for beta-quality releases before a
    379   production release.</li>
    380   <li><strong>Stable channel</strong>: Used for stable, production-ready versions.</li>
    381 </ul>
    382 </p>
    383 
    384 <p>By default, Android Studio uses the <em>Stable</em> channel. Use
    385 <strong>File > Settings > Updates</strong> to change your channel setting. </p>
    386 
    387 
    388 
    389 <h2 id="other">Other Highlights</h2>
    390 
    391 <h3> Translation Editor</h3>
    392 <p>Multi-language support is enhanced with the Translation Editor plugin so you can easily add
    393 locales to the app's translation file. Color codes indicate whether a locale is complete or
    394 still missing string translations. Also, you can use the plugin to export your strings to the
    395 Google Play Developer Console for translation, then download and import your translations back
    396 into your project. </p>
    397 
    398 <p>To access the Translation Editor, open a <code>strings.xml</code> file and click the
    399 <strong>Open Editor</strong> link.  </p>
    400 
    401     <img src="{@docRoot}images/tools/studio-translationeditoropen.png" />
    402     <p class="img-caption"><strong>Figure 11.</strong> Translation Editor</p>
    403 
    404 
    405 <h3> Editor support for the latest Android APIs</h3>
    406 <p>Android Studio supports the new
    407 <a href="{@docRoot}design/material/index.html">Material Design</a></li> themes, widgets, and
    408 graphics, such as shadow layers and API version rendering (showing the layout across different
    409 UI versions). Also, the new drawable XML tags and attributes, such as &lt;ripple&gt;
    410 and &lt;animated-selector&gt;, are supported.</p>
    411 
    412 
    413 <h3 id="git-samples"> Easy access to Android code samples on GitHub</h3>
    414 <p>Clicking <strong>Import Samples</strong> from the <strong>File</strong> menu or Welcome page
    415 provides seamless access to Google code samples on GitHub.</p>
    416     <p><img src="{@docRoot}images/tools/studio-samples-githubaccess.png" /></p>
    417     <p class="img-caption"><strong>Figure 12.</strong> Code Sample Access</p>
    418 
    419 
    420     <p><img src="{@docRoot}images/tools/studio-sample-in-editor.png" /></p>
    421     <p class="img-caption"><strong>Figure 13.</strong> Imported Code Sample</p>
    422 
    423 
    424