1. 程式人生 > >譯文1——Android Studio 3.2.1的更新內容

譯文1——Android Studio 3.2.1的更新內容

前言

Android Studio 的3.2版本出來很久,今天終於升級了。更新成功之後,Android Studio 會彈出一個更新內容的英文版,我就想翻譯一下。如果譯文裡面有錯誤,麻煩看到的小夥伴跟我說一下,我去更正。謝謝!

原文

What New in 3.2

This panel describes some of the new features and behavior changes included in this update.

To open this panel again later, select Help > What's New in Android Studio from the main menu.

Watch an overview

Read in a browser

Support for Android App Bundles

The Android App Bundle is a new upload format that includes all your app’s compiled code and resources, but defers APK generation and signing to the Google Play Store.

Google Play’s new app serving model, called Dynamic Delivery, then uses your app bundle to generate and serve optimized APKs for each user’s device configuration, so they download only the code and resources they need to run your app. You no longer have to build, sign, and manage multiple APKs, and users get smaller, more optimized downloads.

Additionally, you can add dynamic feature modules to your app project and include them in your app bundle. Through Dynamic Delivery, your users can then download and install your app’s dynamic features on-demand.

To learn more about how to build Android App Bundles, read the official documentation in a browser.

Support for Android Jetpack

Android Jetpack helps accelerate Android development with components, tools and guidance that eliminate repetitive tasks, and enables you to more quickly and easily build high-quality, testable apps. Android Studio includes the following updates to support Jetpack. For more details, read the official documentation in a browser.

  - New Navigation Editor: A visual editor for the XML resource that the new Navigation Component uses to handle navigation actions at runtime. The Navigation Editor is an experimental feature, so you must first enable it by opening the IDE Settings/Preferences dialog, selecting Experimental in the left pane, and checking the box next to Enable Navigation Editor. Learn more
  - New template for Architecture Components: Easily add the new Architecture Components to your project, such as the ViewModel, using the New Project Wizard. Learn more
  - AndroidX migration tools: The new Android extension libraries (AndroidX) represent the future of the Android Support Library. You can easily migrate an existing project to use AndroidX (including migrating Maven dependencies that do not yet use AndroidX) by selecting Refactor > Migrate to AndroidX. Learn more

New Profiler Features

The Android Profiler   now includes the following new features: 

 - Energy Profiler: Estimates your app's energy usage of a device's CPU, Network, and GPS resources. This new profiler also highlights background events that may contribute to battery drain, such as wake locks, alarms, jobs, and location requests. Learn more
 - System Trace: In the CPU Profiler, inspect your device's system CPU and thread activity using the new System Trace configuration. It's built on systrace and is useful for investigating system-level issues, such as UI jank. Learn more
 - Sessions: Inspect and revisit data across multiple profiler "sessions". Learn more
 - Export CPU trace files: After you record CPU activity with the CPU profiler, export the data as a .trace file by right-clicking on the recording in the CPU timeline and selecting Export trace from the context menu. Learn more
 - Import and inspect CPU trace files: Import and inspect .trace files that you create using the Debug API or CPU profiler (however, importing System Trace recordings is currently not supported). Import your trace file by clicking Start a new profiling session   in the profiler's Sessions pane and then selecting Load from file. Learn more
 - Record CPU activity during app startup: Enable the feature by selecting Run > Edit Configurations from the main menu and, under the Profiling tab of your desired run configuration, checking the box next to Start recording a method trace on startup. Now deploy your app to a device running Android 8.0 (API level 26) or higher by selecting Run > Profile. Learn more
 - Inspect JNI references: Inspect memory allocations for your app’s JNI code when you deploy to a device running Android 8.0 (API level 26) or higher. Learn more
 - Start method traces using the Debug API: Call Debug.startMethodTracing(String tracePath) and Debug.stopMethodTracing() in your app's code to programmatically start and stop recording method traces in the CPU profiler. Learn more

Android Emulator Snapshots

Using the Android Emulator 27.3.0 or higher, you can now save and load snapshots of an AVD (Android virtual device) at any time, making it fast and easy to return to a known state for testing. You can also edit an AVD using the AVD Manager to specify a default snapshot to load when the AVD starts.

Controls for saving, loading, and managing AVD snapshots are now in the Snapshots tab in the emulator's Extended controls window. Learn more 

