Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ddc61010 authored by Rich Slogar's avatar Rich Slogar Committed by Android Git Automerger
Browse files

am 755cc17a: Merge "Merge commit \'88c0af88\' into mnc-dev..." into mnc-dev

* commit '755cc17a':
  docs: Studio 1.3 new install and feature sections
parents 6fe87a56 755cc17a
Loading
Loading
Loading
Loading
+710 B
Loading image diff...
−36.9 KiB
Loading image diff...
+138 −131
Original line number Diff line number Diff line
@@ -4,9 +4,16 @@ page.title=Android Studio Tips and Tricks
<div id="qv-wrapper">
<div id="qv">

    <h2>In this document</h2>
    <ol>
      <li><a href="#productivity-features">Productivity Shortcuts</a></li>
      <li><a href="#intellij">Working with IntelliJ</a></li>
      <li><a href="#key-commands">Key Commands</a></li>
    </ol>

  <h2>See also</h2>
  <ol>
    <li><a href="{@docRoot}tools/sdk/index.html">Download Android Studio</a></li>
    <li><a href="{@docRoot}sdk/index.html">Download Android Studio</a></li>
    <li><a href="http://wiki.jetbrains.net/intellij/Android">IntelliJ IDEA Android Tutorials</a></li>
    <li><a href="http://confluence.jetbrains.com/display/IntelliJIDEA/FAQ+on+Migrating+to+IntelliJ+IDEA">IntelliJ FAQ on migrating to IntelliJ IDEA</a></li>
  </ol>
@@ -19,36 +26,55 @@ provides some tips to help you get started with some of the most common tasks an
enhancements. </p>


     <h2>Smart Rendering</h2>
<h2 id="productivity-features">Productivity Shortcuts</h2>

<p>Android Studio includes a number of features to help you be more productive in your coding.
This section notes a few of the key features to help you work quickly and efficiently.
</p>


<h3>Smart Rendering</h3>
<p>With smart rendering, Android Studio displays links for quick fixes to rendering errors.
For example, if you add a button to the layout without specifying the <em>width</em> and
<em>height</em> attributes, Android Studio displays the rendering message <em>Automatically
add all missing attributes</em>. Clicking the message adds the missing attributes to the layout.</p>


     <h2> Bitmap rendering in the debugger</h2>
<h3> Bitmap rendering in the debugger</h3>
<p>While debugging, you can now right-click on bitmap variables in your app and invoke
<em>View Bitmap</em>. This fetches the associated data from the debugged process and renders
the bitmap in the debugger. </p>
<p><img src="{@docRoot}images/tools/studio-bitmap-rendering.png" style="width:350px"/></p>
    <p class="img-caption"><strong>Figure 13.</strong> Bitmap Rendering/p>
<p class="img-caption"><strong>Figure 1.</strong> Bitmap Rendering</p>


<h3>Creating new files</h3>
<p>You can quickly add new code and resource files by clicking the appropriate directory in the
<strong>Project</strong> pane and pressing <code>ALT + INSERT</code> on Windows and Linux or
<code>COMMAND + N</code> on Mac. Based on the type of directory selected, Android Studio
offers to create the appropriate file type.</p>

<p>For example, if you select a layout directory, press <code>ALT + INSERT</code> on Windows,
and select <strong>Layout resource file</strong>, a dialog opens so you can name the file
(you can exclude the {@code .xml} suffix) and choose a root view element. The editor then
switches to the layout design editor so you can begin designing your layout.</p>

     <h2>Output window message filtering</h2>

<h3>Output window message filtering</h3>
<p>When checking build results, you can filter messages by <em>message type</em> to quickly
locate messages of interest.</p>
<img src="{@docRoot}images/tools/studio-outputwindowmsgfiltering.png" style="width:200px"style="width:200px" />
     <p class="img-caption"><strong>Figure 14.</strong> Filter Build Messages</p>
<p class="img-caption"><strong>Figure 2.</strong> Filter Build Messages</p>


    <h2>Hierarchical parent setting</h2>
