diff --git a/docs/html/images/tools/studio-allocationtracker.png b/docs/html/images/tools/studio-allocationtracker.png new file mode 100644 index 0000000000000..6c89af0e78651 Binary files /dev/null and b/docs/html/images/tools/studio-allocationtracker.png differ diff --git a/docs/html/images/tools/studio-api-version-rendering.png b/docs/html/images/tools/studio-api-version-rendering.png new file mode 100644 index 0000000000000..61933f124c8f6 Binary files /dev/null and b/docs/html/images/tools/studio-api-version-rendering.png differ diff --git a/docs/html/images/tools/studio-appeng-servlet.png b/docs/html/images/tools/studio-appeng-servlet.png new file mode 100644 index 0000000000000..b9d89e497f617 Binary files /dev/null and b/docs/html/images/tools/studio-appeng-servlet.png differ diff --git a/docs/html/images/tools/studio-bitmap-rendering.png b/docs/html/images/tools/studio-bitmap-rendering.png new file mode 100644 index 0000000000000..b15c987210005 Binary files /dev/null and b/docs/html/images/tools/studio-bitmap-rendering.png differ diff --git a/docs/html/images/tools/studio-cloudmodule.png b/docs/html/images/tools/studio-cloudmodule.png new file mode 100644 index 0000000000000..b7c4fb772c8d4 Binary files /dev/null and b/docs/html/images/tools/studio-cloudmodule.png differ diff --git a/docs/html/images/tools/studio-helloworld-design.png b/docs/html/images/tools/studio-helloworld-design.png new file mode 100644 index 0000000000000..ff90c6b198313 Binary files /dev/null and b/docs/html/images/tools/studio-helloworld-design.png differ diff --git a/docs/html/images/tools/studio-helloworld-text.png b/docs/html/images/tools/studio-helloworld-text.png new file mode 100644 index 0000000000000..5dde67537fe43 Binary files /dev/null and b/docs/html/images/tools/studio-helloworld-text.png differ diff --git a/docs/html/images/tools/studio-memory-monitor.png b/docs/html/images/tools/studio-memory-monitor.png new file mode 100644 index 0000000000000..796daf0841faa Binary files /dev/null and b/docs/html/images/tools/studio-memory-monitor.png differ diff --git a/docs/html/images/tools/studio-outputwindowmsgfiltering.png b/docs/html/images/tools/studio-outputwindowmsgfiltering.png new file mode 100644 index 0000000000000..a4715ee09956b Binary files /dev/null and b/docs/html/images/tools/studio-outputwindowmsgfiltering.png differ diff --git a/docs/html/images/tools/studio-previewall.png b/docs/html/images/tools/studio-previewall.png new file mode 100644 index 0000000000000..1b45e87503880 Binary files /dev/null and b/docs/html/images/tools/studio-previewall.png differ diff --git a/docs/html/images/tools/studio-project-layout.png b/docs/html/images/tools/studio-project-layout.png new file mode 100644 index 0000000000000..880c2336e8b56 Binary files /dev/null and b/docs/html/images/tools/studio-project-layout.png differ diff --git a/docs/html/images/tools/studio-projectview_scripts.png b/docs/html/images/tools/studio-projectview_scripts.png new file mode 100644 index 0000000000000..3e7b9cd873ab3 Binary files /dev/null and b/docs/html/images/tools/studio-projectview_scripts.png differ diff --git a/docs/html/images/tools/studio-samples-githubaccess.png b/docs/html/images/tools/studio-samples-githubaccess.png new file mode 100644 index 0000000000000..991bf6998eead Binary files /dev/null and b/docs/html/images/tools/studio-samples-githubaccess.png differ diff --git a/docs/html/images/tools/studio-setup-wizard.png b/docs/html/images/tools/studio-setup-wizard.png new file mode 100644 index 0000000000000..f84660a4c0de2 Binary files /dev/null and b/docs/html/images/tools/studio-setup-wizard.png differ diff --git a/docs/html/images/tools/studio-translationeditoropen.png b/docs/html/images/tools/studio-translationeditoropen.png new file mode 100644 index 0000000000000..bf17a1348e57e Binary files /dev/null and b/docs/html/images/tools/studio-translationeditoropen.png differ diff --git a/docs/html/images/tools/studio-tvwearsupport.png b/docs/html/images/tools/studio-tvwearsupport.png new file mode 100644 index 0000000000000..02bf484bdc40a Binary files /dev/null and b/docs/html/images/tools/studio-tvwearsupport.png differ diff --git a/docs/html/sdk/installing/studio-tips.jd b/docs/html/sdk/installing/studio-tips.jd index 03e29ca52d8a3..ba2db042022fc 100644 --- a/docs/html/sdk/installing/studio-tips.jd +++ b/docs/html/sdk/installing/studio-tips.jd @@ -1,56 +1,170 @@ page.title=Android Studio Tips and Tricks - @jd:body
-