C/C++ IDE Features

Android Studio now includes the following features for developing your C/C++ libraries:

 - Smart editor features for CMake scripts: Perform safe refactoring, code completion, code reformatting, and other smart editor actions when editing CMake build scripts. Learn more
 - Navigate external header files: In the Project window, view and inspect header files from external C/C++ library dependencies that you import into your project using CMake. Learn more

Other New Features and Behaviors

 - Base IDE upgraded to IntelliJ 2018.1.2: Android Studio now includes updates up through to IntelliJ 2018.1.2. You may notice changes in behavior and performance as a result of this merge.
 - Preview with sample data in the Layout Editor: Use auto-generated sample data to preview your views in the Layout Editor. In the editor's design view, click the   button and, in the pop-up menu that appears, select the type of content you want to use. Learn more
 - AAPT2 now on Google's Maven repo: To use AAPT2, you must add Google's Maven repository to your project-level build.gradle, as shown below. Learn more
	 buildscript.repositories {
         google()
   		 jcenter()
  		  ...
	}
	allprojects.repositories {
   		 google()
    	 jcenter()
   		 ...
	} 
 - New code shrinker: Preview a new code shrinker that also obfuscates by adding the line below to your project’s gradle.properties file. Learn more 
		android.enableR8 = true
 - Lint checks for Java/Kotlin interoperability: Enable new lint checks that enforce best practices described in the Kotlin Interop Guide by first opening the IDE preferences dialog and navigating to Editor > Inspections. Then, check the rules that you want to enable under Kotlin Interoperability. Learn more
 - Native multi-dex enabled by default: The Android plugin for Gradle now enables native multidex for all modules that set minSdkVersion = 21 or higher.
 - Changed set of default ABIs: When building multiple per-ABI APKs, Android plugin for Gradle 3.2.0 no longer generates APKs for the following ABIs by default: mips, mips64, and armeabi. Learn more

譯文

3.2更新了什麼

該面板描述了更新中包含的一些新特性和行為變化。
要再次開啟這個面板,請選擇Help>主選單中的What's New in Android Studio

觀看概覽

在瀏覽器中閱讀

支援Android App Bundles

Android App Bundle是一種新的上傳格式,包括所有應用程式編譯的程式碼和資源,但是推遲了APK的生成和簽名到Google Play Store。

Google Play的新應用程式服務模型,稱為Dynamic Delivery,然後使用您的應用程式包為每個使用者的裝置配置生成和服務優化的APK,因此它們只下載執行應用程式所需的程式碼和資源。您不再需要構建、簽署和管理多個APK,使用者可以獲得更小、更優化的下載。

另外,您可以嚮應用程式專案新增動態特性模組,並將其包含在應用程式包中。通過動態傳遞,使用者可以根據需要下載和安裝應用程式的動態特性。

要了解更多關於如何構建Android App Bundles,請閱讀瀏覽器中的官方文件。

支援Android Jetpack

Android Jetpack通過消除重複任務的元件、工具和指導,幫助加速Android開發,並使您能夠更快更容易地構建高質量的、可測試的應用程式。Android Studio包含支援Jetpack的以下更新。有關詳細資訊,請閱讀瀏覽器中的官方文件。

  • New Navigation Editor:用於XML資源的視覺化編輯器,新Navigation元件使用該編輯器來在執行時處理導航操作。導航編輯器是一個實驗特性,因此您必須首先通過開啟IDE設定/首選項對話方塊、在左窗格中選擇ExpigationEditor並選中Enable Navigation Editor旁邊的框來啟用它。瞭解更多
  • 架構元件的新模板:使用New Project Wizard輕鬆地將新的架構元件新增到專案中,例如ViewModel。瞭解更多
  • Android X遷移工具:新的Android擴充套件庫(Android X)代表了Android支援庫的未來。通過選擇主選單中的Refactor>Migrate to AndroidX,您可以輕鬆地遷移現有專案以使用AndroidX(包括遷移尚未使用AndroidX的Maven依賴項)。瞭解更多

分析器新特徵