<h3>Hierarchical parent setting</h3>
<p>The activity parent can now be set in the Activity Wizard when creating a new
activity. Setting a <em>hierarchal parent</em> sets the {@code Up} button to automatically
appear in the app's Action bar when viewing a child activity, so the {@code Up}
button no longer needs to be manually specified in the <em>menu.xml</em> file.</p>


    <h2>Creating layouts</h2>
<h3>Creating layouts</h3>
<p>Android Studio offers an advanced layout editor that allows you to drag-and-drop widgets
into your layout and preview your layout while editing the XML.</p>

@@ -59,7 +85,7 @@ enhancements. </p>
multiple devices simultaneously, select <strong>Preview All Screen Sizes</strong> from the
device drop-down.</p>
<p><img src="{@docRoot}images/tools/studio-previewall.png" style="width:350px"/></p>
    <p class="img-caption"><strong>Figure 15.</strong> Preview All Screens/p>
<p class="img-caption"><strong>Figure 3.</strong> Preview All Screens</p>

<p>You can switch to the graphical editor by clicking <strong>Design</strong> at the
bottom of the window. While editing in the Design view, you can show and hide the
@@ -71,12 +97,15 @@ enhancements. </p>
<h3>Annotations</h3>
<p>Android Studio provides coding assistance for using annotations from the
{@link android.support.annotation Support-Annotations} library, part of the
   Support Repository. Adding a dependency for this library enables you to decorate your code with
   annotations to help catch bugs, such as null pointer exceptions and resource type conflicts.
   You can also create enumerated annotations to, for example, check that a passed parameter value
   matches a value from a defined set of constants. For more information, see
Support Repository.

Adding a dependency for this library enables you to decorate your code with annotations to help
catch bugs, such as null pointer exceptions and resource type conflicts. You can also create
enumerated annotations to, for example, check that a passed parameter value matches a value from
a defined set of constants. For more information, see
<a href="{@docRoot}tools/debugging/annotations.html#annotations">Improving Code Inspection with
   Annotations</a>. </p>
Annotations</a>.
</p>


<h3>Java class decompiling</h3>
@@ -94,8 +123,8 @@ enhancements. </p>
<h3>Debugging and performance enhancements</h3>
<p>Android Studio offers debugging and performance enhancements such as:</p>
<ul>
    <li>Auto detect an expanded set of code styles. To modify the current code style, choose
      <strong>File &gt; Settings &gt; Code Styles</strong>.  </li>
  <li>Custom keymaps. To modify the current keymap, choose
   <strong>File &gt; Settings &gt; Keymap</strong>.  </li>
  <li>Support for high density (Retina) displays on Windows and Linux.  </li>
  <li>Scratch files for quick prototyping without creating any project files.
   <p>Choose <strong>Tools &gt; New Scratch File</strong> to open a scratch file to quickly
@@ -108,7 +137,7 @@ enhancements. </p>



<h2 id="intellij">Working with IntelliJ-based Coding Practices</h2>
<h2 id="intellij">Working with IntelliJ-based Coding Practices</h3>

<p>This section list just a few of the code editing
practices you should consider using when creating Android Studio apps. </p>
@@ -117,6 +146,7 @@ enhancements. </p>
is based), refer to the
<a href="http://www.jetbrains.com/idea/documentation/index.jsp">IntelliJ IDEA documentation</a>.</p>


<h3><em>Alt + Enter</em> key binding</h3>
<p>For quick fixes to coding errors, the IntelliJ powered IDE implements the <em>Alt + Enter</em>
key binding to fix errors (missing imports, variable assignments, missing references, etc) when
@@ -127,6 +157,7 @@ enhancements. </p>
<p>The <em>Ctrl + D</em> key binding is great for quickly duplicating code lines or fragments.
Simply select the desired line or fragment and enter this key binding. </p>


<h3>Navigate menu</h3>
<p>In case you're not familiar with an API class, file or symbol, the <em>Navigate</em> menu lets
you jump directly to the class of a method or field name without having to search through
@@ -138,19 +169,13 @@ enhancements. </p>
you can set a scope to identify all code related to a specific action bar.   </p>



    <h3>External annotations</h3>
    <p>Specify annotations within the code or from an external annotation file. The Android Studio
    IDE keeps track of the restrictions and validates compliance, for example setting the data type
    of a string as not null.</p>