See also

- + +

In this document

+
    +
  1. Productivity Features
  2. +
  3. Working with IntelliJ
  4. +
  5. Key Commands
  6. +
+ +

See also

+
    +
  1. Download Android Studio
  2. +
  3. IntelliJ IDEA Android Tutorials
  4. +
  5. IntelliJ FAQ on migrating to IntelliJ IDEA
  6. +
+
-

If you're unfamiliar with the IntelliJ IDEA interface, you might be wondering -how to accomplish some common tasks in Android Studio. This page provides some tips -to help you get going.

+

If you're unfamiliar with using Android Studio and the IntelliJ IDEA interface, this page +provides some tips to help you get started with some of the most common tasks and productivity +enhancements.

-

For complete user documentation for the IntelliJ IDEA interface -(upon which Android Studio is based), refer to the -IntelliJ IDEA documentation.

-
- -

Figure 1. Gradle project structure

-
+

Productivity Features

-

Project Structure

+

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. +

-

When you create a new project in Android Studio (or -migrate a project from Eclipse), -you'll notice that the project structure appears differently than you may be used to. -As shown in figure 1, almost all your project files are now inside the {@code src/} directory, -including resources and the manifest file.

-

The new project structure is due to the switch to a Gradle-based build system. This structure -provides more flexibility to the build process and will allow multiple build variants (a feature not -yet fully implemented). Everything still behaves as you expect, but some of the files have moved -around. For the most part, you should need to modify only the files under the {@code src/} -directory. More information about the Gradle project structure is available in the -Gradle -Plugin User Guide.

+

Smart Rendering

+

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 width and +height atttributes, Android Studio displays the rendering message Automatically +add all missing attributs. Clicking the message adds the missing attributes to the layout.

+ + +

Bitmap rendering in the debugger

+

While debugging, you can now right-click on bitmap variables in your app and invoke +View Bitmap. This fetches the associated data from the debugged process and renders +the bitmap in the debugger.

+

+

Figure 2. Bitmap Rendering

+ + +

Output window message filtering

+

When checking build results, you can filter messages by message type to quickly +locate messages of interest.

+ +

Figure 3. Filter Build Messages

+ + +

Hierarchical parent setting

+

The activity parent can now be set in the Activity Wizard when creating a new +activity. Setting a hierarchal parent 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 menu.xml file.

+ + +

Creating layouts

+

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.

+ +

While editing in the Text view, you can preview the layout on devices by +opening the Preview pane available on the right side of the window. Within the +Preview pane, you can modify the preview by changing various options at the top of the pane, +including the preview device, layout theme, platform version and more. To preview the layout on +multiple devices simultaneously, select Preview All Screen Sizes from the +device drop-down.

+

+

Figure 4. Preview All Screens

+ +

You can switch to the graphical editor by clicking Design at the +bottom of the window. While editing in the Design view, you can show and hide the +widgets available to drag-and-drop by clicking Palette on the left side of the +window. Clicking Designer on the right side of the window reveals a panel +with a layout hierarchy and a list of properties for each view in the layout.

+ + +

Working with IntelliJ

+ +

This section list just a few of the code editing +practices you should consider using when creating Android Studio apps.

+ +

For complete user documentation for the IntelliJ IDEA interface (upon which Android Studio +is based), refer to the +IntelliJ IDEA documentation.

-

Basic Operations

+

Alt + Enter key binding

+

For quick fixes to coding errors, the IntelliJ powered IDE implements the Alt + Enter +key binding to fix errors (missing imports, variable assignments, missing references, etc) when +possible, and if not, suggest the most probably solution.

-

The following topics describe how to perform -some basic development tasks with Android Studio.

+ +

Ctrl + D key binding

+

The Ctrl + D key binding is great for quickly duplicating code lines or fragments. +Simply select the desired line or fragment and enter this key binding.

+ + +

Navigate menu

+

In case you're not familiar with an API class, file or symbol, the Navigate menu lets +you jump directly to the class of a method or field name without having to search through +individual classes.

+ + +

Inspection scopes

+

Scopes set the color of code segments for easy code identification and location. For example, +you can set a scope to identify all code related to a specific action bar.

+ + + +

External annotations

+

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.

+ + + +

Injecting languages

+

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 statments.

