| page.title=Features |
| page.metaDescription=Learn about the Android Studio features. |
| page.tags=studio, features |
| @jd:body |
| |
| <div id="qv-wrapper"> |
| <div id="qv"> |
| |
| <h2>In this document</h2> |
| <ol> |
| <li><a href="#trans-editor">Translations Editor</a></li> |
| <li><a href="#git-samples">Android Code Samples on GitHub</a></li> |
| <li><a href="#template-support">Expanded Template and Form Factor Support</a></li> |
| <li><a href="#project-settings">Android Studio and Project Settings</a></li> |
| <li><a href="#finger-print">Fingerprint Support</a></li> |
| <li><a href="#dev-services">Developer Services</a></li> |
| <li><a href="#private-res">Public and Private Resources</a></li> |
| <li><a href="#support-apis">Editor Support for the Latest Android APIs</a></li> |
| <li><a href="#test-module">Test APK Module</a></li> |
| </ol> |
| |
| <h2>See also</h2> |
| <ol> |
| <li><a href="{@docRoot}tools/workflow/index.html">Workflow</a></li> |
| <li><a href="{@docRoot}sdk/installing/studio-build.html">Build System</a></li> |
| <li><a href="{@docRoot}sdk/installing/studio-tips.html">Android Studio Tip & Tricks</a></li> |
| </ol> |
| |
| </div> |
| </div> |
| |
| |
| <p>If you're new to Android Studio or exploring recent updates, this |
| page provides an introduction to some key Android Studio features.</p> |
| |
| <p>For specific Android Studio how-to documentation, see the pages in the <a href= |
| "{@docRoot}tools/workflow/index.html">Workflow</a> section, such as |
| <a href="{@docRoot}sdk/installing/create-project.html">Managing Projects from Android Studio</a> |
| and |
| <a href="{@docRoot}tools/building/building-studio.html">Building and Running from Android Studio</a>. </p> |
| |
| |
| |
| <h2 id="trans-editor">Translations Editor</h2> |
| <p>Multi-language support is enhanced with the Translations Editor plugin so you can easily add |
| a variety of locales to the app's translation file. With |
| <a class="external-link" href="https://tools.ietf.org/html/bcp47">BCP 47</a> support, the editor |
| combines language and |
| region codes into a single selection for targeted localizations. Color codes indicate whether a |
| locale is complete or still missing string translations. </p> |
| |
| <p>To access the Translations Editor, open a <code>strings.xml</code> file and click the |
| <strong>Open Editor</strong> link, or click the globe icon |
| (<img src="{@docRoot}images/tools/studio-globe-icon.png" style="vertical-align:bottom;margin:0;height:19px" />) in the Design layout view. </p> |
| |
| |
| <img src="{@docRoot}images/tools/studio-translationeditoropen.png" /> |
| <p class="img-caption"><strong>Figure 1.</strong> Add locales and strings in the |
| Translations Editor.</p> |
| |
| |
| |
| <h2 id="git-samples">Android Code Samples on GitHub</h2> |
| <p>Clicking <strong>Import Samples</strong> from the <strong>File</strong> menu or <em>Welcome</em> |
| page provides seamless access to Google code samples on GitHub.</p> |
| <p><img src="{@docRoot}images/tools/studio-samples-githubaccess.png" /></p> |
| <p class="img-caption"><strong>Figure 2.</strong> Get code samples from GitHub.</p> |
| |
| |
| <p><img src="{@docRoot}images/tools/studio-sample-in-editor.png" /></p> |
| <p class="img-caption"><strong>Figure 3.</strong> Imported code sample.</p> |
| |
| |
| |
| <h2 id="template-support">Expanded Template and Form Factor Support</h2> |
| <p>Android Studio supports templates for Google Services and expands the available device |
| types. </p> |
| |
| <h4> Android Wear and TV support</h4> |
| <p>For easy cross-platform development, the Project Wizard provides templates for |
| creating your apps for Android Wear and TV. </p> |
| <p><img src="{@docRoot}images/tools/studio-tvwearsupport.png" /> |
| |
| <p class="img-caption"><strong>Figure 4.</strong> Supported form factors.</p> |
| <p>During app creation, the Project Wizard also displays an API Level dialog to help you choose |
| the best <em>minSdkVersion</em> for your project.</p> |
| |
| |
| <h4> Google App Engine integration (Google Cloud Platform/Messaging)</h4> |
| <p>Quick cloud integration. Using Google App Engine to connect to the Google cloud |
| and create a cloud end-point is as easy as selecting <em>File > New Module > App Engine Java |
| Servlet Module</em> and specifying the module, package, and client names. </p> |
| <p><img src="{@docRoot}images/tools/studio-cloudmodule.png" /></p> |
| <p class="img-caption"><strong>Figure 5</strong> Google App Engine integration.</p> |
| |
| |
| <h2 id="project-settings">Android Studio and Project Settings</h2> |
| <p>Android Studio provides setting dialogs so you can manage the most important Android Studio and |
| project settings from the <strong>File > Project Structure</strong> and |
| <strong>File > Settings</strong> menus. For example, you can use the |
| <strong>File > Project Structure</strong> menu or |
| the <code>build.gradle</code> file to update your <code>productFlavor</code> settings. |
| Additional settings from the <strong>File > Project Structure</strong> menus include: |
| <ul> |
| <li>SDK and JDK location </li> |
| <li>SDK version </li> |
| <li>Gradle and Android Plugin for Gradle versions </li> |
| <li>Build tools version </li> |
| <li>Multidex setting</li> |
| <li><code>buildTypes</code> </li> |
| <li>Dependencies </li> |
| </ul> |
| </p> |
| |
| <p>Use the <strong>File > Settings</strong> menu to modify the Android Studio or project |
| behavior, such a UI themes, system settings, and version control. </p> |
| |
| |
| |
| <h2 id="finger-print">Fingerprint Support</h2> |
| <p>Android Studio provides the {@code finger} command, allowing you to simulate, and thus validate, |
| fingerprint authentication for your app. After you set up your app to accept |
| <a href="https://developer.android.com/preview/api-overview.html#authentication">fingerprint |
| authentication</a>, your emulator or device should display the fingerprint authentication screen, |
| as shown below. </p> |
| |
| <p><img src="{@docRoot}images/tools/studio-fingerprint.png" /></p> |
| <p class="img-caption"><strong>Figure 6</strong> Fingerprint authentication.</p> |
| |
| <p>Open a terminal session, and telnet to the emulator. For example:</p> |
| <pre> |
| {@code telnet localhost 5554} |
| </pre> |
| |
| <p>Enter the <code>finger</code> command to simulate finger touch and removal: </p> |
| |
| <ul> |
| <li><code>finger touch <fingerprint-id></code> to simulate a finger touching the sensor</li> |
| <li><code>finger remove</code> to simulate finger removal </li> |
| </ul> |
| |
| <p>Your app should respond as if a user touched, and then removed their finger from, the |
| fingerprint sensor. </p> |
| |
| |
| <h2 id="dev-services">Developer Services</h2> |
| <p>Android Studio supports enabling these developer services in your app: </p> |
| <ul> |
| <li>Ads using <a href="https://developers.google.com/admob/">AdMob</a></li> |
| <li>Analytics <a href="https://developers.google.com/analytics/">Google Analytics</a></li> |
| <li>Authentication using <a href="https://developers.google.com/identity/sign-in/android/">Google |
| Sign-in</a> </li> |
| <li>Notifications using <a href="https://developers.google.com/cloud-messaging/">Google |
| Cloud Messaging</a> </li> |
| </ul> |
| |
| <p>Enabling a developer service adds the required dependencies and, when applicable, also modifies |
| the related configuration files. To activate the service, you must perform |
| service-specific updates, such as loading an ad in the <code>MainActivity</code> class for ad |
| display.</p> |
| |
| <p>To enable an Android developer service, select the <code>File > Project Structure</code> |
| menu option and click a service under the <em>Developer Services</em> sub-menu. The service |
| configuration page appears. In the service configuration page, click the service check box to |
| enable the service and click <strong>OK</strong>. Android Studio updates your library dependencies |
| for the selected service and, for Analytics, updates the <code>AndroidManifest.xml</code> and |
| other tracker configuration files. You can enable multiple services within the same app. For more |
| detail about starting the services, refer to each service's specific activation instructions. </p> |
| |
| |
| |
| <h2 id="private-res">Public and Private Resources</h2> |
| <p>By default, Android Studio treats all library resources as public: A public library resource is |
| available to library clients for use outside the library, and appears in code completion suggestions |
| and other resource references. Android Studio also, however, supports the use of private library |
| resources. A private library resource can only be used within the source library, and does not |
| appear in code completion lists and other resource references. </p> |
| |
| <p>You cannot explicitly declare a library resource as private. Instead, if you declare any library |
| resources as public, Android Studio assumes all the other library resources are private. </p> |
| |
| <p>An app treats all Android library resources as public unless you explicitly declare at least one |
| resource in the library as public. Declaring one public resource causes your app to treat all other, |
| undeclared resources in the library as private. </p> |
| |
| <p class="note"><strong>Note:</strong> Declaring public and private resources requires the |
| <a href="{@docRoot}tools/building/plugin-for-gradle.html">Android Plugin for Gradle</a> version |
| 1.3 or higher. </p> |
| |
| |
| <p>To declare a resource as public and set other undeclared resources as private, add a |
| <code><public></code> declaration with the resource name and type in the resource file. |
| This example shows the public declaration for the <code>mylib_app_name</code> string resource. </p> |
| |
| <pre> |
| <resources> |
| <public name="mylib_app_name" type="string"/> |
| </resources> |
| </pre> |
| |
| <p>For large numbers of declarations, we recommended that you place the public marker declarations |
| in a separate file named <code>public.xml</code>. </p> |
| |
| <p>To help enforce private resource access, a <a href="{@docRoot}tools/help/lint.html">lint</a> |
| warning appears when a client of a library references a private resource. Many Android libraries, |
| such as the |
| <a href="{@docRoot}tools/support-library/features.html#design">Design Support Library</a> and the |
| <a href="{@docRoot}tools/support-library/features.html#v7-appcompat">v7 appcompat Library</a>, |
| declare public resources to display only resources that developers can directly reference. |
| </p> |
| |
| <p class="note"><strong>Note:</strong> If your app requires a private resource, copy the |
| private resource from the library to the location in your app where it is needed. </p> |
| |
| <p>When the build system builds an Android Archive (AAR) file, it extracts the |
| <code><public></code> resource declarations into a <code>public.txt</code> file, which is |
| packaged inside the AAR file next to the <code>R.txt</code> file. The <code>public.txt</code> file |
| contains a simple list of the declared public resources, describing their names and types. </p> |
| |
| <p>For a complete list of the available Android resource types, see |
| <a href="http://developer.android.com/guide/topics/resources/available-resources.html">Resource |
| Types</a></li> and |
| <a href="http://developer.android.com/guide/topics/resources/more-resources.html">More Resource |
| Types</a></li>. </p> |
| |
| |
| |
| <h2 id="support-apis">Editor Support for the Latest Android APIs</h2> |
| <p>Android Studio supports the |
| <a href="{@docRoot}design/material/index.html">Material Design</a></li> themes, widgets, and |
| graphics, such as shadow layers and API version rendering (showing the layout across different |
| UI versions). Also, the drawable XML tags and attributes, such as <code><ripple></code> |
| and <code><animated-selector></code>, are supported.</p> |
| |
| |
| |
| <h2 id="test-module">Test APK Module</h2> |
| <p>Android Studio supports adding a separate <code>test</code> module to your app so you can |
| generate a test APK. This <code>test</code> module resides at the same level as your app and |
| contains: the tests and instrumentation used to run the test APK on an Android device; an |
| <code>Android Manifest.xml</code> file for test APK configuration settings; and, a |
| <code>build.gradle</code> file for build settings.</p> |
| |
| <p>The <code>test</code> module cannot contain a <code>src/androidTest/</code> folder and does |
| not support build variants. If you have different product flavors in your main application APK, |
| create a different test module for each build variant.</p> |
| |
| |
| <p>To create a test APK module: |
| |
| <ul> |
| <li>Use the <strong>File > New > Module</strong> menu option to create a |
| <code>test</code> module consisting of the following directories and files: |
| <ul> |
| <li><code>./test/</code> </li> |
| <li><code>./test/build.gradle</code> </li> |
| <li><code>./test/src/main/java/com/android/tests/basic/MainTest.java</code> </li> |
| <li><code>./test/src/main/AndroidManifest.xml</code> </li> |
| </ul> |
| </li> |
| <li>In the <code>build.gradle</code> file, add the required properties to the |
| <code>android</code> block. |
| <ul> |
| <li><code>targetProjectPath ':<app name>'</code> specifies the main application APK |
| to test. </li> |
| <li><code>targetVariant ':<buildType>'</code> specifies the target build type.</li> |
| </ul> |
| <p>Here is an example of <code>build.gradle</code> file property settings: </p> |
| |
| <pre> |
| android { |
| compileSdkVersion 19 |
| buildToolsVersion = ‘21.1.3’ |
| |
| targetProjectPath ':app' |
| targetVariant 'debug' |
| } |
| </pre> |
| </li> |
| <li>Define the instrumentation entries in the manifest file. |
| <p>Here is an example of <code><instrumentation></code> settings in the manifest file: </p> |
| |
| <pre> |
| <?xml version="1.0" encoding="utf-8"?> |
| <manifest xmlns:android="http://schemas.android.com/apk/res/android" |
| package="com.android.tests.basic.test"> |
| |
| <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="16" /> |
| |
| <application> |
| >uses-library android:name="android.test.runner" /> |
| </application> |
| |
| <instrumentation android:name="android.test.InstrumentationTestRunner" |
| android:targetPackage="com.android.tests.basic" |
| android:handleProfiling="false" |
| android:functionalTest="false" |
| android:label="Tests for com.android.tests.basic"/> |
| </manifest< |
| </pre> |
| |
| <p class="note"><strong>Note:</strong> The <code>targetPackage</code> in the instrumentation |
| settings specifies the package of the test variant. </p> |
| |
| </li> |
| <li>In the <code>build.gradle</code> file for the tested app, include additional artifacts |
| that the test APK requires, such as the <code> classes.jar</code> file, by adding the |
| {@code publishNonDefault} property to the {@code Android} block, and assigning that property |
| a value of {@code true}. |
| <p>Here is an example of the <code>build.gradle</code> file that includes additional |
| artifacts: </p></li> |
| <pre> |
| android { |
| compileSdkVersion 19 |
| buildToolsVersion = ‘21.1.3’ |
| |
| publishNonDefault true |
| } |
| </pre> |
| </li> |
| </ul> |
| |
| |
| <p>In the {@code test} module in this example, the {@code build.gradle} file specifies the |
| properties for the project path and target build type variant. </p> |
| |
| <p><img src="{@docRoot}images/tools/studio-test-module.png" /></p> |
| <p class="img-caption"><strong>Figure 3.</strong> Test module for APK testing.</p> |
| |
| |
| <p class="note"><strong>Note:</strong> By default, the test module's build variant uses the |
| <code>debug</code> build type. You can configure additional build types using the |
| <code>testBuildType</code> property in the <code>defaultConfig</code> block in the main |
| app's <code>build.gradle</code> file. </p> |
| |
| |