<h3>Injecting languages</h3>
<p>With language injection, the Android Studio IDE allows you to work with islands of different
languages embedded in the source code. This extends the syntax, error highlighting and coding
assistance to the embedded language. This can be especially useful for checking regular expression
values inline, and validating XML and SQL statements.</p>


<h3>Code folding</h3>
<p>This allows you to selectively hide and display sections of the code for readability. For
example, resource expressions or code for a nested class can be folded or hidden in to one line
@@ -176,16 +201,6 @@ enhancements. </p>



     <h3>New Allocation Tracker integration in the Android/DDMS window</h3>
     <p>You can now inspect theme attributes using <strong> View > Quick Documentation
     </strong> <code>F1</code>, see the theme inheritance hierarchy, and resolved values for the
     various attributes.</p>
      <img src="{@docRoot}images/tools/studio-allocationtracker.png" style="width:300px" />
      <p class="img-caption"><strong>Figure 16</strong> Allocation Tracker</p>




<h3 id="key-commands">Keyboard Commands</h3>

<p>The following tables list keyboard shortcuts for common operations.</p>
@@ -288,13 +303,5 @@ using Mac OS X, update your keymap to use the Mac OS X 10.5+ version keymaps und
</table>

<p>For a complete keymap reference guide, see the
<a href="http://www.jetbrains.com/idea/documentation/index.jsp">IntelliJ IDEA</a> documentation.</p>


</div>


</div>


<a href="http://www.jetbrains.com/idea/documentation/index.jsp">IntelliJ IDEA</a>
documentation.</p>
+69 −0
Original line number Diff line number Diff line
@@ -198,6 +198,75 @@ settings from the Android SDK installation. Android Studio adds the module-speci
<code>proguard-rules.pro</code> at the root of the module, where you can add custom ProGuard
rules.</p>



<h3>Application ID for package identification </h3>
<p>With the Android build system, the <em>applicationId</em> attribute is used to
uniquely identify application packages for publishing. The application ID is set in the
<em>android</em> section of the <code>build.gradle</code> file.
</p>

    <pre>
    apply plugin: 'com.android.application'

    android {
        compileSdkVersion 19
        buildToolsVersion "19.1"

    defaultConfig {
        <strong>applicationId "com.example.my.app"</strong>
        minSdkVersion 15
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
    }
    ...
    </pre>

<p class="note"><strong>Note:</strong> The <em>applicationId</em> is specified only in your
{@code build.gradle} file, and not in the AndroidManifest.xml file.</p>

<p>When using build variants, the build system enables you to uniquely identify different
packages for each product flavors and build types. The application ID in the build type is added as
a suffix to those specified for the product flavors. </p>

   <pre>
   productFlavors {
        pro {
            applicationId = "com.example.my.pkg.pro"
        }
        free {
            applicationId = "com.example.my.pkg.free"
        }
    }

    buildTypes {
        debug {
            applicationIdSuffix ".debug"
        }
    }
    ....
   </pre>

<p>The package name must still be specified in the manifest file. It is used in your source code
to refer to your R class and to resolve any relative activity/service registrations. </p>

   <pre>
   <?xml version="1.0" encoding="utf-8"?>
   <manifest xmlns:android="http://schemas.android.com/apk/res/android"
   <strong>package="com.example.app"</strong>>
   </pre>

<p class="note"><strong>Note:</strong> If you have multiple manifests (for example, a product
flavor specific manifest and a build type manifest), the package name is optional in those manifests.
If it is specified in those manifests, the package name must be identical to the package name
specified in the manifest in the <code>src/main/</code> folder. </p>

<p>For more information about the build files and process, see
<a href="{@docRoot}sdk/installing/studio-build.html">Build System Overview</a>.</p>



<h3 id="configureSigning">Configure signing settings</h3>

<p>The debug and the release versions of the app differ on whether the application can be
+7 −316

File changed.

Preview size limit exceeded, changes collapsed.

Loading