+ + +

Code folding

+

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 +to make the outer class structure easier to read. The inner clas can be later expanded for +updates.

+ + +

Image and color preview

+

When referencing images and icons in your code, a preview of the image or icon appears +(in actual size at different densities) in the code margin to help you verify the image or icon +reference. Pressing {@code F1} with the preview image or icon selected displays resource asset +details, such as the dp settings.

+ + +

Quick F1 documentation

+

You can now inspect theme attributes using View > Quick Documentation +(F1), +see the theme inheritance hierarchy, and resolve values for the various attributes.

+ +

If you invoke View > Quick Documentation (usually bound to F1) on the theme +attribute ?android:textAppearanceLarge, you will see the theme inheritance hierarchy and +resolved values for the various attributes that are pulled in.

+ + +

New Allocation Tracker integration in the Android/DDMS window

+

You can now inspect theme attributes using View > Quick Documentation + F1, see the theme inheritance hierarchy, and resolved values for the +various attributes.

+ +

Figure 1. Allocation Tracker

+ + +

Keyboard Commands

+ +

The following tables list keyboard shortcuts for common operations.

Note: This section lists Android Studio keyboard shortcuts for the default keymap. To change the default keymap on Windows and Linux, go to @@ -58,85 +172,10 @@ for the default keymap. To change the default keymap on Windows and Linux, go to the default keymap on Mac OS X, go to Android Studio > Preferences > Keymap.

-

Creating virtual devices

- -

All the capabilities of the Android -Virtual Device Manager are accessible directly from -the Android Studio interface. Click the Android Virtual Device Manager - in the toolbar to open it and create -new virtual devices for running your app in the emulator.

- - -

Installing SDK updates

- -

The SDK Manager -is also accessible to download new Android tools, platforms, and libraries -for your app. Click the SDK Manager - in the toolbar to open it and check -for updates.

- - -

Creating new files

- -

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

- -

For example, if you select a layout directory, press ALT + INSERT on Windows, and select -Layout resource file, 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.

- - -

Creating layouts

- -

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.

- -

While editing in the Text view, you can preview the layout on devices by opening -the Preview pane available on the right side of the window. Within the -Preview pane, you can modify the preview by changing various options at the top of the pane, including -the preview device, layout theme, platform version and more. To preview the layout on multiple -devices simultaneously, select Preview All Screen Sizes from the device drop-down. -

- -

You can switch to the graphical editor by clicking Design at the -bottom of the window. While editing in the Design view, you can show and hide the -widgets available to drag-and-drop by clicking Palette on the -left side of the window. Clicking Designer on the right side of the window reveals -a panel with a layout hierarchy and a list of properties for each view in the layout.

- - -

Debugging

- -

When you build and run your app with Android Studio, you can view adb and device log messages -(logcat) in the DDMS pane by clicking Android at the bottom of the window.

- -

If you want to debug your app with the Android Debug Monitor, you can launch it by -clicking Monitor in the toolbar. The Debug Monitor is where -you can find the complete set of DDMS -tools for profiling your app, controlling device -behaviors, and more. It also includes the Hierarchy Viewer tools to help -optimize your layouts.

- - - - - -

Keyboard Commands

- -

The following tables list keyboard shortcuts for common operations.

-

Note: If you're using Mac OS X, update your keymap to use the Mac OS X 10.5+ version keymaps under Android Studio > Preferences > Keymap.

-

Table 1. Programming key commands

@@ -227,7 +266,6 @@ the Mac OS X 10.5+ version keymaps under Android Studio > Preferences >
ActionAndroid Studio Key Command
-

For a complete keymap reference guide, see the IntelliJ IDEA +

For a complete keymap reference guide, see the +IntelliJ IDEA documentation.

- diff --git a/docs/html/tools/studio/index.jd b/docs/html/tools/studio/index.jd new file mode 100644 index 0000000000000..f6c9d52687339 --- /dev/null +++ b/docs/html/tools/studio/index.jd @@ -0,0 +1,432 @@ +page.title=Android Studio +@jd:body + +
+ +
+ + + +
+

Video

+

What's New in Android Developer Tools

+
+
+
+
+ + +

Android Studio is a new Android development environment based on IntelliJ IDEA. It is the official +Android IDE. On top of the capabilities you expect from IntelliJ, Android Studio offers:

+ + + +

If you're ready, go here to get started with +Building Your First App.

+ +

If you're unfamiliar with the Android Studio or the IntelliJ IDEA interface, or just wondering +about what's new, you might be interested in exploring some common tasks before building your app. +

+ +

