Android Studio 2.0 (2016 年 4 月)
注意:如果您是為 N 開發人員預覽版進行開發作業,請使用 Android Studio 2.1 預先發布版。Android Studio 2.0 版不支援指定 N 預覽版所需的所有功能。
Instant Run:
- Android Studio 現在能夠用比以往更快的速度部署清理建構作業。此外,您現在可以近乎即時的速度將漸進式程式碼變更推送至模擬器或實體裝置,而且可以查看更新內容,不必重新部署新的偵錯版本,在多數情況下甚至不必重新啟動應用程式。
<li>Instant Run supports pushing the following changes to a running app:
<ul>
<li>Changes to the implementation of an existing instance method or
static method
</li>
<li>Changes to an existing app resource
</li>
<li>Changes to structural code, such as a method signature or a static
field (requires a target device running API level 21 or higher).
</li>
</ul>
</li>
<li>Read the documentation to learn more <a href=
"/tools/building/building-studio.html#instant-run">about Instant
Run</a>.
<p class="note">
<strong>Note:</strong> Instant Run is supported only when you deploy the
debug build variant, use <a href=
"/tools/revisions/gradle-plugin.html#revisions">Android plugin for
Gradle version 2.0.0</a> or higher, and configure your app's module-level
<code>build.gradle</code> file for <code>minSdkVersion 15</code> or higher.
For the best performance, configure your app for <code>minSdkVersion
21</code> or higher.
</p>
</li>
Lint 新增項目:
- 現在可以使用
@IntDef
加註整數檢查switch
陳述式,確保系統會處理所有常數。如要快速新增任何缺少的陳述式,請使用意圖動作下拉式選單並選取「Add Missing @IntDef Constants」。 - 如果使用字串內插類型在
build.gradle
檔案中插入版本號碼,系統會針對這類錯誤加上標記。 - 擴充
Fragment
類別的匿名類別會加上標記。 - 如果原生程式碼在不安全的位置 (例如
res/
和asset/
資料夾),系統會加上標記。這個標記可鼓勵使用者將原生程式碼儲存在libs/
資料夾,接著系統會在安裝期間,將該程式碼安全地封裝至應用程式的data/app-lib/
資料夾。Android 開放原始碼計畫:#169950 - 不安全的
Runtime.load()
和System.load()
呼叫會加上標記。Android 開放原始碼計畫:#179980 - 從選單列中依序選取「Refactor」>「Remove Unused Resources」,即可尋找並移除任何未使用的資源。未使用資源偵測功能現在支援僅由未使用資源所參照的資源、原始檔案中的參照 (例如
.html
圖片參照),以及 Gradle 資源縮減器使用的tools:keep
和tools:discard
屬性,同時會將未使用的來源集 (例如其他變種版本中使用的資源) 納入考量,並妥善處理靜態欄位匯入項目。 - 系統可檢查透過
minSdkVersion
指定的所有平台是否都支援隱式 API 參考資料。 - 不當的
RecyclerView
和Parcelable
使用情形會加上標記。 - 系統現在也會檢查
@IntDef
、@IntRange
和@Size
是否含有int
陣列和變數引數。
其他改進項目:
- Android Emulator 2.0 版經過最佳化,不但速度比以往更快、支援更多虛擬裝置,UI 也經過大幅改善。如要進一步瞭解新版模擬器,請參閱「SDK 工具版本資訊」。
<li>Improvements to the <a href=
"/tools/devices/managing-avds.html">Android Virtual Device
Manager</a>:
<ul>
<li>System images are now categorized under the following tabs:
<em>Recommended</em>, <em>x86</em>, and <em>Other</em>.
</li>
<li>Under advanced settings, you can enable multi-core support and
specify the number of cores the emulator can use.
</li>
<li>Under advanced settings, you can determine how graphics are rendered
on the emulator by selecting one of the following options:
<ul>
<li>
<strong>Hardware:</strong> use you computer's graphics card for
faster rendering.
</li>
<li>
<strong>Software:</strong> use software-based rendering.
</li>
<li>
<strong>Auto:</strong> let the emulator decide the best option. This
is the default setting.
</li>
</ul>
</li>
</ul>
</li>
<li>Improved AAPT packaging times by specifying deploy target before the app
is built. This allows Android Studio to efficiently package only the
resources required by the specified device.
</li>
<li>Added Cloud Test Lab integration to provide on-demand app testing with
the convenience and scalability of a cloud service. Learn more about how you
can <a href="/training/testing/start/index.html#run-ctl">use Cloud
Test Lab with Android Studio</a>.
</li>
<li>Added a preview of the new <a class="external-link" href=
"//tools.android.com/tech-docs/gpu-profiler">GPU Debugger</a>. For graphics
intensive applications, you can now visually step through your OpenGL ES code
to optimize your app or game.
</li>
<li>Added Google App Indexing Test. Add support for URLs, app
indexing, and search functionality to your apps to help drive more
traffic to your app, discover which app content is used most, and attract
new users. Test and validate URLs in your app all within Android
Studio. See <a href=
"/tools/help/app-link-indexing.html">Supporting URLs and App
Indexing in Android Studio</a>.
</li>
<li>Upgrades from the latest IntelliJ 15 release, including improved code
analysis and performance. See <a class="external-link" href=
"https://www.jetbrains.com/idea/whatsnew">What's New in IntelliJ</a> for a
complete description of the new features and enhancements.
</li>
<li>XML editor auto-complete now adds quotations marks when completing
attributes. To check if this option is enabled, open the <b>Setting</b> or
<b>Preferences</b> dialogue, navigate to <b>Editor > General > Smart
Keys</b>, and check the box next to <b>Add quotes for attribute value on
attribute completion</b>. <a class="external-link" href=
"//b.android.com/195113">Issue: 195113</a>
</li>
<li>The XML editor now supports code completion for <a href=
"/topic/libraries/data-binding/index.html#layout_details">data binding</a>
expressions.
</li>