1page.title=Features
2page.metaDescription=Learn about the Android Studio features.
3page.tags=studio, features
4@jd:body
5
6<div id="qv-wrapper">
7<div id="qv">
8
9    <h2>In this document</h2>
10    <ol>
11      <li><a href="#trans-editor">Translations Editor</a></li>
12      <li><a href="#git-samples">Android Code Samples on GitHub</a></li>
13      <li><a href="#template-support">Expanded Template and Form Factor Support</a></li>
14      <li><a href="#project-settings">Android Studio and Project Settings</a></li>
15      <li><a href="#finger-print">Fingerprint Support</a></li>
16      <li><a href="#dev-services">Developer Services</a></li>
17      <li><a href="#private-res">Public and Private Resources</a></li>
18      <li><a href="#support-apis">Editor Support for the Latest Android APIs</a></li>
19      <li><a href="#test-module">Test APK Module</a></li>
20    </ol>
21
22  <h2>See also</h2>
23  <ol>
24    <li><a href="{@docRoot}tools/workflow/index.html">Workflow</a></li>
25    <li><a href="{@docRoot}sdk/installing/studio-build.html">Build System</a></li>
26    <li><a href="{@docRoot}sdk/installing/studio-tips.html">Android Studio Tip & Tricks</a></li>
27  </ol>
28
29</div>
30</div>
31
32
33<p>If you're new to Android Studio or exploring recent updates, this
34page provides an introduction to some key Android Studio features.</p>
35
36<p>For specific Android Studio how-to documentation, see the pages in the <a href=
37"{@docRoot}tools/workflow/index.html">Workflow</a> section, such as
38<a href="{@docRoot}sdk/installing/create-project.html">Managing Projects from Android Studio</a>
39and
40<a href="{@docRoot}tools/building/building-studio.html">Building and Running from Android Studio</a>. </p>
41
42
43
44<h2 id="trans-editor">Translations Editor</h2>
45<p>Multi-language support is enhanced with the Translations Editor plugin so you can easily add
46a variety of locales to the app's translation file. With
47<a class="external-link" href="https://tools.ietf.org/html/bcp47">BCP 47</a> support, the editor
48combines language and
49region codes into a single selection for targeted localizations. Color codes indicate whether a
50locale is complete or still missing string translations. </p>
51
52<p>To access the Translations Editor, open a <code>strings.xml</code> file and click the
53<strong>Open Editor</strong> link, or click the globe icon
54(<img src="{@docRoot}images/tools/studio-globe-icon.png" style="vertical-align:bottom;margin:0;height:19px" />) in the Design layout view.  </p>
55
56
57    <img src="{@docRoot}images/tools/studio-translationeditoropen.png" />
58    <p class="img-caption"><strong>Figure 1.</strong> Add locales and strings in the
59    Translations Editor.</p>
60
61
62
63<h2 id="git-samples">Android Code Samples on GitHub</h2>
64<p>Clicking <strong>Import Samples</strong> from the <strong>File</strong> menu or <em>Welcome</em>
65page provides seamless access to Google code samples on GitHub.</p>
66    <p><img src="{@docRoot}images/tools/studio-samples-githubaccess.png" /></p>
67    <p class="img-caption"><strong>Figure 2.</strong> Get code samples from GitHub.</p>
68
69
70    <p><img src="{@docRoot}images/tools/studio-sample-in-editor.png" /></p>
71    <p class="img-caption"><strong>Figure 3.</strong> Imported code sample.</p>
72
73
74
75<h2 id="template-support">Expanded Template and Form Factor Support</h2>
76<p>Android Studio supports templates for Google Services and expands the available device
77types. </p>
78
79    <h4> Android Wear and TV support</h4>
80    <p>For easy cross-platform development, the Project Wizard provides templates for
81    creating your apps for Android Wear and TV. </p>
82    <p><img src="{@docRoot}images/tools/studio-tvwearsupport.png"  />
83
84      <p class="img-caption"><strong>Figure 4.</strong> Supported form factors.</p>
85    <p>During app creation, the Project Wizard also displays an API Level dialog to help you choose
86    the best <em>minSdkVersion</em> for your project.</p>
87
88
89    <h4> Google App Engine integration (Google Cloud Platform/Messaging)</h4>
90    <p>Quick cloud integration. Using Google App Engine to connect to the Google cloud
91    and create a cloud end-point is as easy as selecting <em>File > New Module > App Engine Java
92    Servlet Module</em> and specifying the module, package, and client names. </p>
93    <p><img src="{@docRoot}images/tools/studio-cloudmodule.png" /></p>
94    <p class="img-caption"><strong>Figure 5</strong> Google App Engine integration.</p>
95
96
97<h2 id="project-settings">Android Studio and Project Settings</h2>
98<p>Android Studio provides setting dialogs so you can manage the most important Android Studio and
99project settings from the <strong>File &gt; Project Structure</strong> and
100<strong>File &gt; Settings</strong> menus. For example, you can use the
101<strong>File &gt; Project Structure</strong> menu or
102the <code>build.gradle</code> file to update your <code>productFlavor</code> settings.
103Additional settings from the <strong>File &gt; Project Structure</strong> menus include:
104<ul>
105 <li>SDK and JDK location </li>
106 <li>SDK version </li>
107 <li>Gradle and Android Plugin for Gradle versions </li>
108 <li>Build tools version </li>
109 <li>Multidex setting</li>
110 <li><code>buildTypes</code> </li>
111 <li>Dependencies </li>
112</ul>
113</p>
114
115<p>Use the <strong>File &gt; Settings</strong> menu to modify the Android Studio or project
116behavior, such a UI themes, system settings, and version control. </p>
117
118
119
120<h2 id="finger-print">Fingerprint Support</h2>
121<p>Android Studio provides the {@code finger} command, allowing you to simulate, and thus validate,
122fingerprint authentication for your app. After you set up your app to accept
123<a href="https://developer.android.com/preview/api-overview.html#authentication">fingerprint
124authentication</a>, your emulator or device should display the fingerprint authentication screen,
125as shown below. </p>
126
127    <p><img src="{@docRoot}images/tools/studio-fingerprint.png" /></p>
128    <p class="img-caption"><strong>Figure 6</strong> Fingerprint authentication.</p>
129
130<p>Open a terminal session, and telnet to the emulator. For example:</p>
131<pre>
132{@code telnet localhost 5554}
133</pre>
134
135<p>Enter the <code>finger</code> command to simulate finger touch and removal: </p>
136
137<ul>
138   <li><code>finger touch &lt;fingerprint-id&gt;</code> to simulate a finger touching the sensor</li>
139   <li><code>finger remove</code> to simulate finger removal </li>
140</ul>
141
142<p>Your app should respond as if a user touched, and then removed their finger from, the
143fingerprint sensor. </p>
144
145
146<h2 id="dev-services">Developer Services</h2>
147<p>Android Studio supports enabling these developer services in your app: </p>
148<ul>
149  <li>Ads using <a href="https://developers.google.com/admob/">AdMob</a></li>
150  <li>Analytics <a href="https://developers.google.com/analytics/">Google Analytics</a></li>
151  <li>Authentication using <a href="https://developers.google.com/identity/sign-in/android/">Google
152    Sign-in</a> </li>
153  <li>Notifications using <a href="https://developers.google.com/cloud-messaging/">Google
154    Cloud Messaging</a> </li>
155</ul>
156
157<p>Enabling a developer service adds the required dependencies and, when applicable, also modifies
158the related configuration files. To activate the service, you must perform
159service-specific updates, such as loading an ad in the <code>MainActivity</code> class for ad
160display.</p>
161
162<p>To enable an Android developer service, select the <code>File &gt; Project Structure</code>
163menu option and click a service under the <em>Developer Services</em> sub-menu. The service
164configuration page appears. In the service configuration page, click the service check box to
165enable the service and click <strong>OK</strong>. Android Studio updates your library dependencies
166for the selected service and, for Analytics, updates the <code>AndroidManifest.xml</code> and
167other tracker configuration files. You can enable multiple services within the same app. For more
168detail about starting the services, refer to each service's specific activation instructions. </p>
169
170
171
172<h2 id="private-res">Public and Private Resources</h2>
173<p>By default, Android Studio treats all library resources as public: A public library resource is
174available to library clients for use outside the library, and appears in code completion suggestions
175and other resource references. Android Studio also, however, supports the use of private library
176resources. A private library resource can only be used within the source library, and does not
177appear in code completion lists and other resource references. </p>
178
179<p>You cannot explicitly declare a library resource as private. Instead, if you declare any library
180resources as public, Android Studio assumes all the other library resources are private. </p>
181
182<p>An app treats all Android library resources as public unless you explicitly declare at least one
183resource in the library as public. Declaring one public resource causes your app to treat all other,
184undeclared resources in the library as private. </p>
185
186<p class="note"><strong>Note:</strong> Declaring public and private resources requires the
187<a href="{@docRoot}tools/building/plugin-for-gradle.html">Android Plugin for Gradle</a> version
1881.3 or higher. </p>
189
190
191<p>To declare a resource as public and set other undeclared resources as private, add a
192<code>&lt;public&gt;</code> declaration with the resource name and type in the resource file.
193This example shows the public declaration for the <code>mylib_app_name</code> string resource. </p>
194
195<pre>
196&lt;resources&gt;
197    &lt;public name="mylib_app_name" type="string"/&gt;
198&lt;/resources&gt;
199</pre>
200
201<p>For large numbers of declarations, we recommended that you place the public marker declarations
202in a separate file named <code>public.xml</code>. </p>
203
204<p>To help enforce private resource access, a <a href="{@docRoot}tools/help/lint.html">lint</a>
205warning appears when a client of a library references a private resource. Many Android libraries,
206such as the
207<a href="{@docRoot}tools/support-library/features.html#design">Design Support Library</a> and the
208<a href="{@docRoot}tools/support-library/features.html#v7-appcompat">v7 appcompat Library</a>,
209declare public resources to display only resources that developers can directly reference.
210</p>
211
212<p class="note"><strong>Note:</strong> If your app requires a private resource, copy the
213private resource from the library to the location in your app where it is needed. </p>
214
215<p>When the build system builds an Android Archive (AAR) file, it extracts the
216<code>&lt;public&gt;</code> resource declarations into a <code>public.txt</code> file, which is
217packaged inside the AAR file next to the <code>R.txt</code> file. The <code>public.txt</code> file
218contains a simple list of the declared public resources, describing their names and types. </p>
219
220<p>For a complete list of the available Android resource types, see
221<a href="http://developer.android.com/guide/topics/resources/available-resources.html">Resource
222Types</a></li> and
223<a href="http://developer.android.com/guide/topics/resources/more-resources.html">More Resource
224Types</a></li>. </p>
225
226
227
228<h2 id="support-apis">Editor Support for the Latest Android APIs</h2>
229<p>Android Studio supports the
230<a href="{@docRoot}design/material/index.html">Material Design</a></li> themes, widgets, and
231graphics, such as shadow layers and API version rendering (showing the layout across different
232UI versions). Also, the drawable XML tags and attributes, such as <code>&lt;ripple&gt;</code>
233and <code>&lt;animated-selector&gt;</code>, are supported.</p>
234
235
236
237<h2 id="test-module">Test APK Module</h2>
238<p>Android Studio supports adding a separate <code>test</code> module to your app so you can
239generate a test APK. This <code>test</code> module resides at the same level as your app and
240contains: the tests and instrumentation used to run the test APK on an Android device; an
241<code>Android Manifest.xml</code> file for test APK configuration settings; and, a
242<code>build.gradle</code> file for build settings.</p>
243
244<p>The <code>test</code> module cannot contain a <code>src/androidTest/</code> folder and does
245not support build variants. If you have different product flavors in your main application APK,
246create a different test module for each build variant.</p>
247
248
249<p>To create a test APK module:
250
251<ul>
252  <li>Use the <strong>File &gt; New &gt; Module</strong> menu option to create a
253    <code>test</code> module consisting of the following directories and files:
254    <ul>
255      <li><code>./test/</code> </li>
256      <li><code>./test/build.gradle</code> </li>
257      <li><code>./test/src/main/java/com/android/tests/basic/MainTest.java</code> </li>
258      <li><code>./test/src/main/AndroidManifest.xml</code> </li>
259    </ul>
260  </li>
261  <li>In the <code>build.gradle</code> file, add the required properties to the
262    <code>android</code> block.
263    <ul>
264      <li><code>targetProjectPath ':&lt;app name&gt;'</code> specifies the main application APK
265        to test. </li>
266      <li><code>targetVariant ':&lt;buildType&gt;'</code> specifies the target build type.</li>
267    </ul>
268    <p>Here is an example of <code>build.gradle</code> file property settings: </p>
269
270<pre>
271android {
272    compileSdkVersion 19
273    buildToolsVersion = ‘21.1.3’
274
275    targetProjectPath ':app'
276    targetVariant 'debug'
277}
278</pre>
279  </li>
280  <li>Define the instrumentation entries in the manifest file.
281    <p>Here is an example of <code>&lt;instrumentation&gt;</code> settings in the manifest file: </p>
282
283<pre>
284&lt;?xml version="1.0" encoding="utf-8"?&gt;
285&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
286      package="com.android.tests.basic.test"&gt;
287
288      &lt;uses-sdk android:minSdkVersion="16" android:targetSdkVersion="16" /&gt;
289
290      &lt;application>
291            &gt;uses-library android:name="android.test.runner" /&gt;
292      &lt;/application>
293
294      &lt;instrumentation android:name="android.test.InstrumentationTestRunner"
295                       android:targetPackage="com.android.tests.basic"
296                       android:handleProfiling="false"
297                       android:functionalTest="false"
298                       android:label="Tests for com.android.tests.basic"/&gt;
299&lt;/manifest&lt;
300</pre>
301
302<p class="note"><strong>Note:</strong> The <code>targetPackage</code> in the instrumentation
303settings specifies the package of the test variant. </p>
304
305   </li>
306   <li>In the <code>build.gradle</code> file for the tested app, include additional artifacts
307     that the test APK requires, such as the <code> classes.jar</code> file, by adding the
308     {@code publishNonDefault} property to the {@code Android} block, and assigning that property
309     a value of {@code true}.
310     <p>Here is an example of the <code>build.gradle</code> file that includes additional
311     artifacts: </p></li>
312<pre>
313android {
314    compileSdkVersion 19
315    buildToolsVersion = ‘21.1.3’
316
317    publishNonDefault true
318}
319</pre>
320 </li>
321</ul>
322
323
324<p>In the {@code test} module in this example, the {@code build.gradle} file specifies the
325properties for the project path and target build type variant. </p>
326
327    <p><img src="{@docRoot}images/tools/studio-test-module.png" /></p>
328    <p class="img-caption"><strong>Figure 3.</strong> Test module for APK testing.</p>
329
330
331<p class="note"><strong>Note:</strong> By default, the test module's build variant uses the
332<code>debug</code> build type. You can configure additional build types using the
333<code>testBuildType</code> property in the <code>defaultConfig</code> block in the main
334app's <code>build.gradle</code> file. </p>
335
336
337