For starters, Android Studio installs with a basic hello world app to introduce you to +the basic Android Studio project structure and navigation. This section highlights the Android +Studio features.

+ + + +

Project and File Structure

+ +

Android Project View

+

By default, Android Studio displays your profile files in the Android project view. This +view shows a flattened version of your project's structure that provides quick access to the key +source files of Android projects and helps you work with the new +Gradle-based build system. +The Android project view:

+ + + + +

Figure 1: Show the Android project view.

+ +

Figure 2: Project Build Files.

+ +

The Android project view shows all the build files at the top level of the project +hierarchy under Gradle Scripts. Each project module appears as a folder at the +top level of the project hierarchy and contains these three elements at the top level:

+ + + +

For example, Android project view groups all the instances of the +ic_launcher.png resource for different screen densities under the same element.

+ +

Note: The project structure on disk differs from this flattened +representation. To switch to back the segregated project view, select Project from +the Project + + + +

New Project and Directory Structure

+

When you use the Project view of a new project in Android Studio or +( a project migrated from Eclipse), you +should notice that the project structure appears different than you may be used to. Each +instance of Android Studio contains a project with one or more application modules. Each +application module folder contains the complete source sets for that module, including +{@code src/main} and {@code src/androidTest} directories, resources, build +file and the Android manifest. For the most part, you will need to modify the files under each +module's {@code src/main} directory for source code updates, the gradle.build file for build +specification and the files under {@code src/androidTest} directory for test case creation. + +

+

Figure 3. Android Studio project structure

+ +

For more information, see IntelliJ project organization and +Managing Projects.

+ + +

Creating new files

+

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

+ +

For example, if you select a layout directory, press ALT + INSERT on Windows, +and select Layout resource file, 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.

+ + + +

Android Build System

+ +

Android Build System

+

The Android build system is the toolkit you use to build, test, run and package +your apps. This build system replaces the Ant system used with Eclipse ADT. It can run as an +integrated tool from the Android Studio menu and independently from the command line. You can use +the features of the build system to:

+ + + +

The flexibility of the Android build system enables you to achieve all of this without +modifying your app's core source files. To build an Android Studio project, see +Building and Running from Android Studio. +To configure custom build settings in an Android Studio project, see +Configure Android Studio Builds.

+ + +

Application ID for Package Identification

+

With the Android build system, the applicationId attribute is used to +uniquely identify application packages for publishing. The application ID is set in the +android section of the build.gradle file. +

