clarifications to the Java 8 dependencies in preview setup.
Add JDK location screenshot. More information about the Emulator 2.0 in the testing doc. Style edits to the Java 8 features doc. Change-Id: I0c9c74c1e378f43901bd37e70ea68d9e88720adb
This commit is contained in:
@@ -188,14 +188,13 @@ This is the Android SDK Preview License Agreement (the “License Agreement”).
|
||||
|
||||
|
||||
|
||||
<p>To run the Android N Preview so you can test your apps, you can either
|
||||
<p>To run the Android N Preview and test your apps, you can either
|
||||
install the Android N Preview on one of several supported devices or run it on
|
||||
the Android Emulator.</p>
|
||||
|
||||
<p>Simply installing your app onto Android N this way does not require
|
||||
any changes to your app source code. If, however, you want to update your
|
||||
app to use new Android N APIs and Java 8 language features,
|
||||
then you need to download Android Studio 2.1 (preview) as described in
|
||||
app to use new Android N APIs, see
|
||||
<a href="{@docRoot}preview/setup-sdk.html">Set Up to Develop for Android N</a>.
|
||||
|
||||
|
||||
@@ -221,22 +220,19 @@ then you need to download Android Studio 2.1 (preview) as described in
|
||||
|
||||
<h3 id="ota">Get over-the-air updates</h3>
|
||||
|
||||
<p>
|
||||
You can receive preview versions of Android on compatible devices by
|
||||
enrolling them in the Android Beta Program. Once you enroll a device in
|
||||
this program, it receives preview versions of Android over-the-air (OTA).
|
||||
These updates are automatically downloaded and can installed just like
|
||||
official updates.
|
||||
</p>
|
||||
<p>You can receive over-the-air updates to preview versions of Android by
|
||||
enrolling your compatible device in the Android Beta Program.
|
||||
These updates are automatically downloaded and will update your device just like
|
||||
official system updates.</p>
|
||||
|
||||
<p>
|
||||
For more information on the Android Beta Program and to enroll devices, see
|
||||
For more information and to enroll your device, see
|
||||
the <a href="https://g.co/androidbeta">Android Beta Program</a> web site.
|
||||
</p>
|
||||
|
||||
<p class="warning">
|
||||
<strong>Warning:</strong> If you enroll a device for receiving a preview
|
||||
version of Android, and then later opt-out of receiving those updates on
|
||||
<strong>Warning:</strong> If you enroll a device in the Android Beta Program,
|
||||
then later opt-out of receiving updates on
|
||||
the device, all user data on that device will be removed.
|
||||
</p>
|
||||
|
||||
@@ -247,7 +243,7 @@ then you need to download Android Studio 2.1 (preview) as described in
|
||||
the updates yourself, you can download the appropriate system image for your
|
||||
device from the table below.</p>
|
||||
|
||||
<p>The process of installing a system image on a device <em>removes all data
|
||||
<p>Installing a system image on a device <em>removes all data
|
||||
from the device</em>, so you should back up your data before installing a
|
||||
system image.</p>
|
||||
|
||||
@@ -355,8 +351,8 @@ preview system image, you must perform another manual installation.
|
||||
</p>
|
||||
|
||||
<p class="warning">
|
||||
<strong>Warning:</strong> Installing a factory image causes all user data on
|
||||
the device to be removed.
|
||||
<strong>Warning:</strong> Just like when flashing a preview image,
|
||||
installing a factory image removes all user data on the device.
|
||||
</p>
|
||||
|
||||
|
||||
@@ -364,13 +360,13 @@ preview system image, you must perform another manual installation.
|
||||
|
||||
<h2 id="setupAVD">Use the Emulator</h2>
|
||||
|
||||
<p>To use the Android Emulator to run the Android N Preview you need to download
|
||||
the Android N Preview SDK and create a virtual device for the emulator.
|
||||
</p>
|
||||
<p>To use the Android Emulator to run the Android N Preview, you need to
|
||||
download the Android N Preview SDK and create a virtual device for the
|
||||
emulator.</p>
|
||||
|
||||
<p>First, download the Android N Preview SDK as follows (if you
|
||||
already got it while <a href="{@docRoot}preview/setup-sdk.html">setting up
|
||||
Android Studio 2.1</a>, you can skip this part):
|
||||
to develop for Android N</a>, you can skip this part):
|
||||
|
||||
<ol>
|
||||
<li>In Android Studio, open the Settings dialog
|
||||
@@ -404,12 +400,21 @@ Android Studio 2.1</a>, you can skip this part):
|
||||
then click <strong>Next</strong>.</li>
|
||||
<li>Select the <strong>N</strong> system image (with the
|
||||
<strong>x86</strong> ABI), then click <strong>Next</strong>.
|
||||
(Only x86 system images are currently supported with the Android Emulator
|
||||
for the Android N Preview.)
|
||||
<li>Complete the rest of the AVD configuration and click
|
||||
<strong>Finish</strong>.</li>
|
||||
</ol>
|
||||
|
||||
<p>You can now launch the Android Emulator with the Android N Preview AVD.</p>
|
||||
|
||||
<p class="note"><strong>Note:</strong>
|
||||
For the best experience in the Android Emulator, install
|
||||
Android Studio 2.1 Preview, which supports the <a
|
||||
href="http://tools.android.com/tech-docs/emulator">Android Emulator 2.0 Beta</a>
|
||||
with much faster performance compared to the Emulator in
|
||||
Android Studio 1.5.</p>
|
||||
|
||||
<p>For more information about creating virtual devices, see <a href=
|
||||
"{@docRoot}tools/devices/index.html">Managing Virtual Devices</a>.
|
||||
</p>
|
||||
|
||||
BIN
docs/html/preview/images/studio-jdk-location.jpg
Normal file
BIN
docs/html/preview/images/studio-jdk-location.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 81 KiB |
@@ -1,61 +1,41 @@
|
||||
page.title=Using Java 8 Language Features
|
||||
page.title=Java 8 Language Features
|
||||
page.keywords="android N", "Java 8", "Jack"
|
||||
@jd:body
|
||||
|
||||
<div id="qv-wrapper">
|
||||
<div id="qv">
|
||||
<h2>
|
||||
In this document
|
||||
</h2>
|
||||
|
||||
<ol>
|
||||
<li>
|
||||
<a href="#supported-features">Supported Java 8 Language Features and APIs</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="#configuration">Enabling Java 8 Features and the Jack Toolchain</a>
|
||||
</li>
|
||||
</ol>
|
||||
|
||||
<h2>
|
||||
See also
|
||||
</h2>
|
||||
|
||||
<ol>
|
||||
<li>
|
||||
<a class="external-link" href=
|
||||
"https://source.android.com/source/jack.html">Jack (Java Android Compiler
|
||||
Kit)</a>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p>Android N introduces support for Java 8 language features
|
||||
that you can use when developing apps that target the Android N. To start using
|
||||
these features, you need to download and set up Android Studio 2.1 (preview)
|
||||
and the Android N Preview SDK, which includes the required Jack toolchain and
|
||||
updated Android Plugin for Gradle.</p>
|
||||
|
||||
<p>If you haven't yet installed the Android N Preview SDK, follow the guide to
|
||||
<a href="{@docRoot}preview/setup-sdk.html">Set Up to Develop for Android
|
||||
N</a>.</p>
|
||||
|
||||
|
||||
<p>
|
||||
This document describes the new language features supported in the Android N
|
||||
that you can use when developing apps that target Android N.
|
||||
This page describes the new language features supported in the Android N
|
||||
Preview, how to properly set up your project to use them, and any known
|
||||
issues you may encounter.
|
||||
</p>
|
||||
|
||||
<p>To start using these features, you need to download and set up Android
|
||||
Studio 2.1 (preview) and the Android N Preview SDK, which includes the required
|
||||
Jack toolchain and updated Android Plugin for Gradle. If you haven't yet
|
||||
installed the Android N Preview SDK, see <a href=
|
||||
"{@docRoot}preview/setup-sdk.html">Set Up to Develop for Android N</a>.</p>
|
||||
|
||||
|
||||
|
||||
<p class="note">
|
||||
<strong>Note:</strong> Using the new Java 8 language features is not a
|
||||
requirement for developing apps that target the Android N Preview. After
|
||||
following the set up instructions in the <a href=
|
||||
"{@docRoot}preview/setup-sdk.html">Preview guide</a>, you may use
|
||||
the Java 7 language features already supported by Android 6.0 (API level 23)
|
||||
and below.
|
||||
requirement for developing apps that target the Android N platform. If you
|
||||
don't want to write code with Java 8 language features, you can keep your
|
||||
project's source and target compatibility values set to Java 7, but you still
|
||||
must compile with JDK 8 to build against the Android N platform.
|
||||
</p>
|
||||
|
||||
<h2 id="supported-features">
|
||||
@@ -64,8 +44,8 @@ N</a>.</p>
|
||||
|
||||
<p>
|
||||
Android does not currently support all Java 8 language features. However, the
|
||||
following features are now available when developing apps targeting the N
|
||||
Developer Preview:
|
||||
following features are now available when developing apps targeting the
|
||||
Android N Preview:
|
||||
</p>
|
||||
|
||||
<ul>
|
||||
@@ -90,8 +70,7 @@ N</a>.</p>
|
||||
|
||||
|
||||
<p>
|
||||
Additionally, the following Java 8 language feature APIs are now available
|
||||
with the Preview:
|
||||
Additionally, the following Java 8 language feature APIs are now available:
|
||||
</p>
|
||||
|
||||
<ul>
|
||||
@@ -143,18 +122,20 @@ N</a>.</p>
|
||||
new <a class="external-link" href=
|
||||
"https://source.android.com/source/jack.html">Jack toolchain</a>. This new
|
||||
Android toolchain compiles Java language source into Android-readable dex
|
||||
bytecode, has its own {@code .jack} library format, and provides most tool chain
|
||||
bytecode, has its own {@code .jack} library format, and provides most toolchain
|
||||
features as part of a single tool: repackaging, shrinking, obfuscation and
|
||||
multidex.
|
||||
</p>
|
||||
|
||||
<p>Here we compare the two toolchains used to build Android DEX files:</p>
|
||||
<p>Here is a comparison the two toolchains used to build Android DEX files:</p>
|
||||
<ul>
|
||||
<li>Legacy: javac ({@code .java} > {@code .class}) > dx ({@code
|
||||
.class} > {@code .dex})
|
||||
<li>Legacy javac toolchain:<br>
|
||||
<b>javac</b> ({@code .java} --> {@code .class}) --> <b>dx</b> ({@code
|
||||
.class} --> {@code .dex})
|
||||
</li>
|
||||
|
||||
<li>Modern: Jack ({@code .java} > {@code .jack} > {@code .dex})
|
||||
<li>New Jack toolchain:<br>
|
||||
<b>Jack</b> ({@code .java} --> {@code .jack} --> {@code .dex})
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -169,9 +150,9 @@ N</a>.</p>
|
||||
|
||||
<pre>
|
||||
android {
|
||||
...
|
||||
defaultConfig {
|
||||
...
|
||||
defaultConfig {
|
||||
...
|
||||
jackOptions {
|
||||
enabled true
|
||||
}
|
||||
@@ -192,19 +173,17 @@ android {
|
||||
with Jack and will be disabled while using the new toolchain.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Since Jack does not generate intermediate class files when compiling an app,
|
||||
tools that depend on these files do not currently work with Jack. Some examples of
|
||||
these tools are:
|
||||
</p>
|
||||
<p>Because Jack does not generate intermediate class files when compiling an
|
||||
app, tools that depend on these files do not currently work with Jack. Some
|
||||
examples of these tools are:</p>
|
||||
|
||||
<ul>
|
||||
<li>Lint detectors that operate on class files
|
||||
</li>
|
||||
|
||||
<li>Tools and libraries that require the app’s class files (e.g. JaCoCo and Mockito)
|
||||
</li>
|
||||
<li>Tools and libraries that require the app’s class files (such as JaCoCo
|
||||
and Mockito)</li>
|
||||
</ul>
|
||||
|
||||
If you find other problems while using Jack, <a class="external-link" href=
|
||||
"http://tools.android.com/filing-bugs">please report bugs</a>.
|
||||
<p>If you find other problems while using Jack, <a href=
|
||||
"http://tools.android.com/filing-bugs">please report bugs</a>.</p>
|
||||
@@ -25,7 +25,7 @@ page.image=images/cards/card-n-sdk_2x.png
|
||||
<p>To develop apps for the Android N Preview, you need to make some updates
|
||||
to your developer environment, as described on this page.</p>
|
||||
|
||||
<p>To instead simply test your app's compatibility on the
|
||||
<p>To simply test your app's compatibility on the
|
||||
Android N system image, follow the guide to <a
|
||||
href="{@docRoot}preview/download.html">Test on an Android N Device</a>.</p>
|
||||
|
||||
@@ -34,11 +34,14 @@ href="{@docRoot}preview/download.html">Test on an Android N Device</a>.</p>
|
||||
|
||||
<h2 id="get-as13">Get Android Studio 2.1 (preview)</h2>
|
||||
|
||||
<p>The Android N platform adds support for Java 8 language features,
|
||||
which are supported only with a new compiler called Jack. The latest Jack
|
||||
compiler is currently supported only in Android Studio 2.1. So if you want to
|
||||
use Java 8 language features, then you need to use Android Studio 2.1 to
|
||||
build your app.
|
||||
<p>The Android N platform adds support for <a
|
||||
href="{@docRoot}preview/j8-jack.html">Java 8 language features</a>,
|
||||
which require a new compiler called Jack. The latest version of Jack
|
||||
is currently supported only in Android Studio 2.1. So if you want to
|
||||
use Java 8 language features, you need to use Android Studio 2.1 to
|
||||
build your app. Otherwise, you don't need to use the Jack compiler, but you
|
||||
still need to update to JDK 8 to compile against the Android N platform,
|
||||
as described below.
|
||||
</p>
|
||||
|
||||
<iframe width="400" height="225" src="//www.youtube.com/embed/SBbWGxXCMqQ?autohide=1&showinfo=0" frameborder="0" allowfullscreen="" style="float: right; margin: 0 0 20px 20px;"></iframe>
|
||||
@@ -47,8 +50,8 @@ build your app.
|
||||
release channel. If you already
|
||||
have Android Studio and don't want to update to the canary channel, you can
|
||||
download Android Studio 2.1 as a separate installation and use it
|
||||
with Android N, leaving your primary Android Studio environment
|
||||
unaffected.</p>
|
||||
for development with Android N, leaving your primary Android Studio
|
||||
environment unaffected.</p>
|
||||
|
||||
<p>To download Android Studio 2.1 as a separate installation, follow these
|
||||
steps (or if you want to receive Android Studio 2.1 as an update to your
|
||||
@@ -85,8 +88,8 @@ existing installation, skip to step 4):</p>
|
||||
Android N Preview SDK in Android Studio as follows:</p>
|
||||
|
||||
<ol>
|
||||
<li>While still viewing the Updates panel from the previous
|
||||
procedure, select the <strong>Automatically
|
||||
<li>While still viewing the Updates panel (step 4 from above),
|
||||
select the <strong>Automatically
|
||||
check updates for Android SDK</strong> check box and select
|
||||
<strong>Preview Channel</strong> from the drop-down list.
|
||||
</li>
|
||||
@@ -109,7 +112,6 @@ Android N Preview SDK in Android Studio as follows:</p>
|
||||
</li>
|
||||
</ol>
|
||||
|
||||
|
||||
<h3 id="docs-dl">Get the N Preview reference documentation</h3>
|
||||
|
||||
<p>
|
||||
@@ -140,25 +142,32 @@ Android N Preview SDK in Android Studio as follows:</p>
|
||||
|
||||
<h2 id="java8">Get the Java 8 JDK and JRE</h2>
|
||||
|
||||
<p>You also need to update your JDK for Java 8 and install the
|
||||
Java 8 Runtime Environment (JRE) to run some
|
||||
tools included in Android Studio 2.1. So, if you don't have the latest
|
||||
version of each already, download JDK 8 and JRE 8 now.</p>
|
||||
<p>To compile your app against the Android N platform, you need to use
|
||||
the Java 8 Developer Kit (JDK 8), and in order to use some tools with Android
|
||||
Studio 2.1, you need to install the Java 8 Runtime Environment (JRE 8). So, if
|
||||
you don't have the latest version of each already, download JDK 8 and JRE 8
|
||||
now.</p>
|
||||
|
||||
<p>With Java 8 installed, set the JDK version in Android Studio as follows:</p>
|
||||
<p>Then set the JDK version in Android Studio as follows:</p>
|
||||
|
||||
<ol>
|
||||
<li>Open an Android project in Android Studio, then open the
|
||||
Project Structure dialog by selecting <strong>File >
|
||||
Project Structure</strong>.
|
||||
Project Structure</strong>. (Alternatively, you can set the default
|
||||
for all projects by selecting <strong>File > Other Settings >
|
||||
Default Project Structure</strong>.)
|
||||
</li>
|
||||
<li>In the left panel of the dialog, click <strong>SDK Location</strong>.
|
||||
</li>
|
||||
<li>In the <strong>JDK Location</strong> field, enter the location of the
|
||||
Java 8 JDK, then click <strong>OK</strong>.
|
||||
Java 8 JDK (click the button on the right
|
||||
to browse your files), then click <strong>OK</strong>.
|
||||
</li>
|
||||
</ol>
|
||||
|
||||
<img src="{@docRoot}preview/images/studio-jdk-location.jpg" width="700"
|
||||
alt="" />
|
||||
|
||||
|
||||
<h2 id="create-update">Update or Create a Project</h2>
|
||||
|
||||
@@ -166,10 +175,10 @@ Android N Preview SDK in Android Studio as follows:</p>
|
||||
To use the Android N APIs, your project must be configured appropriately.
|
||||
</p>
|
||||
|
||||
<p>If you plan to use Java 8 language features, you should read
|
||||
<a href="{@docRoot}preview/j8-jack.html">Using Java 8 Language Features</a>
|
||||
for information about how to configure your project and the supported
|
||||
Java 8 features.</p>
|
||||
<p>If you plan to use Java 8 language features, you should also read
|
||||
<a href="{@docRoot}preview/j8-jack.html">Java 8 Language Features</a>
|
||||
for information about the supported Java 8 features and
|
||||
how to configure your project with the Jack compiler.</p>
|
||||
|
||||
|
||||
<h3 id="update">Update an existing project</h3>
|
||||
@@ -186,7 +195,6 @@ android {
|
||||
...
|
||||
|
||||
defaultConfig {
|
||||
...
|
||||
minSdkVersion <strong>'N'</strong>
|
||||
targetSdkVersion <strong>'N'</strong>
|
||||
...
|
||||
|
||||
Reference in New Issue
Block a user