Android分析器現在包含了以下新特性:

  • 能源概況:估計應用程式的能源使用的裝置的CPU,網路和GPS資源。這個新的剖析器還突出了可能導致電池耗盡的背景事件,如喚醒鎖、警報、作業和位置請求。瞭解更多
  • 系統跟蹤:在CPU剖析器中,使用新的系統跟蹤配置檢查裝置的系統CPU和執行緒活動。它建立在系統上,對於研究系統級問題,如使用者介面非常有用。瞭解更多
  • Sessions:檢查和重訪多個分析器“sessions”中的資料。瞭解更多
  • 匯出CPU跟蹤檔案:在使用CPU分析器記錄CPU活動之後,通過右鍵單擊CPU時間線中的記錄並從上下文選單中選擇匯出跟蹤,將資料匯出為.trace檔案。瞭解更多
  • 匯入和檢查CPU跟蹤檔案:匯入和檢查使用Debug API或CPU分析器建立的.跟蹤檔案(但是,當前不支援匯入系統跟蹤記錄)。通過單擊“分析器的會話”窗格中的“啟動新的分析會話”,然後從“檔案”中選擇“載入”,匯入跟蹤檔案。瞭解更多
  • 在應用程式啟動期間記錄CPU活動:通過從主選單中選擇Run>Edit Configurations並在所需執行配置的Profiling選項卡下選中Start旁邊的框來啟用該特性,現在將你的應用程式部署到執行Android 8(API級別26)或更高的裝置上,通過選擇Run>Profile。瞭解更多
  • 檢查JNI引用:當您部署到執行Android 8(API級別26)或更高的裝置時,檢查應用程式的JNI程式碼的記憶體分配。瞭解更多
  • 使用除錯API啟動方法跟蹤:在應用程式的程式碼中呼叫Debug.startMethodTracing(String tracePath)和Debug.stopMethodTracing(),以程式設計方式啟動和停止在CPU分析器中記錄方法跟蹤。瞭解更多

Android模擬器快速啟動

使用Android模擬器27.3.0或更高版本,現在可以隨時儲存和載入AVD(Android虛擬裝置)的快速啟動,從而快速且容易地返回到已知狀態以進行測試。還可以使用AVD管理器編輯AVD,以指定在AVD啟動時載入的預設快速啟動。

用於儲存、載入和管理AVD快速啟動的控制元件現在在模擬器的擴充套件控制元件視窗中的快速啟動選項卡中。瞭解更多

C/C++ IDE的特點

Android Studio現在包含了開發C/C++庫的以下特性:

  • CMake指令碼的智慧編輯器特性:在編輯CMake構建指令碼時執行安全重構、程式碼完成、程式碼重新格式化和其他智慧編輯器操作。瞭解更多
  • 導航外部標頭檔案:在專案視窗中,檢視和檢查使用cFube匯入到專案中的外部C/C++庫依賴項的標頭檔案。瞭解更多

其他新的特徵和行為

  • Base IDE升級到IntelliJ 2018.1.2:Android Studio現在包括升級到IntelliJ 2018.1.2的更新。您可能會注意到這種合併行為和效能的變化。
  • 在佈局編輯器中預覽示例資料:使用自動生成的示例資料在佈局編輯器中預覽檢視。在編輯器的設計檢視中,單擊按鈕,在出現的彈出選單中,選擇要使用的內容型別。瞭解更多
  • AAPT2:要使用AAPT2,必須將Google的Maven儲存庫新增到專案級別build.gradle中,如下所示。瞭解更多
buildscript.repositories {
    google()
    jcenter()
    ...
}
allprojects.repositories {
    google()
    jcenter()
    ...
}
  • 新程式碼收縮器:預覽一個新程式碼收縮器,通過將下面的行新增到專案的gradle.properties檔案中,該程式碼收縮器也會混淆。瞭解更多
android.enableR8 = true
  • 對Java/Kotlin interoperability的Lict檢查:通過首先開啟IDE首選項對話方塊並導航到Editor>Inspections,啟用執行Kotlin Interop Guide中描述的最佳實踐的新lint檢查。然後,檢查在Kotlin Interoperability下要啟用的規則。瞭解更多
  • 預設情況下啟用本機多重dex:Gradle的Android外掛現在為設定minSdkVersion=21或更高的所有模組啟用本機多重dex。
  • 更改了預設ABI設定:當構建多個每個ABI APK時,用於Gradle 3.2.0的Android外掛在預設情況下不再為下列ABI生成APK:mipsmips64armeabi。瞭解更多