+ +
+    apply plugin: 'com.android.application'
+
+    android {
+        compileSdkVersion 19
+        buildToolsVersion "19.1"
+
+    defaultConfig {
+        applicationId "com.example.my.app"
+        minSdkVersion 15
+        targetSdkVersion 19
+        versionCode 1
+        versionName "1.0"
+    }
+    ...
+    
+ +

Note: The applicationId is specified only in your +build.gradle file, and not in the AndroidManifest.xml file.

+ +

When using build variants, the build system enables you to 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.

+ +
+   productFlavors {
+        pro {
+            applicationId = "com.example.my.pkg.pro"
+        }
+        free {
+            applicationId = "com.example.my.pkg.free"
+        }
+    }
+
+    buildTypes {
+        debug {
+            applicationIdSuffix ".debug"
+        }
+    }
+    ....
+   
+ +

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.

+ +
+   
+   package="com.example.app">
+   
+ +

Note: If you have multiple manifests (for exmample, 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 src/main/ folder.

+ +

For more information about the build files and process, see +Build System Overview.

+ + + + +

Debug and Performance

+ + +

Android Virtual Device (AVD) Manager

+

AVD Manager has updated screens with links to help you select the most popular device +configurations, screen sizes and resolutions for your app previews.

+Click the Android Virtual Device Manager + in the toolbar to open it and create +new virtual devices for running your app in the emulator.

+ +

The AVD Manager comes with emulators for Nexus 6 and Nexus 9 devices and also supports +creating custom Android device skins based on specific emulator properties and assigning those +skins to hardware profiles. Android Studio installs the the Intel x86 Emulator Accelerator (HAXM) +and creates a default emulator for quick app prototyping.

+ +

For more information, see Managing AVDs.

+ + + +

Memory Monitor

+

Android Studio provides a memory monitor view so you can more easily monitor your +app's memory usage to find deallocated objects, locate memory leaks and track the amount of +memory the connected device is using. With your app running on a device or emulator, click the +Memory Monitor tab in the lower right corner to launch the memory monitor.

+ + +

Figure 5. Memory Monitor

+ + + +

New Lint inspections

+

Lint has several new checks to ensure: +

+ +

Hovering over a Lint error displays the full issue explanation inline for easy error +resolution. There is also a helpful hyperlink at the end of the error message for additional +error information.

+ +

With Android Studio, you can run Lint for a specific build variant, or for all build variants. +You can configure Lint by adding a lintOptions property to the Android settings in the +build.gradle file.

+ +
+    android {
+        lintOptions {
+           // set to true to turn off analysis progress reporting by lint
+           quiet true
+           // if true, stop the gradle build if errors are found
+           abortOnError false
+           // if true, only report errors
+           ignoreWarnings true
+    
+ +

For more information, see +Improving Your Code with Lint.

+ + +

Dynamic layout preview

+

Android Studio allows you to work with layouts in both a Design View

+

+

+

Figure 6. Hello World App with Design View

+ +

and a Text View.

+ +

+ Figure 7. Hello World App with Text View

+ +

Easily select and preview layout changes for different device images, display +densities, UI modes, locales, and Android versions (multi-API version rendering). +

+

Figure 11. API Version Rendering

+ + +

From the Design View, you can drag and drop elements from the Palette to the Preview or +Component Tree. The Text View allows you to directly edit the XML settings, while previewing +the device display.

+ + +

Log messages

+

When you build and run your app with Android Studio, you can view adb and device log messages +(logcat) in the DDMS pane by clicking Android at the bottom of the window.

+ +

If you want to debug your app with the +Android Debug Monitor, you can launch it by +clicking Monitor + +in the toolbar. The Debug Monitor is where you can find the complete set of +DDMS tools for profiling your app, +controlling device behaviors, and more. It also includes the Hierarchy Viewer tools to help + optimize your layouts.

+ + + + +

Installation, Setup, and Update Management

+ +

Android Studio installation and setup wizards

+

An updated installation and setup wizards walk you through a step-by-step installation +and setup process as the wizard checks for system requirements, such as the Java Development +Kit (JDK) and available RAM, and then prompts for optional installation options, such as the +Intel ® HAXM accelerator.

+ +

An updated setup wizard walks you through the setup processes as +the wizard updates your system image and emulation requirements, such GPU, and then creates +an optimized default Android Virtual Device (AVD) based on Android 5 (Lollipop) for speedie and +reliable emulation.

+

+

Figure 10. Setup Wizard

+ + +

Expanded template and form factor support

+

Android Studio supports new templates for Google Services and expands the availabe device +types.

+ +

Android Wear and TV support

+

For easy cross-platform development, the Project Wizard provides new templates for + creating your apps for Android Wear and TV.

+

+

Figure 8. New Form Factors

+

During app creation, the Project Wizard also displays an API Level dialog to help you choose + the best minSdkVersion for your project.

+ + +

Google App Engine integration (Google Cloud Platform/Messaging)

+

Quick cloud integration. Using Google App Engine to connect to the Google cloud + and create a cloud end-point is as easy as selecting File > New Module > App Engine Java + Servlet Module and specifying the module, package, and client names.

+

+

Figure 9. Setup Wizard

+ + + +

Update channels

+

Android Studio provides four update channels to keep Android Studio up-to-date based on your +code-level preference: +

+

+ +

By default, Android Studio uses the Stable channel. Use +File > Settings > Updates to change your channel setting.

+ + + +

Other Highlights/h2> + +

Translation Editor

+

Multi-language support is enhanced with the Translation Editor plugin so you can easily add +locales to the app's translation file. Color codes indicate whether a locale is complete or +still missing string translations. Also, you can use the plugin to export your strings to the +Google Play Developer Console for translation, then download and import your translations back +into your project.

+ +

To access the Translation Editor, open a strings.xml file and click the +Open Editor link.

+ + +

Figure 4. Translation Editor

+ + +

Editor support for the latest Android APIs

+

Android Studio supports the new +Material Design themes, widgets, and +graphics, such as shadow layers and API version rendering (showing the layout across different +UI versions). Also, the new drawable XML tags and attributes, such as <ripple> +and <animated-selector>, are supported.

+ + +

Easy access to Android code samples on GitHub

+

Clicking Import Samples from the File menu or Welcome page +provides seamless access to Google code samples on GitHub.

+

+

Figure 12. Code Sample Access/p> + diff --git a/docs/html/tools/tools_toc.cs b/docs/html/tools/tools_toc.cs index cd10f1d0a97b8..7efbf47829aa7 100644 --- a/docs/html/tools/tools_toc.cs +++ b/docs/html/tools/tools_toc.cs @@ -13,27 +13,21 @@ -

+ + + + + +