Android Studio Bumblebee | What’S New In Android Studio – Bumblebee 1482 투표 이 답변

당신은 주제를 찾고 있습니까 “android studio bumblebee – What’s new in Android Studio – Bumblebee“? 다음 카테고리의 웹사이트 ppa.diaochoangduong.vn 에서 귀하의 모든 질문에 답변해 드립니다: https://ppa.diaochoangduong.vn/blog/. 바로 아래에서 답을 찾을 수 있습니다. 작성자 Android Developers 이(가) 작성한 기사에는 조회수 54,111회 및 좋아요 1,461개 개의 좋아요가 있습니다.

android studio bumblebee 주제에 대한 동영상 보기

여기에서 이 주제에 대한 비디오를 시청하십시오. 주의 깊게 살펴보고 읽고 있는 내용에 대한 피드백을 제공하세요!

d여기에서 What’s new in Android Studio – Bumblebee – android studio bumblebee 주제에 대한 세부정보를 참조하세요

Get an overview of what tools and features are available in Android Studio Bumblebee and Android Gradle plugin 7.1.
New features:
• Compose interactive preview,
• Layout inspector snapshots
• New device manager and ADB over Wi-fi
• Support for profileable apps and other profiler improvements
• Cacheable lint task
• Unified Gradle test runner for instrumentation tests
• Even more stable AGP APIs for plugin authors
Resources:
Android Studio release notes → https://goo.gle/3fRB0bq
AGP release notes → https://goo.gle/3rHGB9Q
File an Android Studio bug → https://goo.gle/3fJWIhR
Catch more videos → https://goo.gle/AndroidStudio-Tools
Subscribe to Android Developers → https://goo.gle/AndroidDevs ​
#Featured​ #Develop​ #AndroidStudio

product: Android – Android Studio; fullname: Wojtek Kaliciński;

android studio bumblebee 주제에 대한 자세한 내용은 여기를 참조하세요.

New features in Android Studio Preview

In Andro Studio Electric Eel, you can use Live Edit to deploy code changes to your composable to an emulator or device in real time. You don’t have to wait …

+ 자세한 내용은 여기를 클릭하십시오

Source: developer.android.com

Date Published: 4/14/2022

View: 5257

Các bản phát hành trước đây của Android Studio

Trong Andro Studio Bumblebee, giờ đây bạn có thể sử dụng Layout Inspector để kiểm tra thông tin ngữ nghĩa trong bố cục của công cụ Compose.

+ 여기를 클릭

Source: developer.android.com

Date Published: 12/17/2021

View: 8325

Past releases of Android Studio

Andro Studio Bumblebee supports the wireless debugging feature on Andro 11 and higher devices. Pair and deploy your app from Andro Studio over Wi-Fi …

+ 여기에 자세히 보기

Source: developer.android.com

Date Published: 6/7/2022

View: 1838

Android Studio Dolphin | 2021.3.1

Discover what’s new in the latest versions of Andro Studio, the official IDE for Andro. … Bumblebee | 2021.1.1, 3.2-7.1. Chipmunk | 2021.2.1, 3.2-7.2.

+ 여기에 보기

Source: developer.android.com

Date Published: 12/11/2022

View: 4511

Lỗi đã đóng của Android Studio 2021.1.1

Andro Studio Bumblebee Beta 5 (2021.1.1.18). Phát hành cùng với: Andro Gradle Plugin 7.1.0-beta05. Lỗi đã được khắc …

+ 더 읽기

Source: developer.android.com

Date Published: 11/8/2021

View: 502

Android Studio 2021 “Bumblebee” now available to download

Andro Studio Bumblebee, also known as version 2021.1.1, coinces with version 7.1.0 of the Andro Gradle plugin (AGP). There’s a brand new …

+ 여기에 더 보기

Source: www.xda-developers.com

Date Published: 3/27/2022

View: 9592

주제와 관련된 이미지 android studio bumblebee

주제와 관련된 더 많은 사진을 참조하십시오 What’s new in Android Studio – Bumblebee. 댓글에서 더 많은 관련 이미지를 보거나 필요한 경우 더 많은 관련 기사를 볼 수 있습니다.

What's new in Android Studio - Bumblebee
What’s new in Android Studio – Bumblebee

주제에 대한 기사 평가 android studio bumblebee

  • Author: Android Developers
  • Views: 조회수 54,111회
  • Likes: 좋아요 1,461개
  • Date Published: 2022. 1. 26.
  • Video Url link: https://www.youtube.com/watch?v=rIt13HjCRiI

New features in Android Studio Preview

This page lists the new features introduced in Android Studio preview releases. The preview builds provide early access to the latest features and improvements in Android Studio. You can download these preview versions here. If you encounter any problems using a preview version of Android Studio, please let us know. Your bug reports help to make Android Studio better.

For the latest news on Android Studio preview releases, including a list of notable fixes in each preview release, see the Release Updates in the Android Studio blog.

Current versions of Android Studio

The following table lists the current versions of Android Studio and their respective channels.

Version Channel Android Studio Dolphin | 2021.3.1 Stable Android Gradle plugin 7.3.0 Stable Android Studio Electric Eel | 2022.1.1 Beta Android Studio Flamingo | 2022.2.1 Canary

Compatibility with Android Gradle plugin previews

Each preview version of Android Studio is published alongside a corresponding version of the Android Gradle plugin (AGP). Preview versions of Studio should work with any compatible stable version of AGP. However, if you’re using a preview version of AGP, you must use the corresponding preview version of Studio (for example, Android Studio Chipmunk Canary 7 with AGP 7.2.0-alpha07). Attempts to use divergent versions (for example, Android Studio Chipmunk Beta 1 with AGP 7.2.0-alpha07) will cause a Sync failure, which results in a prompt to update to the corresponding version of AGP.

For a detailed log of Android Gradle plugin API deprecations and removals, see the Android Gradle plugin API updates.

Android Studio Electric Eel | 2022.1.1

The following are new features in Android Studio Electric Eel.

Live Edit

In Android Studio Electric Eel, you can use Live Edit to deploy code changes to your composable to an emulator or device in real time. You don’t have to wait for builds or deployments to be completed, so you can make faster progress in creating your app.

Note: Android Studio Electric Eel Canary 10 and higher contains a major bug fix for Kotlin functions overloaded by return type being invoked incorrectly.

Note: Starting with Electric Eel Canary 9, if your project is using Compose version 1.2 or higher, Live Edit no longer needs to reset composition after code changes. Only the first code change made to a given file resets composition. Subsequent edits don’t reset composition.

Live Edit is available in the Electric Eel Canary channel as an experimental feature. To turn it on manually, navigate to File > Settings > Editor > Live Edit (Android Studio > Preferences > Editor > Live Edit on a Mac).

Live Edit focuses on UI- and UX-related code changes. Live Edit doesn’t currently support changes such as method signature updates, adding new methods, or class hierarchy changes. Live Edit is an experimental feature in active development, so you might experience some unstable behavior. If you find an issue, please let us know so we can work to fix it. You can also see a list of open issues here. For more information, see Live Edit in Android Studio.

SDK insights

View dependency insights from the new Google Play SDK Index, a public portal with information about popular dependencies, or SDKs. If a specific version of a library has been marked as outdated by its author, a corresponding Lint warning appears when viewing that dependency definition. This enables you to discover and update dependency issues during development instead of later when you go to publish your app on the Play Console. You can learn more about this new tool on the Android Developer’s Blog post here.

App Quality Insights from Firebase Crashlytics

Starting with Android Studio Electric Eel, you can see and act on app crash data from Firebase Crashlytics directly in the IDE. This integration pulls stack trace data and crash statistics from Crashlytics into the new App Quality Insights tool window in the IDE, so you don’t have to jump back and forth between your browser and the IDE. Development teams can benefit from key capabilities including the following:

See lines in your code highlighted when they have related Crashlytics event data.

See the stack trace for top crashes and click on the stack trace to jump to the relevant lines in your code.

See summary statistics about top crash and non-fatal events, for example grouped by device manufacturer and Android version.

Filter events by severity, time, and app version.

Get a browser link that opens the Crashlytics dashboard page with more details about the event.

With the Android Studio and Crashlytics integration, you can write code and address top crash issues all in the same spot. This enriched development experience helps you stay informed about your app’s performance and minimize disruptions for your users. If you encounter any issues with this feature, file a bug.

If you’re not using Crashlytics yet and would like to learn more about its offerings, see Firebase Crashlytics.

Get started

To see Crashlytics data in Android Studio, you need to set up Firebase and Crashlytics in your app project. Here’s how: open the Firebase Assistant in Android Studio by going to Tools > Firebase, click Crashlytics, and then follow the tutorial to add Firebase and Crashlytics to your project. You can read more about the Firebase Assistant workflow in Firebase’s getting started guide for Android.

If you’ve already added Firebase and Crashlytics to your app, sign in to your Developer account in the IDE by clicking on the avatar icon . After you sign in, click on the App Quality Insights tool window. You should see the Issues, Sample Stack Trace, and Details panels populate with reports from Crashlytics.

Navigate Crashlytics data in Android Studio

The App Quality Insights tool window has rich data that gives you insight into the events your users are encountering, and links to help you quickly navigate to the sources of those events.

If your project includes multiple app modules, make sure the module you want to see event data for is selected from the module dropdown menu. Use the application ID dropdown menu to select the app ID you want to analyze. For example, while you might work on the debug version of your app in the IDE, you might want to see event data for your production version of your app that your users install. The Issues panel shows the top events that Crashlytics has data for, and is sorted by your most impactful crashes. The Sample Stack Trace panel shows details about the latest occurrence of the event you click on in the **Issues** panel. You can see the event’s stack trace and click on the stack trace to jump to the relevant lines in your code base. There is also information about the device type affected, its Android version, and the time the event occurred, as well a link to the event in the Firebase Crashlytics dashboard. The dashboard is useful if you want to dive deeper and inspect additional stack traces, trends, and custom logs. The Details panel breaks down the crash counts by device type and Android version, so you can determine which user groups are most affected. It also shows which app version(s) experienced the crash and the number of users affected. Use the severity filters to select or deselect events that are Fatal or Non-Fatal . Use the time range and app version filters to hone in on certain subsets of events.

In addition to being able to navigate from stack trace to code, you can also jump from code to stack trace: Android Studio now highlights lines of code that are related to crashes so you can easily spot and debug them.

When you hover over a highlighted line of code, a pop-up appears that shows the event involved, its frequency, and the number of devices affected. You can click on Open in App Quality Insights to jump to the event details in the App Quality Insights tool window.

Resizable emulator

You can now test your app on multiple screen sizes and with a single resizable emulator. Testing on a single resizable emulator not only allows you to rapidly test changes across different interfaces, but also promotes a smoother development experience by saving the compute resources and memory that would be required to maintain separate virtual devices.

To use the resizable emulator, you need Android Emulator version 31.1.3 or higher (you can upgrade versions by going to Tools > SDK Manager). To create a resizable Android Virtual Device (AVD), in the Create device flow, select the “Resizable (Experimental)” phone hardware profile, download the Android Tiramisu system image, and follow the prompts to create the AVD.

When you deploy your app to the resizable emulator, you can use the Display Mode dropdown menu in the emulator toolbar to quickly toggle between a set of common device types. The emulator screen will resize so you can easily test your app across a range of screen sizes and densities.

Emulated Bluetooth

You can now discover and connect two phone emulators using virtual Bluetooth. With virtual Bluetooth, you can test that your app can recognize and gain access to the Bluetooth adapter in a scalable way. This feature is available on Android Emulator 31.3.8 and higher with system image T (API 33). We plan to add more support for creating sample virtual peripherals, such as beacons and heart rate monitors, and integration testing for your Bluetooth features in the future.

Device Mirroring

You can now mirror your device in the Running Devices window in Android Studio Electric Eel. By streaming your device’s display directly to Android Studio, you can execute common actions such rotating the screen, changing the volume, or locking/unlocking the device right from the IDE itself.

Device Mirroring is available in the Electric Eel Canary channel as an experimental feature. To turn it on manually, navigate to File > Settings > Experimental (Android Studio > Preferences > Experimental on a Mac), and check the box next to Device Mirroring.

To get started, ensure you are connected to a device. All devices that you are connected to are mirrored in tabs in the Running Devices window, which you can open by navigating to View > Tool Windows > Running Devices. When you deploy an app or test to a connected device, the Running Devices window appears automatically and shows the mirrored device.

Privacy notice

If device mirroring is enabled, Android Studio automatically starts device mirroring for any connected and paired device. This might result in information disclosure for devices connected with the adb tcpip command because the mirroring information and commands are passed over a non-encrypted channel. In addition, Android Studio uses a non-encrypted channel to communicate with the adb server, so mirroring information can be intercepted by other users on your host machine.

Updates to Logcat

In Android Studio Electric Eel, the new version of Logcat is enabled by default to make it easier to parse, query, and keep track of logs. This represents the most significant update to the tool since its introduction, and we welcome you to provide feedback.

Android Gradle plugin targets JVM 11 bytecode

Starting with Android Gradle plugin 7.4.0-alpha04, AGP ships wth JVM 11 bytecode. This means that if you compile against AGP, or write custom Lint checks, you need to start targeting JVM 11 bytecode. One of the ways to do this is to include the following in your module-level build.gradle file:

sourceCompatibility = “11” targetCompatibility = “11”

AGP Upgrade Assistant post-upgrade report and rollback functionality

The AGP Upgrade Assistant now includes a post-upgrade report. This report describes the steps that were completed and if the upgrade was successful or unsuccessful. It also includes an action to revert changes that were made by the upgrade assistant, if there are issues building or testing the project after the upgrade.

Project import runs in parallel

Starting with Android Studio Electric Eel Canary 6, the IDE imports projects in parallel when you use Gradle 7.4.2 or higher and Android Gradle plugin 7.2.0 or higher. Specifically, when Android Studio triggers a Gradle sync, the information that describes projects included in your build is created in parallel. This should result in faster sync times, especially for larger projects. Benchmarks show that the time it takes to build Gradle models for a very large project (with 3,500 Gradle subprojects) is reduced by 50%, from 10 to 5 minutes.

Desktop Android Virtual Device now available

You can now test how your app works on desktop devices such as Chromebooks by using a Desktop Android Virtual Device (AVD). Users often interact with apps differently on large screen devices, and the Desktop AVD enables you to see how your app behaves in this environment. Here are some of the unique functionalities you can test:

App resizing: resize your app by dragging the window edges.

Freeform window management: place your app in various places on the desktop screen, and minimize, maximize, and restore the app window.

Notifications: check that the notifications render correctly when pulled up from the system tray on the desktop.

To learn more about Desktop AVDs and how to incorporate them in your testing workflow, see Desktop AVD in Android Studio on the ChromeOS developers blog.

Check download impact using Build Analyzer

Starting with Android Studio Electric Eel Canary 10, Build Analyzer provides a summary of time spent downloading dependencies and a detailed view of downloads per repository. You can use this information to determine whether unexpected dependency downloads are negatively impacting your build performance. This is especially important during incremental builds, which shouldn’t consistently download artifacts.

Specifically, you can use this information to identify configuration issues, such as use of dynamic versions of dependencies that cause unexpected downloads. Also, if you see a high number of failed requests for a specific repository, it could indicate that the repository should be removed or moved lower in your repository configuration.

Layout Inspector recomposition rendering highlights

In Android Studio Electric Eel, your recompositions are highlighted to help you determine where in the UI your composables are recomposing. The highlighted portion shows a gradient overlay of the composable in the image section of the Layout Inspector, and gradually disappears so that you can get an idea of where in the UI the composable with the highest recompositions can be found. If one composable is recomposing at a higher rate than another composable, then the first composable receives a stronger gradient overlay color.

Use Compose Preview with different devices

In Android Studio Electric Eel, you can edit the device parameter of the Preview annotation to define configurations for your Composables in different devices.

Autocompletion

When the device parameter has an empty string ( @Preview(device = “”) ), you can invoke autocomplete by pressing Ctrl + Space . You should be able to set the values of each parameter. To switch, press Enter , or cancel with Esc .

Inspection

If you set an invalid value, the declaration is underlined in red and a fix may be available ( Alt + Enter (⌥ + ⏎ for macOS) > Replace with …. The Inspection will try to provide a fix that is closest to resembling your input.

Preview Picker

You can use the Preview Picker to edit your configurations. To get started, click the settings icon next to your Preview.

Universal Problems panel

In Android Studio Electric Eel, you can view all the issues for your Design Tools in a shared issue panel. To view the tool window, navigate to View > Tool Windows > Problems.

Visual linting

Starting with Electric Eel Canary 1, Android Studio automatically runs your layout to check for Visual Lint issues across different screen sizes. When you open Layout Validation, you can see all your layouts render in multiple device sizes. If there’s an an issue, you can see it in the Problems panel, which is designed to show all issues within design tools, regardless of if your layout is written in Views or Compose.

Compose Preview

Starting with Android Studio Electric Eel Beta 1, you can see immediate updates to your Preview changes as you make them.

Android Studio Flamingo | 2022.2.1

The following are new features in Android Studio Flamingo.

IntelliJ IDEA 2022.2 platform update

Android Studio Flamingo Canary 1 includes the IntelliJ IDEA 2022.2 updates, which improve the IDE experience. For details on the changes, see the IntelliJ IDEA 2022.2 release notes.

Auto-connect to foreground process in Layout Inspector

The Layout Inspector now automatically connects to apps on virtual or physical devices. Specifically, the Layout Inspector automatically connects to debuggable processes running in the foreground of a connected device. If you have feedback on this feature, please file a bug.

Network Inspector traffic interception

Starting with Android Studio Flamingo Canary 1, the Network Inspector shows all traffic data for the full timeline by default. You can select a range within the timeline to see only the traffic in that range.

You can also create and manage rules that help test how your app behaves when encountering different responses such as status codes, and response headers and bodies. The rules determine what responses to intercept and how to modify these responses before they reach the app. You can choose which rule to enable or disable by checking the Active box next to each rule. Rules are automatically saved every time you modify them.

To get started, navigate to the Rules tab in the Network Inspector and click + to create a new rule. In the Rule Details panel, name your new rule and include information about the origin of the response you want to intercept under the Origin subsection. The URL in the Rules table should update based on the changes you made to the origin of the response. All fields in this subsection are optional.

From the Response subsection, you can modify the response before it’s sent to your app. For example, you can set the rule to execute on responses with a specific status code as well as modify that status code.

Modify headers

In the Header rules subsection, you can create multiple sub-rules that add or modify headers in a response. When you create multiple header rules, use the up and down arrows at the top of the Rules table to change the order of the header rules. The order affects the header of the modified response because the header rules are applied in the order that they are listed.

To get started, click + in the Header rules section.

To add a header, enter a name and value for the header in the Add new header section.

To modify a header, navigate to the Edit existing header tab and specify the header name or value that you want to find. Enter a header name or value that you want to replace it with.

Modify response body

You can also create sub-rules to modify the body of the response. You can choose to either Find and Replace a section of the body, in which the first instance in the body is replaced; or, you can choose to replace the entire content of the body by selecting Replace entire body.

Similar to Header rules, you can create multiple body rules that are applied in the order that they are listed in the table.

Default value for RenderScript flag changed

Starting with AGP 8.0.0-alpha02, the default value for the buildFeatures.renderScript flag has changed from true to false . If you need to enable RenderScript compilation, set the flag explicitly to true . This build feature should be enabled only in the modules that use it.

To get help adjusting your code to support this change, use the AGP Upgrade Assistant.

Breaking change: namespace required in module-level build.gradle file

Starting with AGP 8.0.0-alpha03, you must set the namespace in the module-level build.gradle file, rather than the manifest file. You can start using the namespace DSL property starting with AGP 7.3. To learn more, see Set a namespace.

To get help moving to the new namespace DSL, use the AGP Upgrade Assistant (Tools > AGP Upgrade Assistant).

When migrating to the namespace DSL, be aware of the following issues:

Previous versions of AGP infer the test namespace from the main namespace, or application ID, incorrectly in some cases. The AGP Upgrade Assistant blocks the upgrade if it finds that your project’s main namespace and test namespace are the same. If the upgrade is blocked, you need to manually change testNamespace and modify your source code accordingly.

and modify your source code accordingly. After you change the test namespace, it’s possible that your code compiles but your instrumented tests fail at runtime. This can happen if your instrumented test source code references a resource defined in both your androidTest and app sources.

For more information, see issue #191813691 comment #19.

Các bản phát hành trước đây của Android Studio

Trang này liệt kê các tính năng và điểm cải tiến mới cho mỗi bản phát hành chính của các bản phát hành Android Studio trước đây. Để biết thông tin mới trong phiên bản mới nhất, hãy xem ghi chú phát hành của Android Studio hiện tại.

Để biết tin tức mới nhất về các bản phát hành, bao gồm cả danh sách các bản sửa lỗi đáng chú ý trong mỗi bản thử nghiệm, hãy xem nội dung cập nhật của bản phát hành. Để biết thông tin về các tính năng mới trong trình bổ trợ Android cho Gradle, hãy xem các bản ghi chú phát hành của trình bổ trợ này.

Trình bổ trợ Android cho Gradle và khả năng tương thích với Android Studio

Android Studio là một hệ thống xây dựng dựa trên Gradle, còn trình bổ trợ Android cho Gradle bổ sung một số tính năng dành riêng cho việc xây dựng ứng dụng Android. Bảng sau đây liệt kê yêu cầu về phiên bản trình bổ trợ Android cho Gradle đối với từng phiên bản Android Studio.

Nếu dự án của bạn không được hỗ trợ bởi một phiên bản Android Studio cụ thể, bạn vẫn có thể mở và cập nhật dự án đó bằng một phiên bản Android Studio cũ

Phiên bản Android Studio Phiên bản trình bổ trợ cần phải có Arctic Fox | 2020.3.1 3.1-7.0 Bumblebee | 2021.1.1 3.2-7.1 Chipmunk | 2021.2.1 3.2-7.2 Dolphin | 2021.3.1 3.2-7.3 Electric Eel | 2022.1.1 3.2-7.4 Flamingo | 2022.2.1 3.2-8.0

Để biết thông tin về các tính năng mới trong trình bổ trợ Gradle cho Android, hãy xem Ghi chú phát hành của trình bổ trợ Android cho Gradle.

Android Studio Chipmunk | 2021.2.1

Hỗ trợ tạo ứng dụng bằng Jetpack Compose

Tính năng xem trước ảnh động hỗ trợ animatedVisibility

Android Studio Chipmunk hỗ trợ API animatedVisibility trong Tính năng xem trước ảnh động. Để sử dụng tính năng Xem trước ảnh động bằng animatedVisibility , hãy sử dụng phiên bản Compose 1.1.0 trở lên. Để tìm hiểu thêm về tính năng Xem trước ảnh động, hãy xem phần Ảnh động.

Hỗ trợ triển khai bản xem trước từ Mô-đun thư viện

Các bản xem trước cho phép bạn xem giao diện người dùng trong Android Studio mà không cần phải chạy ứng dụng trên một thiết bị thực. Trong Android Studio Chipmunk, bạn có thể triển khai @Preview cụ thể cho một trình mô phỏng hoặc thiết bị thực từ Mô-đun thư viện. Để tìm hiểu thêm, hãy xem phần Triển khai bản xem trước.

Hỗ trợ lập hồ sơ ứng dụng

Phát hiện hiện tượng giật trên Android 12 trở lên

Đối với các thiết bị chạy Android 12 trở lên, một dấu vết được lưu lại sẽ hiển thị trong thành phần Khung hình bị giật bên trong ngăn Hiển thị của Trình phân tích CPU.

Để phát hiện hiện tượng giật,

Khởi động ứng dụng trên trình mô phỏng hoặc thiết bị phát triển. Trong Android Studio, chọn Xem > Công cụ trong Windows > Trình phân tích tài nguyên hoặc nhấp vào Hồ sơ trên thanh công cụ. Nếu hộp thoại Select Deployment Target (Chọn đối tượng triển khai) cho thấy lời nhắc, hãy chọn thiết bị nơi bạn muốn triển khai ứng dụng để phân tích. Nếu bạn đã kết nối thiết bị qua USB nhưng không thấy thiết bị đó trong danh sách, hãy đảm bảo rằng bạn đã bật tính năng gỡ lỗi USB. Nhấp vào nơi bất kỳ trong tiến trình CPU để mở Trình phân tích CPU (CPU Profiler). Bạn sẽ thấy thành phần Khung hình bị giật trong Hiển thị. Theo mặc định, Trình phân tích tài nguyên chỉ hiển thị các khung hình bị giật dưới dạng mục tiêu để điều tra. Trong mỗi khung hình bị giật, phần được tô màu đỏ hiển thị thời lượng khung hình vượt quá thời hạn kết xuất. Sau khi bạn phát hiện ra một khung hình bị giật, hãy nhấp vào nó. Bạn cũng có thể điều chỉnh mức thu phóng bằng cách nhấn M để tập trung vào khung đã chọn. Các sự kiện liên quan sẽ được làm nổi bật trong các chuỗi chính: RenderThread và GPU completion. Bạn có thể tùy ý xem tất cả khung hình hoặc phân tích thời gian kết xuất bằng cách chọn/không chọn các hộp đánh dấu Tất cả các khung và Vòng đời tương ứng.

Để biết thêm thông tin, hãy xem Phát hiện giao diện người dùng bị giật.

Bản phát hành của bản vá

Dưới đây là danh sách các bản phát hành của bản vá trong Android Studio Chipmunk.

Android Studio Chipmunk | 2021.2.1 Bản vá 2 (tháng 8 năm 2022)

Bản cập nhật nhỏ này bao gồm bản cập nhật và các bản sửa lỗi sau:

Hỗ trợ nền tảng Android

Với Android Studio Chipmunk Bản vá 2 và Android Gradle 7.2.2, bạn có thể biên dịch dựa trên các API Android 13 bằng cách đặt compileSdk=33 . Phiên bản SDK tối thiểu được hỗ trợ cao nhất là 32. minSdk = 33 không được hỗ trợ cho đến Trình bổ trợ Android cho Gradle 7.3.0-beta05.

Android Studio Chipmunk | 2021.2.1 Bản vá 1 (tháng 5 năm 2022)

Bản cập nhật nhỏ này bao gồm các bản sửa lỗi sau:

Lỗi đã được khắc phục Dexer (D8) Vấn đề #218298666 Máy ảo Art/Dalvik trước phiên bản 8 không hỗ trợ bản sửa lỗi cho JDK-8272564 IntelliJ Vấn đề #225751091 Trình theo dõi tệp không khởi động được trên Ubuntu 20.04 Vấn đề #206465485 MBP 15″ 2018 bị thiếu trình đơn trên Touch Bar. Chạy Vấn đề #232134751 Tùy chọn thiết bị không hiển thị và không thể chạy ứng dụng mặc dù có sẵn mô-đun ứng dụng. Trình rút gọn (R8) Vấn đề #228791247 Tại sao R8 không điều chỉnh được các phương thức giao diện mặc định nhưng D8 thì có? Vấn đề #218400336 THAM CHIẾU VÒNG TRÒN: com.android.tools.r8.internal.R10: Loại chuyển đổi không mong muốn vào lượt chuyển đổi gốc: OBJECT

Android Studio Bumblebee | 2021.1.1

Android Studio Bumblebee là một bản phát hành chính có nhiều tính năng và điểm cải tiến mới.

Bản xem trước tương tác của Compose được bật theo mặc định

Kể từ Android Studio Bumblebee, tính năng bản xem trước tương tác sẽ được bật theo mặc định. Bản xem trước tương tác cho phép bạn tương tác với một bản xem trước giống như khi bản xem trước đó hoạt động trên thiết bị. Bản xem trước tương tác là bản xem trước tách biệt với bản xem trước khác trong môi trường hộp cát. Tại đây, bạn có thể nhấp vào các phần tử và nhập hoạt động đầu vào của người dùng trong bản xem trước đó. Đây là một cách nhanh chóng để kiểm tra nhiều trạng thái và cử chỉ của cấu trúc có thể kết hợp, chẳng hạn như hộp đánh dấu có thể có trạng thái đã đánh dấu hoặc để trống.

Chế độ tương tác của bản xem trước sẽ chạy ngay trong Android Studio mà không cần chạy trình mô phỏng, dẫn đến một số hạn chế như sau:

Không có quyền truy cập mạng.

Không có quyền truy cập vào tệp.

Có thể không cung cấp đầy đủ một số API ngữ cảnh.

Bản xem trước vectơ vẽ được ở dạng động (AVD)

Công cụ vectơ vẽ được ở dạng động giúp bạn xem trước tài nguyên có thể vẽ ở dạng động. Các công cụ này giúp bạn xem trước tài nguyên , trong Android Studio, đồng thời giúp bạn tinh chỉnh ảnh động tuỳ chỉnh của mình dễ dàng hơn.

Để đơn giản hoá quá trình thiết kế ứng dụng cho nhiều thiết bị Android, chúng tôi đã cập nhật bộ chọn thiết bị trong nhiều cửa sổ công cụ thiết kế, chẳng hạn như Layout Editor và Xác thực bố cục. Trong đó, các thiết bị tham chiếu sẽ phản ánh kích thước phổ biến của từng kiểu dáng thiết bị. Dù là điện thoại, máy tính bảng, thiết bị Wear hay Android TV, giờ đây, bạn có thể xem trước, xác thực hoặc chỉnh sửa bố cục trên các kích thước màn hình tiêu biểu của các thiết bị phổ biến trong thực tế một cách dễ dàng hơn.

Phiên chạy thử nghiệm KMP

Bạn có thể chạy các thử nghiệm cho dự án Kotlin Multiplatform (KMP) trên Android Studio Bumblebee.

Để đảm bảo các thử nghiệm chạy thành công trên Android Studio, hãy đảm bảo bạn đáp ứng mọi yêu cầu dưới đây:

AGP 7.0.0-alpha08 trở lên

Gradle 6.8.2 trở lên

Trình bổ trợ Kotlin 1.4.30 trở lên

Các lớp R không mang tính chất bắc cầu được bật theo mặc định

Các lớp R không mang tính chất bắc cầu giờ đây sẽ được bật theo mặc định. Bạn có thể sử dụng các lớp R không mang tính chất bắc cầu với trình bổ trợ Android cho Grade để tạo các bản dựng nhanh hơn cho các ứng dụng có nhiều mô-đun. Làm như vậy sẽ giúp ngăn chặn tình trạng trùng lặp tài nguyên bằng cách đảm bảo rằng lớp R của mỗi mô-đun chỉ chứa tệp đối chiếu đến tài nguyên riêng của mô-đun đó mà không cần lấy các tệp đối chiếu từ các phần phụ thuộc tương ứng. Điều này giúp chúng ta có các bản dựng mới hơn cũng như nhận được các lợi ích tương ứng khi tránh hoạt động biên dịch.

Bạn có thể yêu cầu trợ giúp khi sử dụng tính năng này bằng cách chuyển đến mục Refactor > Migrate to Non-Transitive R Classes… (Tái cấu trúc > Di chuyển đến lớp R không mang tính chất bắc cầu)

Đối với những người sử dụng macOS trên phần cứng Apple Silicon (arm64), Android Studio Arctic Fox và Trình mô phỏng Android đã hỗ trợ cấu trúc mới này kể từ năm ngoái. Tuy nhiên, với bản phát hành này, chúng tôi hiện đã cập nhật công cụ nền tảng SDK Android phiên bản 32.0.0 (bao gồm công cụ khởi động nhanh và công cụ adb) cũng như công cụ xây dựng phiên bản 32.1.0 (bao gồm cả aapt) thành tệp nhị phân chung để các công cụ dành cho nhà phát triển Android có thể chạy mà không cần đến trình biên dịch tệp nhị phân Rosetta. Xem Ghi chú phát hành về công cụ của nền tảng SDK.

Tính năng mới trong Layout Inspector

Ghi lại ảnh chụp nhanh về hệ thống phân cấp bố cục

Giờ đây, Layout Inspector cho phép bạn lưu ảnh chụp nhanh về hệ thống phân cấp bố cục của ứng dụng đang chạy, nhờ vậy, bạn có thể dễ dàng chia sẻ với những người khác hoặc để tham khảo sau.

Ảnh chụp nhanh ghi lại dữ liệu mà bạn thường thấy khi sử dụng Layout Inspector, bao gồm cả thông tin kết xuất chi tiết ở dạng 3D về bố cục, cây thành phần của Thành phần hiển thị, bộ công cụ Compose hoặc bố cục kết hợp và các thuộc tính chi tiết của mỗi thành phần trong giao diện người dùng. Để lưu ảnh chụp nhanh, hãy làm như sau:

Triển khai ứng dụng của bạn cho thiết bị chạy API cấp 23 trở lên Mở Layout Inspector bằng cách chọn View (Xem) > Tool Windows (Cửa sổ công cụ) > Layout Inspector. Layout Inspector sẽ tự động kết nối với quá trình xử lý ứng dụng. Nếu không, hãy chọn quá trình xử lý ứng dụng từ trình đơn thả xuống. Khi bạn muốn ghi lại ảnh chụp nhanh, hãy nhấp vào biểu tượng Export snapshot (Xuất ảnh chụp nhanh) trên thanh công cụ của Layout Inspector. Trong hộp thoại hệ thống vừa xuất hiện, hãy chỉ định tên và vị trí bạn muốn lưu ảnh chụp nhanh. Hãy nhớ lưu tệp có đuôi là *.li .

Sau đó, bạn có thể tải ảnh chụp nhanh của Layout Inspector bằng cách chọn File > Open (Tệp > Mở) trên thanh trình đơn chính rồi mở tệp *.li .

Hỗ trợ kiểm tra ngữ nghĩa trong Compose

Trong bộ công cụ Compose, Semantics (Ngữ nghĩa học)sẽ mô tả giao diện người dùng theo một cách khác dễ hiểu đối với các dịch vụ Hỗ trợ tiếp cận và khung Thử nghiệm. Trong Android Studio Bumblebee, giờ đây bạn có thể sử dụng Layout Inspector để kiểm tra thông tin ngữ nghĩa trong bố cục của công cụ Compose.

Khi chọn nút Compose, hãy dùng cửa sổ Attributes (Thuộc tính) để kiểm tra xem nút đó có trực tiếp khai báo thông tin ngữ nghĩa, hợp nhất ngữ nghĩa của các phần tử con hoặc cả hai hay không. Để nhanh chóng xác định nút nào có chứa thông tin ngữ nghĩa, đã được khai báo hoặc hợp nhất, hãy dùng trình đơn thả xuống View options (Tuỳ chọn xem) trong cửa sổ Component Tree (Cây thành phần) rồi chọn Highlight Semantics Layers (Làm nổi bật các lớp ngữ nghĩa). Thao tác này chỉ làm nổi bật các nút trong cây chứa thông tin ngữ nghĩa và bạn có thể dùng bàn phím để nhanh chóng di chuyển giữa các nút đó.

Tránh tình trạng Hoạt động khởi động lại

Việc kết nối Layout Inspector với một ứng dụng đang chạy trên các phiên bản Android Studio cũ sẽ khiến Hoạt động của ứng dụng khởi động lại. Việc đặt cờ thiết bị để kiểm tra bố cục của ứng dụng là bắt buộc.

Trong Android Studio Bumblebee, bạn có thể tránh tình trạng Hoạt động khởi động lại khi kết nối Layout Inspector bằng cách đặt cờ này trước theo một trong các bước sau:

Bật tuỳ chọn Run Configuration (Cấu hình chạy) Chọn Run > Edit Configurations (Chạy > Chỉnh sửa cấu hình) trên thanh trình đơn chính. Hộp thoại Run/Debug Configurations (Cấu hình chạy/gỡ lỗi) sẽ hiện ra. Chuyển đến cấu hình chạy mà bạn muốn sử dụng. Trong phần Layout Inspector options (Tuỳ chọn của Layout Inspector), hãy đánh dấu vào hộp bên cạnh tuỳ chọn Connect to Layout Inspector without restarting activity (Kết nối với Layout Inspector mà không cần khởi động lại hoạt động). Sử dụng cấu hình chạy vào lần tiếp theo bạn muốn kiểm tra ứng dụng của mình bằng Layout Inspector.

Cách đặt cờ từ dòng lệnh: Mở một cửa sổ dòng lệnh trên máy được kết nối với thiết bị của bạn Đặt cờ thiết bị cho ứng dụng của bạn bằng lệnh sau đây: adb shell settings put global debug_view_attributes_application_package Triển khai ứng dụng của bạn cho thiết bị và kết nối Layout Inspector. Android Studio sẽ kiểm tra xem cờ đã được đặt hay chưa để tránh tình trạng khởi động lại Hoạt động nếu có thể.

Lưu ý: Mặc dù thường không gây ảnh hưởng đáng kể, nhưng việc đặt cờ thiết bị này khi không sử dụng Layout Inspector có thể ảnh hưởng đến hiệu suất của ứng dụng.

Ghi lại ảnh chụp nhanh trong Layout Inspector ở dạng tài liệu

Giờ đây, bạn có ghi lại ảnh chụp nhanh về hệ thống phân cấp bố cục của ứng dụng để lưu, chia sẻ hoặc kiểm tra sau. Ảnh chụp nhanh ghi lại dữ liệu mà bạn thường thấy khi sử dụng Layout Inspector, bao gồm thông tin hiển thị chi tiết ở dạng 3D về bố cục, cây thành phần của Thành phần hiển thị, bộ công cụ Compose hoặc bố cục kết hợp và các thuộc tính chi tiết của mỗi thành phần trong giao diện người dùng. Khi kiểm tra bố cục của một ứng dụng đang chạy, hãy nhấp vào biểu tượng Export snapshot (Xuất ảnh chụp nhanh) trên thanh công cụ của Layout Inspector và lưu ảnh chụp nhanh ở dạng tệp có đuôi *.li . Sau đó, bạn có thể tải ảnh chụp nhanh của Layout Inspector bằng cách chọn File > Open (Tệp > Mở) trên thanh trình đơn chính rồi mở tệp *.li . Ảnh chụp nhanh sẽ xuất hiện trên một thẻ trong cửa sổ Trình chỉnh sửa để bạn có thể dễ dàng so sánh thông tin này với ứng dụng đang chạy.

Tính năng mới trong cửa sổ Kiểm tra ứng dụng

Trong Android Studio Bumblebee, cửa sổ Kiểm tra ứng dụng có một số công cụ và chức năng mới. Bạn có thể mở App Inspector (Trình kiểm tra ứng dụng) bằng cách chọn View > Tool Windows > App Inspection (Xem > Cửa sổ công cụ > Kiểm tra ứng dụng) trên thanh trình đơn chính.

Công cụ kiểm tra mạng

Giờ đây, Trình phân tích mạng trong cửa sổ công cụ Profilers (Trình phân tích tài nguyên) đã chuyển sang cửa sổ công cụ App Inspection (Kiểm tra ứng dụng). Nếu bạn đã từng dùng Trình phân tích mạng, thì tất cả các tính năng tương tự và dữ liệu đa dạng về lưu lượng truy cập mạng sẽ vẫn được cung cấp. Bạn chỉ cần triển khai ứng dụng của mình cho một thiết bị chạy API cấp 26 trở lên và mở thẻ App Inspector > Network Inspector (Công cụ kiểm tra ứng dụng > Công cụ kiểm tra mạng).

Kiểm tra Công việc, Chuông báo và Hoạt động khoá chế độ thức

Background Task Inspector (Công cụ kiểm tra tác vụ trong nền) hiện cho phép bạn kiểm tra Công việc, Chuông báo và Hoạt động khoá chế độ thức của ứng dụng, ngoài chức năng hỗ trợ hiện tại để kiểm tra Worker (Trình chạy). Giờ đây, mỗi loại tác vụ không đồng bộ sẽ xuất hiện với tiêu đề phù hợp trong thẻ công cụ kiểm tra, cho phép bạn dễ dàng theo dõi trạng thái và tiến trình của tác vụ đó. Tương tự với Worker (Trình chạy), bạn cũng có thể chọn một Công việc, Chuông báo hoặc Hoạt động khoá chế độ thức để kiểm tra thông tin chi tiết của trình chạy đó trong bảng Task Details (Thông tin chi tiết về tác vụ).

Lưu ý: Background task inspector (Công cụ kiểm tra tác vụ trong nền) để kiểm tra tất cả các tác vụ không đồng bộ của ứng dụng. Chúng tôi đã di chuyển chức năng này từ Trình phân tích năng lượng . Vì vậy, giờ đây, bạn nên sử dụng(Công cụ kiểm tra tác vụ trong nền) để kiểm tra tất cả các tác vụ không đồng bộ của ứng dụng.

Do Worker (Trình chạy) sử dụng Công việc và Hoạt động khoá chế độ thức nâng cao, nên các tác vụ mà Worker (Trình chạy) đã lên lịch sẽ xuất hiện ở dạng phần tử con của mỗi Worker (Trình chạy). Xin lưu ý rằng bạn chỉ có thể xem Worker (Trình chạy) ở chế độ Biểu đồ.

Gỡ lỗi qua Wi-Fi

Android Studio Bumblebee hỗ trợ tính năng gỡ lỗi qua Wi-Fi trên các thiết bị Android 11 trở lên. Ghép nối và triển khai ứng dụng của bạn trên Android Studio qua Wi-Fi mà không cần sử dụng cáp USB hoặc quản lý các kết nối của Cầu gỡ lỗi Android (adb) bằng dòng lệnh. Để sử dụng, hãy chuyển đến tuỳ chọn Pair devices using Wi-Fi (Ghép nối thiết bị bằng Wi-Fi) trong trình đơn chọn thiết bị, sau đó chọn một mã QR hoặc mã ghép nối ở dạng mã PIN. Sau đó, trên thiết bị Android 11 trở lên, trong mục Tuỳ chọn cho nhà phát triển, hãy tìm màn hình Gỡ lỗi qua Wi-Fi rồi khởi chạy và kết nối với một phiên adb qua Wi-Fi bằng Android Studio. Hãy tìm hiểu thêm về tính năng gỡ lỗi qua Wi-Fi qua bài viết Kết nối với thiết bị qua Wi-Fi (Android 11 trở lên).

Trình chạy kiểm thử hợp nhất cho Gradle

Trình bổ trợ Android cho Gradle 7.1.0 và Android Studio Bumblebee trở lên sử dụng hoạt động triển khai riêng của Gradle đối với trình chạy kiểm thử được đo lường cho Android để chạy các hoạt động kiểm thử được đo lường. Bằng cách sử dụng cùng một trình chạy kiểm thử, các kết quả có thể nhất quán cho dù bạn chạy bằng AGP từ dòng lệnh, chẳng hạn như trên máy chủ tích hợp liên tục, hay từ Android Studio.

Các phiên bản cũ của Android Studio sử dụng trình chạy kiểm thử được đo lường cho Android phiên bản IntelliJ thay vì trình chạy kiểm thử được đo lường cho Android của Gradle. Vì vậy, nếu không sử dụng Android Studio phiên bản mới nhất, tuỳ thuộc vào việc bạn chạy chương trình kiểm thử bằng Android Studio hay bằng dòng lệnh với Plugin Gradle, thì bạn có thể thấy các kết quả kiểm thử khác nhau, chẳng hạn như chương trình kiểm thử cho kết quả đạt trên một trình chạy này nhưng lại cho kết quả không đạt trên một trình chạy khác.

Nếu bạn đã lưu cấu hình kiểm thử được đo lường vào dự án của mình, thì các cấu hình này sẽ sử dụng Gradle để chạy hoạt động kiểm thử trên thiết bị đã kết nối. Bạn có thể tạo một cấu hình mới cho hoạt động kiểm thử được đo lường bằng cách sử dụng thao tác định hướng bên cạnh lớp hoặc phương thức kiểm thử, như thể hiện dưới đây.

Khi chạy các hoạt động kiểm thử được đo lường, bạn có thể xác nhận rằng Android Studio đang sử dụng trình chạy kiểm thử của Gradle bằng cách kiểm tra đầu ra của hoạt động kiểm thử trong Ma trận thử nghiệm cho đầu ra tác vụ của Gradle. Mặc dù, chúng tôi đang cải thiện tính năng này trong mỗi bản phát hành của Android Studio, nhưng vẫn có một số vấn đề đã biết. Nếu bạn đang gặp vấn đề, hãy báo cáo lỗi. Bạn cũng có thể tắt quy trình kiểm thử mới để quay lại hành vi cũ.

Theo mặc định, Trình mô phỏng Android hiện chạy trực tiếp bên trong Android Studio

Theo mặc định, Trình mô phỏng Android chạy trực tiếp bên trong Android Studio. Điều này cho phép bạn bảo toàn chế độ hiển thị màn hình, di chuyển nhanh giữa trình mô phỏng và cửa sổ trình chỉnh sửa bằng cách sử dụng phím tắt, đồng thời sắp xếp quy trình cho IDE và trình mô phỏng trong một cửa sổ ứng dụng duy nhất.

Khi trình mô phỏng đang chạy, bạn có thể thực hiện các hành động phổ biến trong trình mô phỏng như xoay và dùng các chế độ điều khiển mở rộng như phát và điều hướng. Để chạy trình mô phỏng trong một cửa sổ riêng, hãy chuyển đến File (Tệp) > Settings (Cài đặt) > Tools (Công cụ) > Emulator (Trình mô phỏng) (Android Studio > Preferences (Lựa chọn ưu tiên) > Tools (Công cụ) > Emulator (Trình mô phỏng) trên macOS) rồi bỏ chọn Launch in a tool window (Chạy trong cửa sổ công cụ).

Tắt quy trình kiểm thử mới

Theo mặc định, Android Studio Bumblebee sử dụng Gradle để chạy các hoạt động kiểm thử được đo lường của mình. Nếu đang gặp vấn đề, bạn có thể vô hiệu hoá hành vi này như sau:

Chọn File (Tệp) > Settings (Cài đặt) > Build, Execution, Deployment (Xây dựng, Thực thi, Triển khai) > Testing (Kiểm thử) (hoặc Android Studio > Preferences (Tuỳ chọn) > Build, Execution, Deployment (Xây dựng, Thực thi, Triển khai) > Testing (Kiểm thử) đối với MacOS.) Bỏ đánh dấu hộp bên cạnh Run Android instrumented tests using Gradle (Chạy các hoạt động kiểm thử được đo lường cho Android bằng Gradle) rồi nhấp vào OK.

Bạn cũng có thể quay lại các hành vi cũ bằng cách thực hiện một trong những thao tác sau đây:

Khi chạy các tác vụ của Gradle từ dòng lệnh, hãy sử dụng tham số dòng lệnh sau: -Pandroid.experimental.androidTest.useUnifiedTestPlatform=false

Thêm tham số sau đây vào tệp gradle.properties của dự án: android.experimental.androidTest.useUnifiedTestPlatform=false

Để giải quyết các vấn đề mà bạn có thể gặp phải, hãy báo cáo lỗi.

Trình quản lý thiết bị mới

Device Manager (Trình quản lý thiết bị) là một ứng dụng thay thế độc lập cho Trình quản lý thiết bị ảo Android, trên cả Màn hình chào mừng của Android Studio hoặc sau khi bạn mở một dự án. Trình quản lý thiết bị giới thiệu một số tính năng mới giúp bạn dễ dàng tạo và quản lý tất cả thiết bị thử nghiệm trên máy, chẳng hạn như:

Một giao diện người dùng linh hoạt hơn hỗ trợ việc đưa vào môi trường phát triển tích hợp (IDE), thành phần nổi hoặc một cửa sổ riêng biệt, chẳng hạn như bạn có thể đưa vào các cửa sổ công cụ khác của Android Studio. Điều này giúp bạn dễ dàng truy cập vào các thiết bị của mình hơn mà không gây trở ngại các cửa sổ khác của IDE.

Thẻ Virtual (Ảo) cho phép bạn tạo, quản lý và triển khai các thiết bị ảo; xem nhanh thông tin chi tiết về từng thiết bị; hoặc kiểm tra nhanh thiết bị trong Trình khám phá tệp trên thiết bị chỉ bằng một thao tác nhấp chuột.

(Ảo) cho phép bạn tạo, quản lý và triển khai các thiết bị ảo; xem nhanh thông tin chi tiết về từng thiết bị; hoặc kiểm tra nhanh thiết bị trong Trình khám phá tệp trên thiết bị chỉ bằng một thao tác nhấp chuột. Thẻ Physical (Thực) cho phép bạn nhanh chóng ghép nối với một thiết bị mới bằng cách sử dụng Cầu gỡ lỗi Android (ADB) qua Wi-Fi và xem nhanh thông tin chi tiết về từng thiết bị thực. Bạn cũng có thể nhanh chóng kiểm tra hệ thống tệp của từng thiết bị bằng Trình khám phá tệp trên thiết bị chỉ với một thao tác nhấp vào nút.

Để mở Device Manager (Trình quản lý thiết bị) mới, hãy làm theo một trong những cách sau:

Trên màn hình Chào mừng của Android Studio, hãy chọn More Actions (Thao tác khác) > Virtual Device Manager (Trình quản lý thiết bị ảo).

Lưu ý: Hiện tại, bạn chỉ có thể tạo và quản lý các thiết bị ảo trên màn hình chào mừng.

Sau khi mở một dự án, hãy chọn View (Xem) > Tool Windows (Cửa sổ công cụ) > Device Manager (Trình quản lý thiết bị) trên thanh trình đơn chính.

Phát hiện giao diện người dùng bị giật

Giờ đây, khi tạo hồ sơ cho ứng dụng bằng thiết bị chạy Android 11 (API cấp 30) trở lên, hồ sơ CPU sẽ cho thấy một nhóm kênh theo dõi mới minh hoạ các giai đoạn của mỗi khung hình trong Vòng đời khung hình: Ứng dụng, Chờ GPU, Quá trình kết hợp và Khung hình hiển thị. Mỗi kênh sẽ gắn nhãn các khung có số khung và mã màu bằng hình chữ nhật để giúp bạn dễ dàng trực quan hoá vị trí của một khung cụ thể trong vòng đời, cùng với hướng dẫn mà bạn có thể bật/tắt để so sánh Sự kiện Vsync. Bạn có thể sử dụng dữ liệu này để hiểu vị trí có thể xảy ra tình trạng giật trong ứng dụng và điều tra nguyên nhân gốc rễ. Trong bảng Phân tích, hiện có một thẻ Khung, giúp bạn tóm tắt thông tin kết xuất cho tất cả khung hình một cách thuận tiện. Để biết thêm thông tin, hãy xem bài viết Phát hiện giao diện người dùng trên giao diện người dùng.

Hỗ trợ hồ sơ ứng dụng

Khi tạo hồ sơ cho ứng dụng, điều quan trọng là bạn phải tạo dữ liệu chính xác bằng phiên bản ứng dụng giống nhất với phiên bản mà người dùng sẽ cài đặt. Để làm như vậy, giờ đây, bạn có thể đưa thuộc tính vào tệp kê khai của ứng dụng để các ứng dụng hồ sơ không thể gỡ lỗi, như mã thể hiện dưới đây.

Hồ sơ có thể định cấu hình là tệp cấu hình tệp kê khai được giới thiệu trong Android 10, đồng thời có sẵn cho các tác vụ lập hồ sơ CPU và Bộ nhớ. Việc sử dụng cờ có thể định cấu hình thay vì cờ có thể gỡ lỗi có lợi thế là chi phí thấp hơn để đo lường hiệu suất; tuy nhiên, một số tính năng hồ sơ nhất định (dùng từ rõ nghĩa hơn) cho các bản dựng có thể lập hồ sơ, chẳng hạn như tiến trình Sự kiện, hồ sơ API do khởi tạo, tệp kết xuất của vùng nhớ khối xếp hoặc bản ghi vị trí trực tiếp. Để biết thêm thông tin, hãy xem Ứng dụng có thể lập hồ sơ.

Thu gọn khung Callstack

Bây giờ, bạn có thể thu gọn các khung không liên quan đến cuộc điều tra khi kiểm tra Bản ghi mẫu Callstack trong cửa sổ công cụ Profilers. Các ngăn xếp lệnh gọi rất hữu ích trong việc giúp bạn nắm rõ được phần nào của mã đã được thực thi và lý do lệnh đó được gọi. Tuy nhiên, ngăn xếp cho chương trình Java/Kotlin thường không chỉ bao gồm mã Java/Kotlin, mà còn bao gồm các khung từ mã gốc có thể gây mất tập trung. Để tìm hiểu thêm về cách tinh chỉnh chế độ xem Callstack, hãy xem Kiểm tra khung callstack.

Bản phát hành của bản vá

Dưới đây là danh sách các bản phát hành của Bản vá trong Android Studio Bumblebee.

Android Studio Bumblebee | 2021.1.1 Bản vá 3 (Tháng 4 năm 2022)

Bản cập nhật nhỏ này bao gồm các bản sửa lỗi sau:

Trình bổ trợ Android cho Gradle Các vấn đề trùng lặp về lớp do R8 báo cáo

Biến thể xây dựng versionNameSuffix không còn hoạt động nữa nếu tên phiên bản của biến thể được đặt thông qua API onVariant mới

Tính năng xem trước trong Compose Sửa lỗi liên quan đến hiệu suất và độ ổn định. Giải quyết tình trạng ứng dụng bị treo đôi khi xảy ra khi dùng tính năng Chỉnh sửa trực tiếp của Literals

Công cụ kiểm tra mạng Công cụ kiểm tra mạng mới gặp sự cố sau khi cập nhật Bumblebee Tôi liên tục gặp lỗi này khi trình gỡ lỗi được kết nối trên phiên bản Android Studio mới nhất. TrackedHttpURLConnection.getHeaderField gặp sự cố với NullPointerException

Để biết thêm thông tin, hãy xem Bài đăng trên blog về Android Studio Bumblebee Bản vá 1

Android Studio Bumblebee | 2021.1.1 Bản vá 2 (tháng 2/2022)

Bản cập nhật này bao gồm các bản sửa lỗi sau:

Bản dựng C++ ModelCache.safeGet(androidProjectResult.androidProject::getNdkVersion, “”) không được có giá trị rỗng

Trình soạn thảo mã Lỗi trong Mẫu trực tiếp của Android Studio – biểu thức className() không phân giải tên lớp

D8/R8 java.lang.NoSuchMethodError: Không có phương thức $jacocoInit tĩnh Phạm vi kiểm thử Android không hoàn thành do lỗi Mockito Cần có giải pháp cho quá trình triển khai CAS không thành công trên API 31 Lớp kín không được hỗ trợ NullPointerExceptions khi bật tính năng hợp nhất lớp theo chiều ngang trong Chrome AbstractMethodError sau khi hợp nhất phương thức ảo Không xác minh được khung ngăn xếp do loại đầu ra khởi tạo lớp không đúng Đầu vào Dex sử dụng một thanh ghi chưa được xác định StringBuilderOptimizerAnalysisTest không thực hiện được trên các nhánh của bản phát hành Thuyết không đơn định trong R8

Bản triển khai Không chạy được dự án của ứng dụng chủ sở hữu thiết bị với thông báo lỗi là “Không chấm dứt được quy trình hiện tại của”

Công cụ thiết kế Bản xem trước của Compose không tìm thấy tài nguyên từ các mô-đun khác khi lớp R không mang tính chất bắc cầu ở trạng thái bật Studio bị treo trong quá trình xây dựng.

Trình mô phỏng được nhúng Các điểm cải tiến khác về hiệu suất và độ ổn định.

Nhập/Đồng bộ hoá Lỗi IDE khi chạy Bumblebee: Không có tệp bản dựng liệt kê danh sách đầu ra cho APK loại đầu ra trong IdeBuildTaskAndOutput Informationimp

IntelliJ Các biến Env không được cung cấp khi chạy trên Mac OS X Monterey Dock

Jetpack (AndroidX) > Điều hướng Nâng cấp SafeArgs được xây dựng dựa trên AGP ổn định mới nhất

Cửa sổ công cụ Không chạy được Trình quản lý thiết bị Android Công cụ kiểm tra mạng trong BumbleBee không hiển thị phản hồi của API ở định dạng có thể đọc được

Để biết thêm thông tin, hãy xem bài đăng trên blog về Android Studio Bumblebee Bản vá 2.

Android Studio Bumblebee | 2021.1.1 Bản vá 1 (tháng 2/2022)

Bản cập nhật nhỏ này bao gồm các bản sửa lỗi sau:

Trình mô phỏng Không kết nối được với trình mô phỏng được nhúng sau khi nâng cấp lên Bumblebee (máy Mac M1)

IntelliJ Các biến Env không được cung cấp khi chạy trên Mac OS X Monterey Dock

Để biết thêm thông tin, hãy xem bài đăng trên blog về Android Studio Bumblebee Bản vá 1.

Android Studio Arctic Fox | 2020.3.1

Android Studio Bumblebee là một bản phát hành chính có nhiều tính năng và điểm cải tiến sau.

Đánh số phiên bản mới

Chúng tôi đã thay đổi hệ thống đánh số phiên bản cho Android Studio để phù hợp hơn với IntelliJ IDEA, IDE mà Android Studio dựa trên đó.

Trong hệ thống đánh số cũ, bản phát hành này sẽ được đánh số là Android Studio 4.3 hoặc phiên bản 4.3.0.1. Với hệ thống đánh số mới, bản phát hành này giờ đây sẽ là Android Studio – Arctic Fox | 2020.3.1 hoặc phiên bản 2020.3.1.

Phiên bản Intellij Tên cũ Cũ – Hệ thống số Mới – Hệ thống năm Tên phiên bản mới 2020.3 4.3 4.3.0 2020.3.1 Arctic Fox | 2020.3.1

Sau đây là cách xác định số phiên bản Android Studio:

. . .

2 nhóm số đầu tiên thể hiện phiên bản của nền tảng IntellIj mà một bản phát hành Android Studio cụ thể sẽ dựa vào đó. Đối với bản phát hành này, đây là phiên bản 2020.3.

Nhóm số thứ ba đại diện cho phiên bản chính của Studio, bắt đầu từ 1 và tăng dần từng phiên bản một cho mỗi bản phát hành chính.

Nhóm số thứ tư đại diện cho phiên bản nhỏ/bản vá của Studio, bắt đầu từ 1 và tăng dần từng phiên bản một cho mỗi bản phát hành nhỏ.

Chúng tôi cũng đặt tên phiên bản cho từng bản phát hành chính, tăng dần từ A đến Z dựa trên tên của các loài động vật. Bản phát hành này có tên là Arctic Fox.

Chúng tôi đã thay đổi cách đánh số phiên bản áp dụng với trình bổ trợ Android cho Gradle (AGP) để phù hợp hơn với công cụ xây dựng cơ bản của Gradle. Do đó, AGP 7.0 là bản phát hành tiếp theo sau AGP 4.2.

Để biết thêm thông tin chi tiết, hãy xem phần Các thay đổi liên quan đến việc tạo phiên bản trong ghi chú phát hành của AGP.

Trình bổ trợ Android cho Gradle 7.0.0

Phiên bản mới nhất của trình bổ trợ Android cho Gradle sẽ bao gồm nhiều bản cập nhật. Để tìm hiểu thêm, hãy đọc ghi chú phát hành đầy đủ của trình bổ trợ Android cho Gradle.

Hoạt động kiểm thử đơn vị hiện dùng trình chạy kiểm thử của Gradle

Để cải thiện tính nhất quán chung của các phiên chạy thử nghiệm, Android Studio hiện sử dụng Gradle để chạy mọi hoạt động kiểm thử đơn vị theo mặc định. Trong nhiều trường hợp, sự thay đổi này sẽ không ảnh hưởng đến quy trình kiểm thử của bạn trong IDE.

Ví dụ: Khi bạn nhấp vào lệnh Run (Chạy) trong trình đơn theo bối cảnh (hiển thị khi bạn nhấp chuột phải vào một lớp kiểm thử) hoặc thao tác định hướng tương ứng của lệnh đó, theo mặc định, Android Studio sẽ sử dụng cấu hình chaỵ của Gradle để chạy các hoạt động kiểm thử đơn vị.

Tuy nhiên, Android Studio không nhận dạng các cấu hình chạy JUnit hiện có của Android nữa, vì vậy, bạn nên di chuyển các cấu hình chạy JUnit của Android mà bạn có thể lưu ở dạng tệp dự án sang cấu hình chạy của Gradle.

Để tạo một cấu hình kiểm thử của Gradle, hãy chọn mẫu Gradle trong khi làm theo các hướng dẫn trong bài viết Tạo một cấu hình chạy/gỡ lỗi mới. Khi bạn đã tạo một cấu hình mới, cấu hình đó sẽ xuất hiện trong hộp thoại Edit Configurations (Chỉnh sửa cấu hình) trong phần Gradle:

Nếu muốn kiểm tra các cấu hình JUnit của Android hiện không nhận dạng được nữa, thì bạn có thể làm một trong hai việc sau:

Mở cấu hình đã lưu thủ công trong trình chỉnh sửa văn bản. Vị trí của các tệp này do người dùng chỉ định, nhưng các tệp thường xuất hiện trong /.idea/runConfigurations/ .

. Tìm các cấu hình tạm thời trong /.idea/workspace.xml và tìm ở bên dưới nút . Ví dụ:

Công cụ kiểm tra tác vụ trong nền phiên bản mới

Bạn có thể minh hoạ trực quan, theo dõi và gỡ lỗi các trình chạy trong nền của ứng dụng bằng Công cụ kiểm tra tác vụ trong nền phiên bản mới. Để bắt đầu, hãy triển khai ứng dụng của bạn trên một thiết bị chạy thư viện WorkManager 2.5.0 trở lên rồi chọn View (Xem) > Tool Windows (Cửa sổ công cụ) > App Inspection (Kiểm tra ứng dụng) trên thanh trình đơn.

Bạn có thể xem thêm thông tin chi tiết bằng cách nhấp vào một trình chạy. Ví dụ: Bạn có thể xem nội dung mô tả về trình chạy này, cách thực thi trình chạy, thông tin chi tiết về chuỗi trình chạy và kết quả thực thi.

Bạn cũng có thể xem hình ảnh biểu diễn của một chuỗi trình chạy bằng cách chọn một trình chạy trong bảng rồi nhấp vào biểu tượng Show Graph View (Hiện thành phần hiển thị biểu đồ) trên thanh công cụ. Sau đó, bạn có thể chọn bất kỳ trình chạy nào trong chuỗi để xem thông tin chi tiết hoặc dừng trình chạy nếu nó đang ở trong hàng đợi hoặc đang chạy. Để quay lại bảng, hãy nhấp vào biểu tượng Show List View (Hiện thành phần hiển thị danh sách) .

Để giúp bạn điều tra vấn đề của các trình chạy không thực thi được, bạn có thể dừng một trình chạy đang chạy hoặc đang ở trong hàng đợi bằng cách chọn nó trong bảng rồi nhấp vào biểu tượng Cancel Selected Worker (Huỷ trình chạy đã chọn) trên thanh công cụ. Bạn cũng có thể lọc trình chạy trong bảng theo thẻ mà bạn đã chỉ định cho trình chạy đó bằng cách dùng trình đơn thả xuống All tags (Tất cả các thẻ).

Cập nhật Trình kiểm tra cơ sở dữ liệu

Database Inspector (Trình kiểm tra cơ sở dữ liệu) hiện đã có trong cửa sổ công cụ mới App Inspection (Kiểm tra ứng dụng). Bạn cũng có thể tìm thấy Background Task Inspector (Công cụ kiểm tra tác vụ trong nền) phiên bản mới ở đây. Mở cửa sổ công cụ App Inspection (Kiểm tra ứng dụng) trên thanh cửa sổ công cụ hoặc chọn View (Xem) > Tool Windows (Cửa sổ công cụ) > App Inspection (Kiểm tra ứng dụng) trên thanh trình đơn.

Xuất dữ liệu trên Trình kiểm tra cơ sở dữ liệu

Trong Arctic Fox, bạn có thể dễ dàng xuất cơ sở dữ liệu, bảng và kết quả truy vấn trên Database Inspector (Trình kiểm tra cơ sở dữ liệu) để lưu, chia sẻ hoặc tạo lại trên máy. Khi mở dự án ứng dụng trong Android Studio và kiểm tra ứng dụng của dự án đó trong Database Inspector (Trình kiểm tra cơ sở dữ liệu), bạn có thể bắt đầu xuất dữ liệu theo một trong những cách sau:

Chọn một cơ sở dữ liệu hoặc bảng trong bảng Databases (Cơ sở dữ liệu) rồi nhấp vào Export to file (Xuất sang tệp) ở gần đầu bảng.

(Cơ sở dữ liệu) rồi nhấp vào (Xuất sang tệp) ở gần đầu bảng. Nhấp chuột phải vào một cơ sở dữ liệu hoặc bảng trong bảng Databases (Cơ sở dữ liệu), rồi chọn Export to file (Xuất sang tệp) từ trình đơn ngữ cảnh.

(Cơ sở dữ liệu), rồi chọn (Xuất sang tệp) từ trình đơn ngữ cảnh. Khi kiểm tra một bảng hoặc kết quả truy vấn trong một thẻ, hãy nhấp vào Export to file (Xuất sang tệp) ở phía trên bảng hoặc kết quả truy vấn.

Sau khi chọn một hành động xuất, bạn sẽ sử dụng hộp thoại Xuất để giúp bạn thực hiện các bước cuối cùng, như hiển thị bên dưới. Tuỳ thuộc vào việc bạn đang cố gắng xuất cơ sở dữ liệu, bảng hay kết quả truy vấn, bạn có thể chọn xuất dữ liệu ở một hoặc nhiều định dạng sau: DB, SQL hoặc CSV.

Cập nhật giao diện người dùng để ghi trong Trình phân tích bộ nhớ

Chúng tôi đã hợp nhất giao diện người dùng (UI) của Trình phân tích bộ nhớ cho nhiều hoạt động ghi, chẳng hạn như ghi tệp báo lỗi và ghi lại quá trình phân bổ cho Java, Kotlin, cũng như bộ nhớ gốc.

Trình phân tích bộ nhớ cung cấp các tuỳ chọn sau:

Capture heap dump (Ghi tệp báo lỗi): Xem các đối tượng trong ứng dụng đang sử dụng bộ nhớ tại một thời điểm cụ thể.

(Ghi tệp báo lỗi): Xem các đối tượng trong ứng dụng đang sử dụng bộ nhớ tại một thời điểm cụ thể. Record native allocations (Ghi lại quá trình phân bổ gốc): Xem cách thức phân bổ đối với mỗi đối tượng C/C++ trong một khoảng thời gian.

(Ghi lại quá trình phân bổ gốc): Xem cách thức phân bổ đối với mỗi đối tượng C/C++ trong một khoảng thời gian. Record Java/Kotlin allocations (Ghi lại quá trình phân bổ cho Java/Kotlin): Xem cách thức phân bổ đối với mỗi đối tượng Java/Kotlin trong một khoảng thời gian.

Dưới đây là cách sử dụng 3 tuỳ chọn này:

Để ghi tệp báo lỗi, hãy nhấp vào Capture heap dump (Ghi tệp báo lỗi), sau đó chọn Record (Ghi). Sau khi trình phân tích tài nguyên hoàn tất việc ghi tệp báo lỗi, giao diện người dùng của Trình phân tích bộ nhớ sẽ chuyển sang một màn hình riêng hiển thị tệp báo lỗi.

Để ghi lại các lượt phân bổ mã gốc trên thiết bị chạy Android 10 trở lên, hãy chọn Record native allocations (Ghi mức phân bổ cho mã gốc), sau đó chọn Record (Ghi). Quá trình ghi sẽ tiếp tục cho đến khi bạn nhấp vào nút Stop (Dừng) , sau đó, giao diện người dùng của Trình phân tích bộ nhớ sẽ chuyển sang một màn hình riêng hiển thị quá trình ghi gốc. Trên Android 9 trở xuống, bạn không sử dụng được tuỳ chọn Record native allocations (Ghi lại quá trình phân bổ gốc).

Để ghi lại mức phân bổ cho Java và Kotlin, hãy chọn Record Java / Kotlin allocations (Ghi lại mức phân bổ cho Java/Kotlin), sau đó chọn Record (Ghi). Nếu thiết bị đang chạy Android 8 trở lên, thì giao diện người dùng của Trình phân tích bộ nhớ sẽ chuyển sang một màn hình riêng hiển thị quá trình ghi đang diễn ra. Bạn có thể tương tác với tiến trình thu nhỏ ở phía trên bản ghi (ví dụ: để thay đổi phạm vi lựa chọn). Để hoàn tất quá trình ghi, hãy chọn biểu tượng Stop (Dừng) . Trên Android 7.1 trở xuống, trình phân tích bộ nhớ sử dụng tính năng ghi quá trình phân bổ cũ, cho thấy quá trình ghi trên tiến trình cho đến khi bạn nhấp vào Stop (Dừng).

Cập nhật tuỳ chọn Làm mới dự án C++ đã liên kết

Chúng tôi đã di chuyển các tệp không liên quan đến cấu hình từ thư mục .cxx/ vào thư mục build/ . Các bản dựng CMake C++ cần có một giai đoạn định cấu hình giúp tạo dự án Ninja dùng để thực thi các bước biên dịch và liên kết. Các dự án tạo bằng CMake rất tốn kém chi phí và dự kiến sẽ tiếp tục có hiệu lực khi không có Gradle. Vì lý do này, các dự án sẽ được lưu trữ trong thư mục có tên .cxx/ , bên cạnh thư mục build/ . Thông thường, trình bổ trợ Android cho Gradle sẽ nhận thấy các thay đổi về cấu hình và tự động tạo lại dự án Ninja. Tuy nhiên, không phải trường hợp nào cũng có thể được phát hiện. Khi trường hợp này xảy ra, tuỳ chọn “Refresh Linked C++ Project” (Làm mới dự án C++ đã liên kết) có thể được dùng để tạo lại dự án Ninja theo cách thủ công.

Ma trận thử nghiệm mới cho quá trình kiểm thử nhiều thiết bị

Giờ đây, các hoạt động kiểm thử đo lường có thể chạy song trên nhiều thiết bị và được điều tra thông qua một bảng điều khiển chuyên dùng về kết quả kiểm thử đo lường. Khi sử dụng bảng điều khiển này, bạn có thể xác định được rằng hoạt động kiểm thử có trạng thái không đạt là do cấp độ API hay do thuộc tính phần cứng.

Việc kiểm thử ứng dụng trên nhiều kiểu dáng và cấp độ API là một trong những cách tốt nhất nhằm mang lại trải nghiệm tuyệt vời cho tất cả người dùng khi họ dùng ứng dụng.

Để tận dụng tính năng này, hãy làm như sau:

Chọn Select Multiple Devices (Chọn nhiều thiết bị) trong trình đơn thả xuống thiết bị mục tiêu ở trên cùng chính giữa của IDE. Chọn thiết bị mục tiêu rồi nhấp vào OK. Chạy hoạt động kiểm thử.

Để xem kết quả kiểm thử, trong bảng điều khiển Run (Chạy), hãy chuyển đến phần View > Tool Windows > Run (Xem > Cửa sổ công cụ > Chạy).

Bảng điều khiển mới về kết quả kiểm thử giúp bạn lọc kết quả kiểm thử theo trạng thái, thiết bị và cấp độ API. Ngoài ra, bạn có thể sắp xếp từng cột bằng cách nhấp vào tiêu đề. Khi nhấp vào một hoạt động kiểm thử riêng lẻ, bạn có thể xem riêng nhật ký và thông tin về thiết bị của từng thiết bị.

Hỗ trợ StateFlow trong liên kết dữ liệu

Đối với các ứng dụng Kotlin dùng coroutine, giờ đây, bạn có thể sử dụng các đối tượng StateFlow làm nguồn liên kết dữ liệu để tự động thông báo cho giao diện người dùng về các thay đổi trong dữ liệu. Các liên kết dữ liệu của bạn sẽ nhận biết được vòng đời và chỉ được kích hoạt khi giao diện người dùng hiển thị trên màn hình.

Để dùng một đối tượng StateFlow với lớp liên kết, bạn cần chỉ định một chủ sở hữu vòng đời để xác định phạm vi của đối tượng StateFlow . Đồng thời, trong bố cục của bạn, hãy chỉ định các thuộc tính và phương thức của thành phần ViewModel cho thành phần hiển thị tương ứng thông qua biểu thức liên kết, như thể hiện trong ví dụ sau đây:

class ViewModel() { val username: StateFlow }

Nếu bạn đang dùng ứng dụng Kotlin sử dụng AndroidX, thì chức năng hỗ trợ StateFlow sẽ tự động được đưa vào chức năng liên kết dữ liệu, bao gồm cả phần phụ thuộc của coroutine.

Để tìm hiểu thêm, hãy xem bài viết Làm việc với các đối tượng dữ liệu có thể quan sát.

Cải thiện thành phần nhập đề xuất

Chúng tôi đã cải thiện số lượng thư viện được tính năng thành phần nhập đề xuất hỗ trợ và cập nhật chỉ mục thường xuyên hơn. Tính năng thành phần nhập đề xuất giúp bạn dễ dàng và nhanh chóng nhập một số cấu phần mềm Maven của Google vào cả lớp và dự án Gradle. Khi Android Studio phát hiện thấy các biểu tượng chưa được giải quyết cho một số thư viện của Google, IDE sẽ đề xuất nhập thư viện vào cả lớp và dự án.

Hỗ trợ bộ nhớ đệm cấu hình trong Trình phân tích bản dựng

Trình phân tích bản dựng hiện xác định thời điểm một dự án không bật bộ nhớ đệm cấu hình và cung cấp dự án ở dạng tối ưu hoá. Trình phân tích bản dựng sẽ chạy quá trình đánh giá khả năng tương thích để thông báo cho bạn nếu có bất kỳ vấn đề nào với bộ nhớ đệm cấu hình trong dự án trước khi bộ nhớ này được bật.

Cải thiện Trợ lý nâng cấp cho AGP

Giờ đây, Trợ lý nâng cấp của trình bổ trợ Android cho Gradle sẽ có một cửa sổ công cụ xuất hiện liên tục, trong đó hiện danh sách các bước cần được hoàn thành. Thông tin bổ sung cũng sẽ xuất hiện ở phía bên phải của cửa sổ công cụ. Nếu cần, bạn cũng có thể chọn một phiên bản AGP khác để nâng cấp lên. Thao tác nhấp vào nút Refresh (Làm mới) sẽ cập nhật các bước cập nhật tương ứng.

Hoạt động tái cấu trúc đối với lớp R không mang tính chất bắc cầu

Bạn có thể sử dụng các lớp R không mang tính chất bắc cầu với trình bổ trợ Android cho Grade để tạo các bản dựng nhanh hơn cho các ứng dụng có nhiều mô-đun. Làm như vậy sẽ giúp ngăn chặn tình trạng trùng lặp tài nguyên bằng cách đảm bảo rằng lớp R của mỗi mô-đun chỉ chứa tệp đối chiếu đến tài nguyên riêng của mô-đun đó mà không cần lấy các tệp đối chiếu từ các phần phụ thuộc tương ứng. Điều này giúp chúng ta có các bản dựng mới hơn cũng như nhận được các lợi ích tương ứng khi tránh hoạt động biên dịch.

Bạn có thể sử dụng tính năng này bằng cách chuyển đến Refactor > Migrate to Non-transitive R Classes (Tái cấu trúc > Di chuyển đến lớp R không mang tính chất bắc cầu).

Lưu ý: Trước đây, tuỳ chọn sử dụng các lớp R không mang tính chất bắc cầu với AGP sẽ chỉ áp dụng cho các thư viện. Giờ đây, trong AGP 4.2 trở lên, tuỳ chọn này sẽ áp dụng cho tất cả các mô-đun.

Hỗ trợ cho công cụ Jetpack Compose

Chúng tôi hiện cung cấp chức năng hỗ trợ bổ sung cho các ứng dụng xem trước và kiểm thử sử dụng Jetpack Compose. Để có trải nghiệm tốt nhất khi phát triển bằng Jetpack Compose, bạn nên dùng Android Studio Arctic Fox phiên bản mới nhất để nhận được lợi ích từ các tính năng của trình chỉnh sửa thông minh, chẳng hạn như các mẫu New Project (Dự án mới) và khả năng xem trước ngay giao diện người dùng trong Compose.

Tính năng xem trước trong Compose

Hiện đã có các tham số sau đây cho phương thức @Preview:

showBackground : Bật và tắt một nền cho bản xem trước.

: Bật và tắt một nền cho bản xem trước. backgroundColor : Đặt một màu mà chỉ được dùng trong giao diện xem trước.

: Đặt một màu mà chỉ được dùng trong giao diện xem trước. uiMode: Tham số mới này có thể lấy bất kỳ hằng số Configuration.UI_* nào và cho phép bạn thay đổi hành vi của bản xem trước để, chẳng hạn như đặt thành Chế độ ban đêm để xem phản ứng của giao diện này.

Bản xem trước tương tác

Bạn có thể sử dụng tính năng này để tương tác với các thành phần giao diện người dùng, nhấp vào các thành phần đó và xem trạng thái sẽ thay đổi như thế nào. Đây là một cách nhanh chóng để nhận được thông tin phản hồi về cách phản ứng của giao diện người dùng và để xem trước ảnh động. Để bật tính năng này, hãy nhấp vào biểu tượng Interactive (Tương tác) và thành phần hiển thị trước sẽ chuyển đổi các chế độ.

Để dừng, hãy nhấp vào Stop Interactive Preview (Dừng bản xem trước tương tác) trên thanh công cụ ở trên cùng.

Triển khai cho thiết bị

Bạn có thể sử dụng tính năng này để triển khai đoạn mã của giao diện người dùng cho một thiết bị. Việc này giúp bạn kiểm thử các phần nhỏ của mã trong thiết bị mà không phải khởi động toàn bộ ứng dụng.

Nhấp vào biểu tượng Deploy to Device (Triển khai cho thiết bị) bên cạnh chú thích @Preview hoặc ở trên cùng của bản xem trước, và Android Studio sẽ triển khai @Preview đó trên trình mô phỏng hoặc thiết bị đã được kết nối của bạn.

Chỉnh sửa trực tiếp giá trị cố định

Chúng tôi đã thêm tính năng Chỉnh sửa trực tiếp giá trị cố định để giúp những nhà phát triển sử dụng Compose nhanh chóng chỉnh sửa giá trị cố định (chuỗi, số, boolean) trong mã của họ và xem kết quả ngay lập tức mà không cần chờ quá trình biên dịch. Mục tiêu của tính năng này là giúp tăng năng suất của bạn bằng cách làm cho các thay đổi về mã xuất hiện gần như ngay lập tức trong bản xem trước, trình mô phỏng hoặc thiết bị thực tế.

Hỗ trợ Compose trong Layout Inspector

Layout Inspector cho phép bạn xem thông tin chi tiết phong phú về bố cục của ứng dụng đang chạy trên thiết bị đã kết nối của bạn. Bạn có thể tương tác với ứng dụng và xem thông tin cập nhật trực tiếp trong công cụ này để khắc phục nhanh các vấn đề có thể phát sinh.

Bạn có thể kiểm tra các bố cục đã viết bằng khung giao diện người dùng khai báo mới của Android, đó là Jetpack Compose. Cho dù ứng dụng của bạn sử dụng bố cục được viết đầy đủ trong ứng dụng Compose hay bố cục sử dụng kết hợp giữa Compose và Thành phần hiển thị, thì Layout Inspector vẫn sẽ giúp bạn hiểu được cách các bố cục hiển thị trên thiết bị đang chạy của mình.

Bắt đầu

Để bắt đầu, hãy triển khai ứng dụng của bạn cho một thiết bị đã kết nối, sau đó mở cửa sổ Layout Inspector bằng cách chọn View (Xem) > Tool Windows (Cửa sổ công cụ) > Layout Inspector. Nếu Layout Inspector không tự động kết nối với quy trình ứng dụng của bạn, hãy chọn quy trình ứng dụng mong muốn trong danh sách quy trình kéo xuống. Bạn sẽ sớm thấy bố cục của ứng dụng hiển thị trong cửa sổ công cụ. Để bắt đầu kiểm tra bố cục của Compose, hãy chọn thành phần bố cục xuất hiện trong quy trình hiển thị hoặc chọn thành phần có trong Component Tree (Cây thành phần).

Cửa sổ Attributes (Thuộc tính) hiển thị cho bạn thông tin chi tiết về hàm Compose hiện được chọn. Trong cửa sổ này, bạn có thể kiểm tra các tham số của hàm cũng như giá trị của các tham số đó, bao gồm cả các giá trị sửa đổi và biểu thức lambda. Đối với biểu thức lambda, công cụ kiểm tra sẽ cung cấp một lối tắt để giúp bạn chuyển đến biểu thức trong mã nguồn.

Layout Inspector hiển thị mọi hàm của Compose trong ngăn xếp lệnh gọi thực hiện việc gửi các thành phần cho bố cục của ứng dụng. Trong nhiều trường hợp, hàm này bao gồm các hàm của Compose được Thư viện của Compose gọi trong nội bộ. Nếu bạn chỉ muốn xem các hàm của Compose trong Component Tree (Cây thành phần) mà ứng dụng trực tiếp gọi, hãy nhấp vào biểu tượng hành động của bộ lọc . Việc này có thể giúp giảm số nút hiển thị trong cây xuống số nút mà bạn muốn kiểm tra.

Cải thiện trình đơn thả xuống về triển khai

Hiện trình đơn thả xuống về thiết bị hiện phân biệt các loại lỗi khác nhau trong cấu hình thiết bị mà bạn chọn. Giờ đây, sự thay đổi về biểu tượng và văn phong sẽ phân biệt giữa lỗi (lựa chọn thiết bị dẫn đến cấu hình bị hỏng) và cảnh báo (lựa chọn thiết bị có thể dẫn đến hành vi không mong muốn nhưng vẫn chạy được).

Ngoài ra, giờ đây, Android Studio cũng sẽ cảnh báo bạn nếu bạn cố gắng chạy dự án trên một thiết bị có lỗi hoặc có cảnh báo liên quan đến dự án đó.

Trợ lý ghép nối Wear OS mới

Trợ lý ghép nối Wear OS mới sẽ hướng dẫn nhà phát triển ghép nối trình mô phỏng Wear OS với điện thoại thực tế hoặc điện thoại ảo ngay trong Android Studio theo từng bước một. Trợ lý có thể giúp bạn cài đặt đúng ứng dụng đồng hành Wear OS trên điện thoại rồi thiết lập mối kết nối giữa hai thiết bị đó. Bạn có thể bắt đầu bằng cách chuyển đến trình đơn thả xuống về thiết bị > Wear OS Emulator Pairing Assistant (Trợ lý ghép nối trình mô phỏng Wear OS).

Mẫu bố cục thích ứng

Android Studio Arctic Fox hiện có một mẫu bố cục mới thích ứng với nhiều kích thước hiển thị cũng như hoạt động đổi kích thước ứng dụng, chẳng hạn như điện thoại, thiết bị có thể gập lại, máy tính bảng và chế độ chia đôi màn hình. Khi tạo một dự án hoặc mô-đun mới, hãy chọn mẫu Hoạt động thích ứng để tạo bố cục có các thành phần tự động đổi kích thước.

Để bắt đầu, hãy chuyển đến File > New (Tệp > Mới), chọn New Project (Dự án mới) hoặc New Module (Mô-đun mới) rồi chọn mẫu Responsive Activity (Hoạt động thích ứng).

Vấn đề đã biết về Arctic Fox

Phần này mô tả các vấn đề hiện đã biết trong Android Studio Arctic Fox.

Bản vá không hoạt động trên Windows đối với phiên bản 3.6-v4.1

Các bản vá trên nền tảng Windows cho phiên bản 3.6-4.1 đối với Android Studio Arctic Fox có thể không hoạt động.

Phiên bản 4.2 (Tháng 4/2021)

Android Studio 4.2 là một bản phát hành chính có nhiều tính năng và điểm cải tiến mới.

Trình bổ trợ Android cho Gradle 4.2.0

Phiên bản mới nhất của trình bổ trợ Android cho Gradle sẽ bao gồm nhiều bản cập nhật. Để tìm hiểu thêm, hãy đọc ghi chú phát hành đầy đủ của trình bổ trợ Android cho Gradle.

Thay đổi về cấu hình và khả năng tương thích với Gradle

Khi chạy trong Android Studio, công cụ bản dựng Gradle sẽ sử dụng JDK đi kèm của Studio. Trong các bản phát hành trước, JDK 8 được tích hợp với Studio. Tuy nhiên, trong 4.2, JDK 11 sẽ được tích hợp để thay thế. Khi sử dụng JDK đi kèm mới để chạy Gradle, điều này có thể dẫn đến một số điểm không tương thích hoặc ảnh hưởng đến hiệu suất của JVM do những thay đổi đối với bộ thu gom rác. Những vấn đề này được mô tả trong ghi chú phát hành AGP.

Tuỳ chọn tối ưu hoá thời gian đồng bộ hoá Gradle

Để cải thiện hiệu suất đồng bộ hoá Gradle, Android Studio sẽ bỏ qua việc tạo danh sách tác vụ trong quá trình đồng bộ hoá. Điều này giúp quá trình đồng bộ hoá Gradle hoàn thành nhanh hơn và cải thiện khả năng thích ứng của giao diện người dùng cho các dự án có quy mô rất lớn. Tuỳ chọn này được bật theo mặc định trong Android Studio 4.2. Để tắt tuỳ chọn này, hãy chuyển đến File > Settings > Experimental (Tệp > Cài đặt > Thử nghiệm) (Preferences > Experimental (Lựa chọn ưu tiên > Thử nghiệm) trên máy Mac) và bỏ đánh dấu tuỳ chọn Do not build Gradle task list during Gradle sync (Không tạo danh sách tác vụ Gradle trong quá trình đồng bộ hoá Gradle).

Trình kiểm tra cơ sở dữ liệu

Cải tiến trình chỉnh sửa truy vấn

Trình kiểm tra cơ sở dữ liệu bao gồm một số điểm cải tiến để giúp bạn viết và thực thi các câu lệnh SQL tuỳ chỉnh. Khi mở trình kiểm tra và mở thẻ New query (Truy vấn mới), bạn sẽ thấy một giao diện trình chỉnh sửa lớn hơn, có thể đổi kích thước để tạo và định dạng các truy vấn, như thể hiện dưới đây.

Ngoài ra, hiện chúng tôi cũng cung cấp nhật ký các truy vấn trước đây của bạn. Khi nhấp vào nút Show query history (Hiển thị nhật ký truy vấn) , bạn sẽ thấy danh sách các truy vấn mà mình đã chạy trước đây dựa trên cơ sở dữ liệu hiện được chọn. Nhấp vào một truy vấn trong danh sách để xem trước truy vấn đầy đủ trong trình chỉnh sửa rồi nhấn Enter để sao chép truy vấn đó vào trình chỉnh sửa. Sau đó, hãy nhấp vào Run (Chạy) để thực thi câu lệnh.

Chế độ ngoại tuyến

Trong các phiên bản Android Studio cũ, việc ngắt kết nối khỏi một quy trình ứng dụng trong khi sử dụng Trình kiểm tra cơ sở dữ liệu sẽ khiến trình kiểm tra và dữ liệu của trình kiểm tra này đóng lại. Trong Android Studio 4.2, chúng tôi đã thêm tính năng tiếp tục kiểm tra cơ sở dữ liệu của ứng dụng sau khi một quá trình bị ngắt kết nối để dễ dàng gỡ lỗi ứng dụng sau khi gặp sự cố hơn.

Khi tình trạng ngắt kết nối xảy ra, Trình kiểm tra cơ sở dữ liệu sẽ tải cơ sở dữ liệu của bạn xuống, sau đó cung cấp cho bạn ở chế độ ngoại tuyến. Khi ở chế độ ngoại tuyến, bạn có thể mở bảng và chạy các truy vấn.

Xin lưu ý rằng khi bạn kết nối lại với một quy trình ứng dụng đang hoạt động, Trình kiểm tra cơ sở dữ liệu sẽ quay về chế độ trực tiếp và chỉ hiển thị cho bạn dữ liệu có trên thiết bị. Điều này nghĩa là dữ liệu hiển thị ở chế độ ngoại tuyến sẽ không tồn tại khi bạn kết nối lại với một quy trình ứng dụng. Do đó, Trình kiểm tra cơ sở dữ liệu không cho phép chỉnh sửa hoặc chạy câu lệnh sửa đổi khi ở chế độ ngoại tuyến.

Trợ lý nâng cấp của AGP

Trợ lý nâng cấp mới cho Trình bổ trợ Android cho Gradle có thể giúp bạn cập nhật phiên bản AGP cho dự án của mình.

Được xây dựng dựa trên chức năng nâng cấp hiện có cho AGP, công cụ này sẽ hướng dẫn bạn cách tái cấu trúc/cập nhật trên toàn dự án và xem trước các bản cập nhật để ngăn chặn các thay đổi có thể gây lỗi trước khi thực hiện việc nâng cấp AGP.

Trong trình phân tích CPU, tính năng Theo dõi hệ thống hiện có các chỉ số mới để phân tích hiệu suất của ứng dụng và bao gồm các chỉ số sau:

Bảng sự kiện. Liệt kê tất cả các sự kiện theo dõi trong chuỗi hiện được chọn.

BufferQueue. Trong phần Hiển thị, kênh mới này cho biết số lượng vùng đệm của giao diện ứng dụng BufferQueue (0, 1 hoặc 2) để giúp bạn biết được trạng thái của bộ đệm hình ảnh khi chúng di chuyển giữa các thành phần đồ hoạ Android.

Tần suất của CPU. Trong phần lõi của CPU, kênh mới này sẽ hiển thị tần suất của CPU theo lõi, cho biết hiệu suất hoạt động của mỗi lõi.

Bộ nhớ xử lý (RSS). Cửa sổ mới này cho thấy dung lượng bộ nhớ thực tế hiện ứng dụng đang dùng.

Để biết thêm thông tin chi tiết, hãy xem bài viết Kiểm tra hoạt động của CPU bằng Trình phân tích CPU.

Thao tác làm mới của Layout Inspector

Ra mắt trong Android Studio 4.0, Layout Inspector được thiết kế để kiểm tra ngăn xếp trên giao diện người dùng của ứng dụng đang chạy theo thời gian thực. Tuy nhiên, không phải lúc nào bạn cũng muốn Layout Inspector ngay lập tức phản ánh những gì đang diễn ra trong ứng dụng của mình, vì bạn có thể muốn kiểm tra ảnh chụp nhanh cho bố cục của ứng dụng tại một thời điểm cụ thể hoặc muốn giảm thiểu tác động về hiệu suất của bản cập nhật trực tiếp đến ứng dụng của mình.

Tạm dừng bản cập nhật trực tiếp và làm mới thao tác chụp ảnh màn hình trong Layout Inspector.

Để tải ảnh chụp nhanh về dữ liệu giao diện người dùng trong ứng dụng của bạn theo cách thủ công, trước tiên, hãy tắt tuỳ chọn Live updates (Bản cập nhật trực tiếp). Sau đó, bạn có thể nhấp vào nút Refresh (Làm mới) để xem ảnh chụp nhanh mới về ngăn xếp giao diện người dùng để kiểm tra. Layout Inspector hiện ghi nhớ các lựa chọn ưu tiên của bạn để luôn bật hoặc tắt các tuỳ chọn Live updates (Bản cập nhật trực tiếp) giữa các phiên.

Hỗ trợ cho Safe Args

Safe Args là một trình bổ trợ cho Gradle tạo ra các lớp xây dựng và đối tượng đơn giản để di chuyển theo loại an toàn, đồng thời cấp quyền truy cập vào mọi đối số liên quan. Android Studio hiện hỗ trợ nhiều tính năng hơn khi làm việc với Safe Args, như mô tả ở bên dưới:

Tính năng tự động hoàn thành cho dịch vụ Đường đi, Args và các lớp xây dựng

Hỗ trợ cho cả trình bổ trợ Safe Args của Java và Kotlin

Di chuyển từ nguồn sang XML

R8 retrace hiện đã có trong công cụ dòng lệnh

Có sẵn trong phiên bản 4.0 của công cụ dòng lệnh, R8 retrace là một công cụ độc lập giúp lấy dấu vết ngăn xếp ban đầu từ dấu vết ngăn xếp đã làm rối mã nguồn.

Bạn có thể tải gói này xuống bằng Trình quản lý SDK, trình quản lý này sẽ cài đặt R8 retrace trong android_sdk /cmdline-tools . Ngoài ra, bạn cũng có thể tải gói công cụ dòng lệnh độc lập xuống.

Để biết thông tin về cách sử dụng, hãy xem phần R8 retrace trong hướng dẫn sử dụng.

Triển khai cho nhiều thiết bị

Để giúp đơn giản hoá quá trình kiểm thử ứng dụng trên các thiết bị và cấp độ API, giờ đây, bạn có thể triển khai ứng dụng của mình cho nhiều thiết bị hoặc trình mô phỏng cùng một lúc bằng cách làm theo các bước sau:

Chọn Select Multiple Devices (Chọn nhiều thiết bị) trong trình đơn thả xuống thiết bị mục tiêu (ở trên cùng chính giữa của IDE). Chọn thiết bị mục tiêu rồi nhấp vào OK. Chạy ứng dụng của bạn.

Lưu ý: Tính năng chạy và xem hoạt động kiểm thử trên nhiều thiết bị là một tính năng thử nghiệm. Khi chạy một cấu hình kiểm thử trên nhiều thiết bị, bạn có thể được nhắc bật tính năng này để có thể tiếp tục.

Chế độ cài đặt removable mới cho mô-đun tính năng

Trình bổ trợ Android cho Gradle 4.2 sử dụng bundletool 1.0.0 giới thiệu sự thay đổi về hành vi của các ứng dụng dùng mô-đun tính năng: Bất kỳ mô-đun tính năng nào được chỉ định là dist:install-time nhưng chưa được đánh dấu rõ ràng là dist:removable sẽ trở thành giá trị không xoá được theo mặc định. Chế độ cài đặt mới này tối ưu hoá việc hợp nhất các mô-đun thời gian cài đặt với mô-đun cơ sở, nhờ đó có thể cải thiện hiệu suất ứng dụng cho một số ứng dụng.

Để xoá được các mô-đun tính năng, hãy đặt dist:removable=”true” trên bất kỳ mô-đun nào bạn muốn gỡ cài đặt.

Để biết thêm thông tin về chế độ cài đặt mới này, hãy xem tài liệu cho thẻ dist:removable trong tài liệu về tệp kê khai mô-đun tính năng.

Áp dụng các thay đổi

Để giúp bạn làm việc hiệu quả hơn khi thực hiện thao tác lặp lại trên ứng dụng, chúng tôi đã thực hiện các cải tiến sau đây để áp dụng các thay đổi cho thiết bị chạy Android 11 trở lên:

Hỗ trợ cho các thay đổi khác về mã

Đối với các thiết bị chạy Android 11 trở lên, giờ đây, bạn có thể thêm các trường gốc chính thức, sau đó triển khai những thay đổi đó đối với ứng dụng đang chạy bằng cách nhấp vào biểu tượng Apply Code Changes (Áp dụng các thay đổi mã) hoặc Apply Changes and Restart Activity (Áp dụng các thay đổi và khởi động lại hoạt động) .

Giờ đây, bạn cũng có thể thêm tài nguyên, rồi triển khai những thay đổi đó cho ứng dụng đang chạy trên thiết bị Android 11 bằng cách nhấp vào Apply Changes and Restart Activity (Áp dụng thay đổi và khởi động lại hoạt động) .

Cập nhật trình hướng dẫn Dự án mới và Mô-đun mới

Trình hướng dẫn New Project (Dự án mới) và New Module (Mô-đun mới) đã được cập nhật để giúp bạn dễ dàng duyệt xem, chọn mẫu và nhập thông tin về dự án hoặc mô-đun mới hơn.

Tuỳ chọn Import .JAR/.AAR Package (Nhập gói .JAR/.AAR) trong trình hướng dẫn New Module (Mô-đun mới) cũng bị xoá. Để nhập JAR hoặc AAR vào dự án của bạn, hãy sử dụng Hộp thoại cấu trúc dự án để thay thế.

Kotlin 1.4.31

Android Studio 4.2 tích hợp Kotlin 1.4.31. Hãy xem nhật ký thay đổi của Kotlin 1.4.0 để xem xét các thay đổi chính.

Không dùng biến môi trường ANDROID_SDK_HOME nữa

Biến môi trường ANDROID_SDK_HOME không được dùng nữa và được thay thế bằng ANDROID_PREFS_ROOT . Để biết thêm thông tin, hãy xem bài viết Biến môi trường của Trình mô phỏng.

Vấn đề đã biết với Android Studio 4.2

Phần này mô tả các vấn đề đã biết còn tồn tại trong Android Studio 4.2. Để xem danh sách đầy đủ, hãy truy cập trang Các vấn đề đã biết.

Android Studio 4.2.0 tạo dự án có phiên bản Kotlin không chính xác: “1.5.0-release-764”

Nếu bạn đang dùng Android Studio 4.2.0 và đã nâng cấp lên trình bổ trợ Kotlin 1.5.0, thì các dự án Kotlin mới do Studio tạo sẽ không tạo được do lỗi đồng bộ hoá Gradle sau: Could not find org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.0-release-764.

Để khắc phục lỗi này, hãy thay thế “1.5.0-release-764” bằng “1.5.0” trong tệp build.gradle của dự án.

Lỗi khi sử dụng nhiều mật khẩu khác nhau cho khoá và kho khoá

Kể từ phiên bản 4.2, Android Studio hiện chạy trên JDK 11. Bản cập nhật này gây ra sự thay đổi lớn về hành vi liên quan đến các khoá ký.

Khi bạn chuyển đến phần Build > Generate Signed Bundle/APK (Tạo > Tạo gói đã ký/APK) và tìm cách định cấu hình cho hoạt động ký ứng dụng cho gói ứng dụng hoặc APK, việc nhập các mật khẩu khác nhau cho khoá và kho khoá có thể dẫn đến lỗi sau:

Key was created with errors: Warning: Different store and Key passwords not supported for PKCS12 Key stores

Để khắc phục lỗi này, hãy nhập cùng một mật khẩu cho cả khoá và kho khoá.

Android Studio không khởi động sau khi cài đặt phiên bản 4.2

Studio cố gắng nhập .vmoptions trước và dọn dẹp chúng để thao tác với trình thu gom rác do JDK 11 sử dụng. Nếu quá trình đó không thành công, thì IDE có thể không khởi động cho một số người dùng đã đặt các tuỳ chọn máy ảo tuỳ chỉnh trong tệp .vmoptions.

Để khắc phục lỗi này, bạn nên đánh dấu các tuỳ chọn tuỳ chỉnh trong .vmoptions là nội dung nhận xét (bằng ký tự “#”). Bạn có thể tìm thấy tệp .vmoptions ở các vị trí sau:

Windows

C:\Users\YourUserName\AppData\ [Local|Roaming] \Google\AndroidStudio4.2\studio64.exe.vmoptions

macOS

~/Library/Application Support/Google/AndroidStudio4.2/studio.vmoptions

Linux

~/.config/Google/AndroidStudio4.2/studio64.vmoptions

Nếu Studio vẫn không khởi động sau khi thử giải pháp này, hãy xem bài viết Studio không khởi động sau khi nâng cấp ở bên dưới.

Phiên bản 4.1 (Tháng 8/2020)

Android Studio 4.1 là một bản phát hành chính có nhiều tính năng và điểm cải tiến mới.

Trình bổ trợ Android cho Gradle 4.1.0

Phiên bản mới nhất của trình bổ trợ Android cho Gradle sẽ bao gồm nhiều bản cập nhật. Để tìm hiểu thêm, hãy đọc ghi chú phát hành đầy đủ của trình bổ trợ Android cho Gradle.

Trình kiểm tra cơ sở dữ liệu mới

Kiểm tra, gửi truy vấn và sửa đổi cơ sở dữ liệu của bạn trong ứng dụng đang chạy bằng Trình kiểm tra cơ sở dữ liệu mới. Để bắt đầu, hãy triển khai ứng dụng của bạn cho một thiết bị chạy cấp độ API 26 trở lên rồi chọn View > Tool Windows > Database Inspector (Xem > Cửa sổ công cụ > Trình kiểm tra cơ sở dữ liệu) trong thanh trình đơn.

Để tìm hiểu thêm, hãy xem bài viết Gỡ lỗi cho cơ sở dữ liệu bằng Trình kiểm tra cơ sở dữ liệu.

Chạy Trình mô phỏng Android ngay trong Android Studio

Giờ đây, bạn có thể chạy Trình mô phỏng Android ngay trong Android Studio. Hãy sử dụng tính năng này để bảo toàn không gian màn hình, để di chuyển nhanh giữa trình mô phỏng và cửa sổ trình chỉnh sửa bằng cách sử dụng phím tắt, cũng như để sắp xếp quy trình IDE và trình mô phỏng trong một cửa sổ ứng dụng duy nhất.

Để tìm hiểu thêm, hãy xem tài liệu về Trình mô phỏng Android.

Sử dụng mô hình TensorFlow Lite

Liên kết mô hình máy học giúp bạn dễ dàng nhập trực tiếp tệp mô hình .tflite và sử dụng các tệp đó trong các dự án của mình. Android Studio tạo ra các lớp dễ sử dụng để bạn có thể chạy mô hình của mình mà không tốn nhiều mã cũng như cải thiện mức độ an toàn của hoạt động nhập.

Mô hình được hỗ trợ

Việc triển khai Liên kết mô hình máy học hiện tại hỗ trợ việc phân loại hình ảnh và mô hình chuyển kiểu, miễn là các mô hình đó được nâng cao bằng siêu dữ liệu. Theo thời gian, dịch vụ hỗ trợ sẽ được mở rộng cho các miền khác gặp vấn đề, như phát hiện đối tượng, phân đoạn hình ảnh và phân loại văn bản.

Có rất nhiều mô hình luyện sẵn có siêu dữ liệu được cung cấp trên TensorFlow Hub. Bạn cũng có thể tự thêm siêu dữ liệu vào mô hình TensorFlow Lite như đã nêu trong bài viết Thêm siêu dữ liệu vào mô hình TensorFlow Lite.

Nhập một tệp mô hình

Để nhập tệp mô hình được hỗ trợ, hãy làm theo các bước sau:

Mở hộp thoại nhập mô hình TensorFlow Lite trong trình đơn Tệp tại File > New > Other > TensorFlow Lite Model (Tệp > Mới > Khác > Mô hình TensorFlow Lite). Chọn tệp mô hình .tflite mà bạn đã tải xuống hoặc tạo trước đó. Nhấp vào Hoàn tất.

Thao tác này sẽ nhập tệp mô hình vào dự án của bạn và đặt tệp đó vào thư mục ml/ ; nếu thư mục không tồn tại, Android Studio sẽ tạo thư mục cho bạn.

Xem siêu dữ liệu và mức sử dụng mô hình

Để xem thông tin chi tiết của một mô hình đã nhập cũng như hướng dẫn về cách sử dụng mô hình đó trong ứng dụng, hãy nhấp đúp vào tệp mô hình trong dự án của bạn để mở trang trình xem mô hình có nội dung như sau:

Mô hình: Thông tin mô tả cấp cao về mô hình

Thông tin mô tả cấp cao về mô hình Tensor: Thông tin mô tả về tensor đầu vào và đầu ra

Thông tin mô tả về tensor đầu vào và đầu ra Mã mẫu: Ví dụ về cách tạo giao diện bằng mô hình trong ứng dụng của bạn

Dưới đây là ví dụ về cách sử dụng mobilenet_v1_0.25_160_quantized.tflite:

Như ví dụ minh hoạ, Android Studio sẽ tạo một lớp có tên là MobilenetV1025160Quantized để tương tác với mô hình.

Nếu mô hình này không có siêu dữ liệu, màn hình này sẽ chỉ cung cấp rất ít thông tin.

Các sự cố đã biết và cách giải quyết

Hệ thống hiện chưa hỗ trợ các mô hình TensorFlow Lite cho các miền có vấn đề ngoài việc phân loại hình ảnh và chuyển kiểu. Mặc dù việc nhập hoạt động tốt, nhưng một số đầu vào và/hoặc đầu ra của mô hình lại được thể hiện bằng TensorBuffers thay vì các loại dễ dùng. Đối với các mô hình không có siêu dữ liệu, tất cả các đầu vào và đầu ra của mô hình sẽ là TensorBuffers.

Các mô hình có loại dữ liệu Đầu vào và Đầu ra khác với DataType.UINT8 hoặc DataType.FLOAT32 không được hỗ trợ.

Tính năng này vẫn đang trong quá trình phát triển, nên vui lòng cung cấp ý kiến phản hồi hoặc báo cáo lỗi.

Trình phân tích bộ nhớ cho mã gốc

Trình phân tích bộ nhớ của Android Studio hiện bao gồm Trình phân tích bộ nhớ cho mã gốc cho các ứng dụng được triển khai trên các thiết bị thực tế chạy Android 10 trở lên. Với Trình phân tích bộ nhớ cho mã gốc, bạn có thể ghi lại các quá trình phân bổ và giải phóng bộ nhớ từ mã gốc và kiểm tra số liệu thống kê tích luỹ về các đối tượng gốc.

Để tìm hiểu thêm về Trình phân tích bộ nhớ cho mã gốc, hãy xem bài viết Kiểm tra mức sử dụng bộ nhớ của ứng dụng bằng Trình phân tích bộ nhớ.

Các sự cố đã biết và cách giải quyết

Trình phân tích bộ nhớ gốc trong Android Studio 4.1 không hoạt động trên các thiết bị Android 11. Hiện tại, chúng tôi đã cung cấp chức năng hỗ trợ tạo hồ sơ cho thiết bị Android 11 trong bản thử nghiệm 4.2

Kể từ bản phát hành 4.1 đầu tiên, tuỳ chọn tạo hồ sơ khởi động ứng dụng đã bị tắt. Tuỳ chọn này sẽ được bật trong bản phát hành sắp tới. Để khắc phục vấn đề này, bạn có thể sử dụng Trình phân tích dòng lệnh độc lập Perfetto để ghi lại dữ liệu phân tích trong quá trình khởi động.

Giao diện người dùng của công cụ Theo dõi hệ thống: Dễ lựa chọn hơn, có thẻ phân tích mới và nhiều dữ liệu kết xuất khung hơn

Giao diện người dùng của công cụ Theo dõi hệ thống trong trình phân tích tài nguyên của Android Studio có các điểm cải tiến sau:

Box selection (Lựa chọn hộp): Trong mục Threads (Luồng), giờ đây, bạn có thể kéo chuột để thực hiện thao tác chọn hộp theo vùng hình chữ nhật mà bạn có thể phóng to bằng cách nhấp vào nút Zoom to Selection (Thu phóng vùng lựa chọn) ở phía trên cùng bên phải (hoặc sử dụng phím tắt M ). Khi kéo và thả các chuỗi tương tự bên cạnh các chuỗi khác, bạn có thể chọn trên nhiều chuỗi để kiểm tra tất cả chuỗi đó cùng một lúc. Ví dụ: bạn có thể muốn thực hiện việc phân tích trên nhiều chuỗi trình chạy.

Summary tab (Thẻ tóm tắt): Thẻ Summary (Tóm tắt) mới trong bảng điều khiển Analysis (Phân tích) sẽ hiển thị: Dữ liệu thống kê tổng hợp cho tất cả những lần xuất hiện của một sự kiện cụ thể, chẳng hạn như số lần xuất hiện và thời lượng tối thiểu/tối đa. Số liệu thống kê của sự kiện theo dõi cho lần xuất hiện đã chọn. Dữ liệu về việc phân phối trạng thái chuỗi. Lần xuất hiện dài nhất của sự kiện theo dõi đã chọn. Để chuyển đến một lần xuất hiện khác, hãy chọn một hàng khác trong bảng.

Display data (Dữ liệu hiển thị): Trong phần Display (Hiển thị), tiến trình mới cho SurfaceFlinger và VSYNC sẽ giúp bạn điều tra sự cố hiển thị trong giao diện người dùng của ứng dụng.

Để biết hướng dẫn sử dụng cơ bản về cách ghi lại hoạt động theo dõi hệ thống, hãy xem phần Ghi lại dấu vết trong bài viết Kiểm tra hoạt động của CPU bằng Trình phân tích CPU.

Windows users (Người dùng Windows): Nếu bị thiếu nhãn trong tiến trình hoạt động của chuỗi khi bạn lập hồ sơ cho ứng dụng của mình, hãy xem các vấn đề đã biết để biết cách giải quyết. Vấn đề này được khắc phục trong bản phát hành 4.2.

Hiện đã có trình phân tích tài nguyên độc lập

Với trình phân tích tài nguyên độc lập mới, giờ đây bạn có thể lập hồ sơ cho ứng dụng của mình mà không cần chạy toàn bộ IDE Android Studio.

Để xem hướng dẫn về cách sử dụng các trình phân tích tài nguyên độc lập, hãy xem bài viết Chạy các trình phân tích tài nguyên độc lập.

Hỗ trợ điều hướng trên Dagger

Android Studio giúp bạn dễ dàng di chuyển giữa mã liên quan đến Dagger bằng cách cung cấp các thao tác định hướng mới và mở rộng khả năng hỗ trợ trong cửa sổ Find Usages (Tìm hoạt động sử dụng).

New gutter actions (Thao tác định hướng mới): Đối với các dự án sử dụng Dagger, IDE cung cấp các thao tác định hướng giúp bạn di chuyển giữa mã được chú thích của Dagger. Ví dụ: khi nhấp vào thao tác định hướng bên cạnh phương thức sử dụng một loại nhất định, bạn sẽ được chuyển đến nhà cung cấp của loại đó. Ngược lại, khi nhấp vào thao tác định hướng , bạn sẽ được chuyển đến vị trí mà một loại được dùng làm phần phụ thuộc.

Find Usages node (Nút Tìm hoạt động sử dụng): Khi bạn gọi Find Usages (Tìm hoạt động sử dụng) đối với nhà cung cấp một loại nhất định, cửa sổ Find (Tìm) giờ đây sẽ bao gồm một nút Dependency consumer (Người dùng phần phụ thuộc). Nút này sẽ liệt kê những người dùng loại đó. Ngược lại, khi gọi hành động này cho một người dùng phần phụ thuộc được chèn của Dagger, cửa sổ Find (Tìm) sẽ hiển thị cho bạn thấy nhà cung cấp phần phụ thuộc đó.

Thành phần thiết kế Material Design: Cập nhật giao diện và kiểu trong mẫu dự án mới

Các mẫu của Android Studio trong hộp thoại Create New Project (Tạo dự án mới) hiện sử dụng Thành phần thiết kế Material Design (MDC) và tuân theo hướng dẫn cập nhật dành cho các giao diện và kiểu theo mặc định. Nội dung cập nhật bao gồm:

MDC: Các dự án phụ thuộc vào com.google.android.material:material trong build.gradle. Giao diện của ứng dụng cơ sở sử dụng phần tử mẹ Theme.MaterialComponents.* và ghi đè các thuộc tính màu và thuộc tính “bật” được cập nhật của MDC.

Các dự án phụ thuộc vào trong Giao diện của ứng dụng cơ sở sử dụng phần tử mẹ và ghi đè các thuộc tính màu và thuộc tính “bật” được cập nhật của MDC. Color resources (Tài nguyên màu): Tài nguyên màu trong colors.xml sử dụng tên của các giá trị cố định (ví dụ: purple_500 thay vì colorPrimary ).

(Tài nguyên màu): Tài nguyên màu trong sử dụng tên của các giá trị cố định (ví dụ: thay vì ). Theme resources (Tài nguyên giao diện): Tài nguyên giao diện có trong themes.xml (thay vì styles.xml ) và sử dụng tên Theme. .

(Tài nguyên giao diện): Tài nguyên giao diện có trong (thay vì ) và sử dụng tên . Dark theme (Giao diện tối): Giao diện của ứng dụng cơ sở sử dụng phần tử mẹ của DayNight và được phân tách giữa res/values và res/values-night .

(Giao diện tối): Giao diện của ứng dụng cơ sở sử dụng phần tử mẹ của và được phân tách giữa và . Theme attributes (Thuộc tính giao diện): Tài nguyên màu được tham chiếu ở dạng thuộc tính giao diện (ví dụ: ?attr/colorPrimary ) trong bố cục và kiểu để tránh màu sắc được mã hoá cứng.

IntelliJ IDEA 2020.1

IDE Android Studio chính được cập nhật với những điểm cải tiến từ IntelliJ IDEA thông qua bản phát hành 2020.1, trong đó có cửa sổ Commit (Cam kết) mới cho phép thực hiện hoạt động kiểm soát phiên bản và bật chế độ Zen mới có thể chuyển đổi bằng cách chọn View > Appearance > Enter Distraction Free Mode (Xem > Giao diện > Chuyển sang Chế độ không làm mất tập trung).

Để tìm hiểu thêm về những điểm cải tiến trong phiên bản 2020.1, hãy xem trang sau:

Thay đổi thư mục cấu hình của IDE

Vị trí của các thư mục cấu hình người dùng đã được thay đổi như sau:

Windows

Cú pháp: %APPDATA%\Google\

Ví dụ: C:\Users\YourUserName\AppData\Roaming\Google\AndroidStudio4.1

macOS

Cú pháp: ~/Library/Application Support/Google/

Ví dụ: ~/Library/Application Support/Google/AndroidStudio4.1

Linux

Cú pháp: ~/.config/Google/

Ví dụ: ~/.config/Google/AndroidStudio4.1

Các vị trí mới này của thư mục phù hợp với thông tin cập nhật gần đây đối với IntelliJ IDEA, IDE mà Android Studio dựa trên đó.

Lưu ý: Nếu Studio không khởi động lại sau khi nâng cấp, thì bạn có thể phải xoá thư mục cấu hình khỏi phiên bản Studio cũ. Hãy xem trang các vấn đề đã biết để biết thêm thông tin.

Kotlin 1.3.72

Android Studio 4.1 tích hợp Kotlin 1.3.72, gồm một số bản sửa lỗi để cải thiện tính năng làm nổi bật, kiểm tra và hoàn thành mã của Kotlin. Hãy xem nhật ký thay đổi của Kotlin 1.3.72 để biết thông tin chi tiết.

Xem trước thành phần hiển thị tuỳ chỉnh

Khi tạo thành phần hiển thị tuỳ chỉnh (ví dụ: bằng cách mở rộng lớp View hoặc Button ), giờ đây, Android Studio sẽ cho bạn xem trước thành phần hiển thị tuỳ chỉnh. Sử dụng trình đơn thả xuống trên thanh công cụ để chuyển đổi giữa nhiều thành phần hiển thị tuỳ chỉnh hoặc nhấp vào các nút để xuống dòng theo chiều dọc hoặc chiều ngang tuỳ theo nội dung.

Lưu ý: Nếu bạn không thấy thay đổi của mình trong bản xem trước, hãy chọn Build > Make Project (Xây dựng > Tạo dự án) trên thanh trình đơn.

Quá trình thay thế bằng biểu tượng cho báo cáo trục trặc mã gốc

Khi một sự cố hoặc lỗi ANR xảy ra trong mã gốc, hệ thống sẽ tạo ra một dấu vết ngăn xếp. Đây là ảnh chụp nhanh về trình tự của các hàm được lồng và gọi trong chương trình của bạn cho tới thời điểm xảy ra sự cố. Các ảnh chụp nhanh này có thể giúp bạn xác định và khắc phục mọi vấn đề trong nguồn, nhưng trước tiên, các ảnh chụp nhanh đó phải được thay thế bằng biểu tượng để dịch các địa chỉ máy lại thành tên hàm mà người dùng có thể đọc được.

Nếu dùng mã gốc, chẳng hạn như C++, để phát triển ứng dụng hoặc trò chơi, thì giờ đây, bạn có thể tải các tệp biểu tượng gỡ lỗi lên Play Console cho từng phiên bản của ứng dụng. Play Console sử dụng các tệp biểu tượng gỡ lỗi này để thực hiện quá trình thay thế bằng biểu tượng cho dấu vết ngăn xếp của ứng dụng. Nhờ đó, bạn có thể dễ dàng phân tích các sự cố và lỗi ANR hơn. Để tìm hiểu cách tải tệp biểu tượng gỡ lỗi lên, hãy xem bài viết Hỗ trợ cho trục trặc mã gốc.

Áp dụng các thay đổi

Để giúp bạn làm việc hiệu quả hơn khi thực hiện thao tác lặp lại trên ứng dụng, chúng tôi đã thực hiện các cải tiến sau đây để áp dụng các thay đổi cho thiết bị chạy Android 11 Bản dùng thử cho nhà phát triển 3 trở lên:

Tốc độ triển khai nhanh hơn

Chúng tôi đã đầu tư mạnh vào việc tối ưu hoá tốc độ lặp lại bằng cách phát triển một phương thức để triển khai và duy trì các thay đổi trên thiết bị mà không cần cài đặt ứng dụng. Sau lần triển khai đầu tiên, các lần triển khai tiếp theo cho thiết bị Android 11 sử dụng tuỳ chọn Apply Code Changes (Áp dụng các thay đổi mã) hoặc Apply Changes and Restart Activity (Áp dụng các thay đổi và khởi động lại hoạt động) giờ đây sẽ nhanh hơn đáng kể.

Để tìm hiểu thêm về sự khác biệt giữa 2 hành động này, hãy xem bài viết Áp dụng các thay đổi.

Hỗ trợ cho các thay đổi khác về mã

Đối với các thiết bị chạy Android 11 Bản dùng thử cho nhà phát triển 3 trở lên, giờ đây, bạn có thể thêm các phương thức rồi triển khai các thay đổi đó cho ứng dụng đang chạy của mình bằng cách nhấp vào biểu tượng tuỳ chọn Apply Code Changes (Áp dụng các thay đổi mã) hoặc Apply Changes and Restart Activity (Áp dụng các thay đổi và khởi động lại hoạt động) .

Phiên bản 4.0 (Tháng 5/2020)

Android Studio 4.0 là một bản phát hành chính có nhiều tính năng và điểm cải tiến mới.

Trình bổ trợ Android cho Gradle 4.0.0

Trình bổ trợ Android cho Gradle phiên bản mới nhất có nhiều điểm cập nhật, chẳng hạn như tính năng đơn giản hoá Java 8 dành cho các phiên bản Android cũ và các phần phụ thuộc có tính năng liên quan đến nhau. Để tìm hiểu thêm, hãy đọc ghi chú phát hành đầy đủ của trình bổ trợ Android cho Gradle.

Ngoài ra, Android Studio hiện cũng bao gồm các tính năng mới để giúp bạn cải thiện hiệu suất của bản dựng.

Trình phân tích bản dựng

Khi sử dụng Android Studio 4.0 với trình bổ trợ Android cho Gradle 4.0.0 trở lên, cửa sổ Build Analyzer (Trình phân tích bản dựng) sẽ giúp bạn nắm được và chẩn đoán các vấn đề liên quan đến quy trình xây dựng, chẳng hạn như hoạt động tối ưu hoá đã tắt và tác vụ đã định cấu hình không đúng cách. Để mở cửa sổ Build Analyzer (Trình phân tích bản dựng), hãy làm như sau:

Tạo một ứng dụng bằng cách chọn Build > Make Project (Bản dựng > Tạo dự án) trên thanh trình đơn nếu bạn chưa thực hiện việc này. Chọn View > Tool Windows > Build (Xem > Cửa sổ công cụ > Bản dựng) trên thanh trình đơn. Trong cửa sổ Build (Bản dựng), hãy mở cửa sổ Build Analyzer (Trình phân tích bản dựng) theo một trong các cách sau: Sau khi Android Studio hoàn tất quá trình tạo dự án, hãy nhấp vào thẻ Build Analyzer (Trình phân tích bản dựng).

(Trình phân tích bản dựng). Sau khi Android Studio hoàn tất quá trình tạo dự án, hãy nhấp vào đường liên kết ở bên phải cửa sổ Build Output (Đầu ra bản dựng).

Cửa sổ Build Analyzer (Trình phân tích bản dựng) sắp xếp các vấn đề về bản dựng có thể xảy ra trong một cây ở bên trái. Bạn có thể kiểm tra và nhấp vào từng vấn đề để tìm hiểu thông tin chi tiết về vấn đề đó trong bảng bên phải. Khi phân tích bản dựng, Android Studio sẽ tính toán tập hợp tác vụ đã xác định thời lượng của bản dựng và cung cấp hình ảnh để giúp bạn hiểu tác động của từng tác vụ này. Bạn cũng có thể xem thông tin chi tiết về các cảnh báo bằng cách mở rộng nút Warnings (Cảnh báo).

Kiểm tra các tác vụ đã xác định thời lượng của bản dựng.

Đơn giản hoá thư viện Java 8 trong D8 và R8

Android Studio hiện đã hỗ trợ việc sử dụng một số API ngôn ngữ Java 8 mà không yêu cầu cấp độ API tối thiểu cho ứng dụng.

Thông qua một quy trình có tên là đơn giản hoá (desugaring), trình biên dịch DEX D8 trong Android Studio 3.0 trở lên đã hỗ trợ đáng kể các tính năng ngôn ngữ Java 8 (chẳng hạn như biểu thức lambda, phương thức giao diện mặc định, thử với các tài nguyên và các tính năng khác). Trong Android Studio 4.0, công cụ đơn giản hoá đã được mở rộng để có thể đơn giản hoá các API ngôn ngữ Java. Như vậy tức là bạn hiện có thể đưa các API ngôn ngữ tiêu chuẩn chỉ có trong các bản phát hành Android gần đây (chẳng hạn như java.util.streams ) vào các ứng dụng hỗ trợ các phiên bản Android cũ.

Bộ API sau đây được hỗ trợ trong bản phát hành này:

Luồng tuần tự ( java.util.stream )

) Một tập hợp con của java.time

java.util.function

Các mục bổ sung gần đây cho java.util.{Map,Collection,Comparator}

Mục không bắt buộc ( java.util.Optional , java.util.OptionalInt và java.util.OptionalDouble ) và một số lớp mới khác hữu ích với các API ở trên

, và ) và một số lớp mới khác hữu ích với các API ở trên Một số mục bổ sung cho java.util.concurrent.atomic (các phương thức mới trên AtomicInteger , AtomicLong và AtomicReference )

(các phương thức mới trên , và ) ConcurrentHashMap (có bản sửa lỗi cho Android 5.0)

Để hỗ trợ các API ngôn ngữ này, D8 biên dịch một tệp DEX trong thư viện riêng có chứa cách triển khai các API còn thiếu và đưa vào ứng dụng. Quy trình đơn giản hoá sẽ ghi lại mã ứng dụng để sử dụng thư viện này trong thời gian chạy.

Để bật tính năng hỗ trợ cho các API ngôn ngữ này, hãy đưa nội dung sau đây vào tệp build.gradle của app module (mô-đun ứng dụng):

Groovy android { defaultConfig { // Required when setting minSdkVersion to 20 or lower multiDexEnabled true } compileOptions { // Flag to enable support for the new language APIs coreLibraryDesugaringEnabled true // Sets Java compatibility to Java 8 sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } } dependencies { coreLibraryDesugaring ‘com.android.tools:desugar_jdk_libs:1.0.4’ } Kotlin android { defaultConfig { // Required when setting minSdkVersion to 20 or lower multiDexEnabled = true } compileOptions { // Flag to enable support for the new language APIs coreLibraryDesugaringEnabled = true // Sets Java compatibility to Java 8 sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 } } dependencies { coreLibraryDesugaring(“com.android.tools:desugar_jdk_libs:1.0.4”) }

Xin lưu ý rằng bạn cũng cần bổ sung đoạn mã trên vào tệp build.gradle của library module (mô-đun thư viện) nếu:

Các hoạt động kiểm thử được đo lường của mô-đun thư viện sử dụng các API ngôn ngữ này (trực tiếp hoặc thông qua mô-đun thư viện hoặc các phần phụ thuộc của mô-đun). Việc này là để cung cấp các API còn thiếu cho APK kiểm thử được đo lường.

Bạn muốn chạy riêng công cụ tìm lỗi mã nguồn trên mô-đun thư viện. Tính năng này giúp công cụ tìm lỗi mã nguồn nhận ra cách sử dụng hợp lệ của các API ngôn ngữ và tránh báo cáo các cảnh báo sai.

Các phần phụ thuộc có tính năng liên quan với nhau

Trong các phiên bản trước của trình bổ trợ Android cho Gradle, tất cả mô-đun tính năng chỉ dựa vào mô-đun cơ sở của ứng dụng. Giờ đây, khi sử dụng trình bổ trợ Android cho Gradle 4.0.0 trở lên, bạn có thể thêm mô-đun tính năng phụ thuộc vào một mô-đun tính năng khác. Tức là một tính năng của :video có thể phụ thuộc vào tính năng của :camera . Và tính năng này cũng phụ thuộc vào mô-đun cơ sở, theo minh hoạ trong hình dưới đây.

Mô-đun tính năng :video phụ thuộc vào tính năng :camera . Tính năng này lại phụ thuộc vào mô-đun :app cơ sở.

Tức là khi ứng dụng yêu cầu tải một mô-đun tính năng xuống, ứng dụng cũng sẽ tải các mô-đun tính năng khác mà mô-đun đó phụ thuộc vào. Sau khi tạo mô-đun tính năng cho ứng dụng, bạn có thể khai báo phần phụ thuộc có tính năng liên quan với nhau trên tệp build.gradle của mô-đun. Ví dụ: mô-đun :video khai báo phần phụ thuộc trên :camera như sau:

Groovy // In the build.gradle file of the ‘:video’ module. dependencies { // All feature modules must declare a dependency // on the base module. implementation project(‘:app’) // Declares that this module also depends on the ‘camera’ feature module. implementation project(‘:camera’) … } Kotlin // In the build.gradle file of the ‘:video’ module. dependencies { // All feature modules must declare a dependency // on the base module. implementation(project(“:app”)) // Declares that this module also depends on the ‘camera’ feature module. implementation(project(“:camera”)) … }

Ngoài ra, bạn nên bật tính năng phần phụ thuộc có tính năng liên quan với nhau trên Android Studio (ví dụ: để hỗ trợ tính năng này khi chỉnh sửa cấu hình Run (Chạy)) bằng cách nhấp vào Help > Edit Custom VM Options (Trợ giúp > Tuỳ chọn chỉnh sửa máy ảo tuỳ chỉnh) trên thanh trình đơn rồi bổ sung nội dung sau:

-Drundebug.feature.on.feature=true

Siêu dữ liệu của phần phụ thuộc

Khi xây dựng ứng dụng bằng trình bổ trợ Android cho Gradle 4.0.0 trở lên, trình bổ trợ sẽ bao gồm siêu dữ liệu mô tả các phần phụ thuộc được biên dịch thành ứng dụng. Khi bạn tải ứng dụng lên, Play Console sẽ kiểm tra siêu dữ liệu này để mang lại cho bạn những lợi ích sau:

Nhận thông báo về các vấn đề đã biết liên quan đến SDK và các phần phụ thuộc ứng dụng sử dụng

Nhận ý kiến phản hồi hữu ích để giải quyết những vấn đề đó

Dữ liệu được nén, mã hoá bằng một khoá ký Google Play và lưu trữ trong khối ký của ứng dụng phát hành. Tuy nhiên, bạn có thể tự kiểm tra siêu dữ liệu trong các tệp bản dựng trung gian cục bộ trong thư mục sau: //build/outputs/sdk-dependencies/release/sdkDependency.txt .

Nếu không muốn chia sẻ thông tin này, bạn có thể chọn không sử dụng bằng cách đưa nội dung sau vào tệp build.gradle của mô-đun:

Groovy android { dependenciesInfo { // Disables dependency metadata when building APKs. includeInApk = false // Disables dependency metadata when building Android App Bundles. includeInBundle = false } } Kotlin android { dependenciesInfo { // Disables dependency metadata when building APKs. includeInApk = false // Disables dependency metadata when building Android App Bundles. includeInBundle = false } }

Hỗ trợ tệp tập lệnh Kotlin DSL

Trình bổ trợ Android cho Gradle hiện hỗ trợ các tệp tập lệnh bản dựng Kotlin DSL ( *.kts ). Khi sử dụng với Android Studio, giờ đây, một số tính năng IDE, chẳng hạn như hộp thoại Project Structure (Cấu trúc dự án) và bản sửa lỗi nhanh về tập lệnh bản dựng, cũng hỗ trợ đọc và ghi vào tệp tập lệnh bản dựng Kotlin.

Nâng cấp Trình phân tích CPU

Dựa trên ý kiến phản hồi của bạn, chúng tôi đã tập trung cải thiện trải nghiệm người dùng trong Trình phân tích CPU theo 2 cách quan trọng.

Thứ nhất, so với các bản phát hành Android Studio trước đó, tỷ lệ lỗi của bản ghi CPU trong Trình phân tích CPU đã giảm đáng kể.

Thứ hai, giao diện người dùng của Trình phân tích CPU đã được cải tiến toàn diện để mang đến một quy trình trực quan hơn. Một số thay đổi đáng chú ý đối với giao diện người dùng gồm có:

Các bản ghi CPU giờ được tách riêng với tiến trình chính của trình phân tích tài nguyên để có thể phân tích dễ dàng hơn. Dữ liệu đã ghi sẽ được sắp xếp theo nhóm ở phía bên trái cửa sổ Profiler (Trình phân tích tài nguyên). Bạn có thể di chuyển các nhóm lên và xuống để sắp xếp lại danh sách bằng cách nhấp vào biểu tượng tuỳ chọn ở góc trên cùng bên phải của cửa sổ hoặc bằng cách kéo và thả từng mục trong nhóm.

(Trình phân tích tài nguyên). Bạn có thể di chuyển các nhóm lên và xuống để sắp xếp lại danh sách bằng cách nhấp vào biểu tượng tuỳ chọn ở góc trên cùng bên phải của cửa sổ hoặc bằng cách kéo và thả từng mục trong nhóm. Để phân tích song song dễ dàng hơn, giờ đây, bạn có thể xem tất cả các hoạt động trong chuỗi trong tiến trình của hoạt động trong chuỗi đó (bao gồm cả các phương thức, hàm và sự kiện). Có một số cách để di chuyển trong tiến trình: Để tập trung vào một thời điểm cụ thể, hãy kéo một dải ô trong biểu đồ mức sử dụng CPU ở phía trên cùng bên trái. Để phóng to hoặc thu nhỏ, hãy dùng con lăn chuột khi nhấn phím Control (hoặc phím Command trên MacOS). Để xoay sang trái hoặc phải, hãy kéo trong khi nhấn phím cách. Ngoài ra, hãy sử dụng phím W và A để phóng to và thu nhỏ, cũng như phím S và D để di chuyển sang trái và sang phải một cách chi tiết.

Các thẻ cho hoạt động phân tích Flame Chart (Biểu đồ hình ngọn lửa), Top Down (Từ trên xuống) và Bottom Up (Từ dưới lên) hiện nằm ở cột bên phải. Trong nhóm Luồng, luồng sẽ tự động được mở rộng cho các bản ghi Theo dõi hệ thống và thu gọn theo mặc định cho các loại bản ghi khác. Nhấp đúp (hoặc nhấn Enter) vào tên chuỗi để mở rộng hoặc thu gọn.

(Biểu đồ hình ngọn lửa), (Từ trên xuống) và (Từ dưới lên) hiện nằm ở cột bên phải. Trong nhóm Luồng, luồng sẽ tự động được mở rộng cho các bản ghi Theo dõi hệ thống và thu gọn theo mặc định cho các loại bản ghi khác. Nhấp đúp (hoặc nhấn Enter) vào tên chuỗi để mở rộng hoặc thu gọn. Giao diện người dùng của công cụ Theo dõi hệ thống, như trong ảnh chụp màn hình, cũng bao gồm cả các điểm cải tiến: Giờ đây, các sự kiện được tô màu theo cách độc đáo để dễ phân biệt hơn. Các chuỗi được sắp xếp theo số lượng sự kiện theo dõi trong các chuỗi đó để các chuỗi “có nhiều sự kiện hơn” sẽ có thứ hạng cao hơn trong danh sách. Bạn có thể chọn một hoặc nhiều chuỗi để xem thông tin phân tích trong cột bên phải cho riêng các chuỗi được chọn đó. Tương tự như vậy, bạn có thể chọn một sự kiện theo dõi trong bất kỳ chuỗi nào để xem dữ liệu phân tích cho sự kiện đó.

Phiên bản Android Studio này bao gồm các bản cập nhật cho công cụ thiết kế, chẳng hạn như Layout Inspector và Trình chỉnh sửa chuyển động hoàn toàn mới.

Trình chỉnh sửa chuyển động mới

Android Studio hiện có một trình chỉnh sửa thiết kế trực quan cho loại bố cục MotionLayout, giúp bạn dễ tạo và xem trước ảnh động hơn.

Trình chỉnh sửa chuyển động cung cấp một giao diện đơn giản để thao tác với các phần tử trong thư viện MotionLayout có vai trò là nền tảng cho ảnh động trong ứng dụng Android. Trong các bản phát hành trước, việc tạo và thay đổi các phần tử này yêu cầu bạn phải chỉnh sửa các quy tắc ràng buộc trong các tệp tài nguyên XML theo cách thủ công. Giờ đây, Trình chỉnh sửa chuyển động có thể tạo XML này cho bạn, cùng với khả năng hỗ trợ cho trạng thái bắt đầu và kết thúc, khung hình chính, hoạt động chuyển đổi và tiến trình.

Để tìm hiểu thêm về cách sử dụng Trình chỉnh sửa chuyển động, hãy xem hướng dẫn sử dụng.

Lưu ý: Trước khi dùng Trình chỉnh sửa chuyển động, hãy nhớ đặt phần phụ thuộc ConstraintLayout trong tệp build.gradle thành phiên bản 2.0.0-beta3 trở lên.

Layout Inspector trực tiếp

Gỡ lỗi bố cục bằng Layout Inspector trực tiếp đã cập nhật. Công cụ này cung cấp thông tin chi tiết hoàn chỉnh theo thời gian thực về giao diện người dùng của ứng dụng trong khi triển khai cho thiết bị.

Để mở cửa sổ Layout Inspector, hãy chuyển đến View > Tools Windows > Layout Inspector (Xem > Cửa sổ công cụ > Layout Inspector). Cùng với nhiều tính năng tương tự của Layout Inspector hiện tại, Layout Inspector trực tiếp cũng bao gồm:

Hệ phân cấp bố cục động: Sẽ cập nhật khi số lượt xem trên thiết bị thay đổi.

Ngăn xếp độ phân giải giá trị của thuộc tính: Giúp điều tra nguồn gốc của giá trị thuộc tính tài nguyên trong mã nguồn và di chuyển đến vị trí của giá trị đó bằng cách truy cập vào các siêu liên kết trong ngăn thuộc tính.

Thành phần hiển thị 3D: Xem hệ phân cấp thành phần hiển thị của ứng dụng trong thời gian chạy bằng chế độ trực quan hoá 3D nâng cao. Để sử dụng tính năng này, trong cửa sổ của công cụ Layout Inspector trực tiếp, bạn chỉ cần nhấp vào Layout (Bố cục) rồi xoay bằng cách kéo chuột.

Bạn chỉ có thể sử dụng Layout Inspector trực tiếp khi triển khai ứng dụng cho một thiết bị hoặc trình mô phỏng chạy API cấp độ 29 trở lên. Để bật Layout Inspector trực tiếp, hãy chuyển đến File > Settings > Experimental (Tệp > Cài đặt > Thử nghiệm) rồi đánh dấu hộp bên cạnh tuỳ chọn Enable Live Layout Inspector (Bật Layout Inspector trực tiếp). Sau đó, nhấp vào hộp đánh dấu bên cạnh Live updates (Bản cập nhật trực tiếp) phía trên Layout Display (Màn hình bố cục).

Xác thực bố cục

Xác thực bố cục là một công cụ trực quan giúp bạn cùng lúc xem trước bố cục trên nhiều thiết bị và cấu hình, giúp bạn phát hiện vấn đề về bố cục và tạo các ứng dụng dễ tiếp cận hơn.

Bạn có thể truy cập vào tính năng này bằng cách nhấp vào thẻ Layout Validation (Xác thực bố cục) ở góc trên cùng bên phải cửa sổ IDE:

Trong cửa sổ Xác thực bố cục, bạn có thể chọn trong số 4 nhóm cấu hình gồm có:

Thiết bị Pixel: Xem trước ứng dụng của bạn trên các thiết bị Pixel.

Xem trước ứng dụng của bạn trên các thiết bị Pixel. Tuỳ chỉnh: Xem trước ứng dụng bằng các tuỳ chọn hiển thị tuỳ chỉnh, chẳng hạn như hướng màn hình hoặc ngôn ngữ.

Xem trước ứng dụng bằng các tuỳ chọn hiển thị tuỳ chỉnh, chẳng hạn như hướng màn hình hoặc ngôn ngữ. Mù màu: Xem trước ứng dụng của bạn bằng cách sử dụng các tình huống mô phỏng về các loại mù màu phổ biến.

Xem trước ứng dụng của bạn bằng cách sử dụng các tình huống mô phỏng về các loại mù màu phổ biến. Kích thước phông chữ: Xem trước ứng dụng bằng nhiều kích thước phông chữ.

Để tìm hiểu thêm về cách sử dụng tính năng Xác thực bố cục, hãy xem bài viết Gỡ lỗi bố cục bằng Layout Inspector.

Các tính năng của trình chỉnh sửa thông minh cho quy tắc trình thu gọn mã

Android Studio hiện cung cấp các tính năng của trình chỉnh sửa thông minh khi bạn mở các tệp quy tắc trình thu gọn mã cho R8, chẳng hạn như làm nổi bật cú pháp, hoàn thành mã và kiểm tra lỗi. Trình chỉnh sửa cũng tích hợp với dự án Android Studio để hoàn thành toàn bộ biểu tượng cho tất cả các lớp, phương thức và trường, đồng thời bao gồm cả việc điều hướng nhanh và tái cấu trúc.

Mẫu trực tiếp trên Android cho Kotlin

Android Studio hiện bao gồm các mẫu trực tiếp trên Android cho các lớp Kotlin. Ví dụ: giờ đây, bạn có thể nhập toast và nhấn phím Tabđể chèn nhanh một Thông báo ngắn. Để xem toàn bộ danh sách các mẫu trực tiếp đang hoạt động, hãy nhấp vào File > Settings (Tệp > Cài đặt) trong thanh trình đơn (hoặc Android Studio > Preferences (Android Studio > Lựa chọn ưu tiên) trên macOS) rồi chuyển đến Editor > Live Templates (Trình chỉnh sửa > Mẫu trực tiếp).

Trình hướng dẫn cho mảnh và mẫu mảnh mới

Trình hướng dẫn mới cho mảnh của Android và các mẫu mảnh mới hiện đã có sẵn khi bạn chuyển đến File > New > Fragment > Gallery (Tệp > Mới > Mảnh > Thư viện) hoặc nhấp vào Create new destination (Tạo đích mới) trong Trình chỉnh sửa điều hướng.

Hỗ trợ máy ảnh mở rộng trong Trình mô phỏng Android

Khi sử dụng hình ảnh Android 11, máy ảnh của Trình mô phỏng Android sẽ có các tính năng mới sau:

Chụp ảnh RAW

Xử lý lại YUV

Thiết bị cấp 3

Hỗ trợ máy ảnh logic

Để tìm hiểu thêm về cách phát triển Android 11, hãy xem tài liệu về Android 11.

clangd hiện có sẵn cho trình soạn thảo mã C++

Jetbrains CLion, công nghệ giúp cải thiện khả năng hỗ trợ ngôn ngữ C++ của Android Studio, hiện sử dụng công cụ kiểm tra dựa trên clangd và clang-tidy của LLVM, giúp tăng tốc độ hoàn thành mã C/C++ và cung cấp khả năng tích hợp liền mạch hơn với clang-tidy.

Hiện có sẵn trong trình soạn thảo mã Android Studio C++, clangd và clang-tidy đều thuộc công cụ bổ sung LLVM nguồn mở:

clangd có tính năng hoàn thiện mã, biên dịch thông báo lỗi trong trình chỉnh sửa và di chuyển đến phần định nghĩa.

clang-tidy là một công cụ phát hiện lỗi sai (Linter) C++ bằng khung mở rộng để chẩn đoán và sửa các lỗi lập trình điển hình.

Trong các bản phát hành trước, người dùng Android Studio có thể sử dụng clang-tidy thông qua NDK; Với sự thay đổi này, Android Studio không còn phụ thuộc vào NDK đối với chức năng clang-tidy nữa.

Chế độ cài đặt ndk.dir trong tệp local.properties không dùng nữa

Giá trị của ndk.dir sẽ không được đặt trong tệp local.properties của ứng dụng nữa và chức năng hỗ trợ cho chế độ cài đặt ndk.dir này sẽ bị xoá trong một phiên bản trong tương lai. Trình bổ trợ Android cho Gradle sẽ đặt phiên bản NDK theo mặc định, nhưng nếu cần một phiên bản NDK cụ thể, thì bạn có thể đặt android.ndkVersion trong build.gradle .

Để biết thêm thông tin về cách thiết lập NDK, hãy xem bài viết Cài đặt và định cấu hình NDK và CMake.

IntelliJ IDEA 2019.3.3

IDE Android Studio chính đã được cập nhật với các điểm cải tiến từ IntelliJ IDEA thông qua bản phát hành 2019.3.3.

Để tìm hiểu thêm về những điểm cải tiến từ các phiên bản IntelliJ khác được tích hợp theo cách tích luỹ với phiên bản 2019.3.3, hãy xem các trang sau:

Phiên bản 3.6 (Tháng 2/2020)

Android Studio 3.6 là một bản phát hành chính có nhiều tính năng và điểm cải tiến mới.

Chúng tôi cũng muốn cảm ơn tất cả những người đóng góp cho cộng đồng đã giúp chúng tôi triển khai bản phát hành này.

Phiên bản Android Studio này bao gồm các bản cập nhật cho một số công cụ thiết kế, bao gồm Layout Editor và Trình quản lý tài nguyên.

Thành phần hiển thị phân tách và tính năng thu phóng trong trình chỉnh sửa thiết kế

Các bản cập nhật sau đây cho trình chỉnh sửa thiết kế trực quan đều được đưa vào bản phát hành này:

Trình chỉnh sửa thiết kế, chẳng hạn như Layout Editor và Trình chỉnh sửa điều hướng, hiện cung cấp thành phần hiển thị Split (Phân tách) cho phép bạn cùng lúc xem cả thành phần hiển thị Design (Thiết kế) và Code (Mã) của giao diện người dùng. Ở góc trên cùng bên phải của cửa sổ trình chỉnh sửa, giờ đây có 3 nút để bật/tắt giữa các tuỳ chọn xem: Để bật thành phần hiển thị phân tách, hãy nhấp vào biểu tượng Split (Phân tách) . Để bật thành phần hiển thị nguồn XML, hãy nhấp vào biểu tượng Source (Nguồn) . Để bật thành phần hiển thị thiết kế, hãy nhấp vào biểu tượng Design (Thiết kế) .

Các nút điều khiển để thu phóng và xoay trong trình chỉnh sửa thiết kế đã chuyển sang một bảng điều khiển nổi ở góc dưới cùng bên phải của cửa sổ trình chỉnh sửa.

Để tìm hiểu thêm, hãy xem bài viết Tạo giao diện người dùng bằng Layout Editor.

Thẻ tài nguyên trong Công cụ chọn màu

Để giúp bạn nhanh chóng cập nhật giá trị của tài nguyên màu trong ứng dụng khi đang dùng bộ chọn màu trong XML hoặc công cụ thiết kế, giờ đây, IDE sẽ điền các giá trị của tài nguyên màu cho bạn.

Trình quản lý tài nguyên

Trình quản lý tài nguyên có các bản cập nhật sau:

Trình quản lý tài nguyên hiện đã hỗ trợ hầu hết các loại tài nguyên.

Giờ đây, khi tìm kiếm một tài nguyên, Trình quản lý tài nguyên sẽ hiển thị kết quả của tất cả các mô-đun dự án. Trước đây, các lượt tìm kiếm chỉ trả về kết quả của mô-đun đã chọn.

Nút bộ lọc cho phép bạn xem tài nguyên của các mô-đun phụ thuộc cục bộ, thư viện bên ngoài và khung Android. Bạn cũng có thể dùng bộ lọc để hiển thị các thuộc tính của giao diện.

Giờ đây, bạn có thể đổi tên tài nguyên trong quá trình nhập bằng cách nhấp vào bên trong hộp văn bản ở phía trên tài nguyên đó.

Để tìm hiểu thêm, hãy xem bài viết Quản lý tài nguyên giao diện người dùng của ứng dụng bằng Trình quản lý tài nguyên.

Các điểm cập nhật của trình bổ trợ Android cho Gradle

Trình bổ trợ Android cho Gradle phiên bản mới nhất có nhiều điểm cập nhật, chẳng hạn như khả năng tối ưu hoá cho tốc độ xây dựng, khả năng hỗ trợ trình bổ trợ phát hành của Maven cũng như tính năng Liên kết thành phần hiển thị. Để tìm hiểu thêm, hãy đọc ghi chú phát hành đầy đủ.

Liên kết thành phần hiển thị

Tính năng Liên kết thành phần hiển thị giúp bạn dễ dàng viết mã tương tác với các thành phần hiển thị bằng cách tạo một lớp liên kết cho mỗi tệp bố cục XML. Các lớp này có chứa thông tin tham chiếu trực tiếp đến tất cả các thành phần hiển thị có mã nhận dạng trong bố cục tương ứng.

Vì thay thế cho findViewById() , nên tính năng liên kết thành phần hiển thị sẽ loại bỏ rủi ro xảy ra trường hợp ngoại lệ con trỏ rỗng do mã thành phần hiển thị không hợp lệ.

Để bật tính năng liên kết thành phần hiển thị, bạn cần sử dụng trình bổ trợ Android cho Gradle 3.6.0 trở lên và đưa mã sau vào tệp build.gradle của mỗi mô-đun:

Groovy android { buildFeatures.viewBinding = true } Kotlin android { buildFeatures.viewBinding = true }

Áp dụng các thay đổi

Giờ đây, bạn có thể thêm một lớp rồi triển khai sự thay đổi mã đó cho ứng dụng đang chạy bằng cách nhấp vào biểu tượng tuỳ chọn Apply Code Changes (Áp dụng các thay đổi mã) hoặc Apply Changes and Restart Activity (Áp dụng các thay đổi và khởi động lại hoạt động) .

Để tìm hiểu thêm về sự khác biệt giữa 2 hành động này, hãy xem bài viết Áp dụng các thay đổi.

Tái cấu trúc tuỳ chọn trình đơn để bật chế độ hỗ trợ Ứng dụng tức thì

Giờ đây, bạn có thể bật ngay mô-đun cơ sở bất cứ lúc nào sau khi tạo dự án ứng dụng như sau:

Mở bảng điều khiển Project (Dự án) bằng cách chọn View > Tool Windows > Project (Xem > Cửa sổ công cụ > Dự án) trên thanh trình đơn. Nhấp chuột phải vào mô-đun cơ sở, thường có tên là “app” (ứng dụng), rồi chọn Refactor > Enable Instant Apps Support (Tái cấu trúc > Bật chế độ hỗ trợ Ứng dụng tức thì). Trong hộp thoại xuất hiện, hãy chọn mô-đun cơ sở trên trình đơn thả xuống. Nhấp vào OK.

Lưu ý: Tuỳ chọn bật ngay mô-đun ứng dụng cơ sở từ trình hướng dẫn Create New Project (Tạo dự án mới) đã bị xoá.

Để tìm hiểu thêm, hãy đọc bài viết Tổng quan về Google Play Instant.

Gỡ rối mã nguồn cho mã byte của lớp và phương thức trong Công cụ phân tích APK

Khi sử dụng Công cụ phân tích APK để kiểm tra tệp DEX, bạn có thể gỡ rối mã nguồn cho mã byte của lớp và phương thức theo cách sau đây:

Chọn Build > Analyze APK (Tạo > Phân tích APK) trên thanh trình đơn. Trong hộp thoại xuất hiện, hãy chuyển đến APK bạn muốn kiểm tra và chọn APK đó. Nhấp vào Open (Mở). Trong Công cụ phân tích APK, hãy chọn tệp DEX mà bạn muốn kiểm tra. Trong trình xem tệp DEX, hãy tải tệp liên kết ProGuard cho APK mà bạn đang phân tích. Nhấp chuột phải vào lớp hoặc phương thức mà bạn muốn kiểm tra rồi chọn Show bytecode (Hiển thị mã byte).

Công cụ gốc

Các bản cập nhật sau đây hỗ trợ việc phát triển (C/C++) gốc trong Android Studio.

Hỗ trợ Kotlin

Các tính năng sau đây của NDK trong Android Studio, trước đây được hỗ trợ trong Java, giờ đây cũng được hỗ trợ trong Kotlin:

Chuyển từ phần khai báo JNI sang hàm triển khai tương ứng trong C/C++. Xem mối liên kết này bằng cách di chuột qua điểm đánh dấu của mục C hoặc C++ ở gần số dòng trong tệp mã nguồn được quản lý.

Tự động tạo hàm triển khai đoạn mã cho mục khai báo JNI. Trước tiên, hãy xác định mục khai báo JNI, sau đó nhập “jni” hoặc tên phương thức vào tệp C/C++ để kích hoạt.

Các hàm triển khai gốc không sử dụng được đánh dấu là cảnh báo trong mã nguồn. Các mục khai báo JNI bị thiếu phần triển khai cũng được đánh dấu là lỗi.

Khi bạn đổi tên (tái cấu trúc) một hàm triển khai gốc, tất cả các mục khai báo JNI tương ứng sẽ được cập nhật. Đổi tên mục khai báo JNI để cập nhật hàm triển khai gốc.

Kiểm tra chữ ký cho các hoạt động triển khai JNI có liên kết ngầm định.

Các điểm cải tiến khác của JNI

Giờ đây, trình soạn thảo mã trong

Past releases of Android Studio

This page lists the new features and improvements for each major release of past Android Studio releases. To see what’s new in the latest version, see the current Android Studio release notes.

For the latest news on releases, including a list of notable fixes in each preview release, see the release updates. For information on what’s new in the Android Gradle plugin, see its release notes.

Android Gradle plugin and Android Studio compatibility

The Android Studio build system is based on Gradle, and the Android Gradle plugin adds several features that are specific to building Android apps. The following table lists which version of the Android Gradle plugin is required for each version of Android Studio.

If your project is not supported by a specific version of Android Studio, you can still open and update your project using an older version of Android Studio.

Android Studio version Required plugin version Arctic Fox | 2020.3.1 3.1-7.0 Bumblebee | 2021.1.1 3.2-7.1 Chipmunk | 2021.2.1 3.2-7.2 Dolphin | 2021.3.1 3.2-7.3 Electric Eel | 2022.1.1 3.2-7.4 Flamingo | 2022.2.1 3.2-8.0

For information on what’s new in the Android Gradle plugin, see the Android Gradle plugin release notes.

Android Studio Chipmunk | 2021.2.1

Support for creating your app with Jetpack Compose

Animation Preview supports animatedVisibility

Android Studio Chipmunk supports the animatedVisibility API in Animation Preview. To use Animation preview with animatedVisibility , use Compose version 1.1.0 or higher. To learn more about Animation Preview, see Animations.

Support for deploying preview from Library Modules

Previews allow you to view your UI within Android Studio without having to run your app on a physical device. In Android Studio Chipmunk, you can deploy a specific @Preview to an emulator or physical device from Library Modules. To learn more, see Deploy Preview.

Support for profiling your app

Detect jank on Android 12 and higher

For devices using Android 12 or higher, a captured trace is shown in the Janky frames track under the Display pane in the CPU Profiler.

To detect jank,

From the development emulator or device, start the app. In Android Studio, select View > Tool Windows > Profiler or click Profile in the toolbar. If prompted by the Select Deployment Target dialog, choose the device to which to deploy your app for profiling. If you’ve connected a device over USB but don’t see it listed, ensure that you have enabled USB debugging. Click anywhere in the CPU timeline to open the CPU Profiler. You should see the Janky frames track under Display. By default, the Profiler only shows janky frames as candidates for investigation. Within each janky frame, the red portion highlights the duration the frame takes past its rendering deadline. Once you find a janky frame, click on it; optionally, you can press M to adjust the zoom to focus on the selected frame. The relevant events will be highlighted in the main threads: RenderThread and GPU completion. You can optionally see all frames or a breakdown of the rendering time by toggling the checkboxes All Frames and Lifecycle, respectively.

For more information, see UI jank detection.

Patch releases

The following is list of patch releases in Android Studio Chipmunk.

Android Studio Chipmunk | 2021.2.1 Patch 2 (August 2022)

This minor update includes the following update and bug fixes:

Android platform support

With Android Studio Chipmunk Patch 2 and Android Gradle 7.2.2, you can compile against Android 13 APIs by setting compileSdk=33 . The highest supported minimum SDK version is 32. minSdk = 33 is not supported until Android Gradle plugin 7.3.0-beta05.

Android Studio Chipmunk | 2021.2.1 Patch 1 (May 2022)

This minor update includes the following bug fixes:

Fixed Issues Dexer (D8) Issue #218298666 Art / Dalvik VMs prior to version 8 does not support the fix for JDK-8272564 IntelliJ Issue #225751091 File watcher failed to start on Ubuntu 20.04 Issue #206465485 MBP 15″ 2018 Touch Bar menu is missed. Run Issue #232134751 Devices option is not visible and unable to run the app even though app module is available. Shrinker (R8) Issue #228791247 Why does R8 doesn’t backport default interface methods but D8 does? Issue #218400336 CIRCULAR REFERENCE: com.android.tools.r8.internal.R10: Unexpected type in conversion to primitive: OBJECT

Android Studio Bumblebee | 2021.1.1

Android Studio Bumblebee is a major release that includes the following features and improvements.

Compose interactive preview enabled by default

Starting with Android Studio Bumblebee, the interactive preview feature is enabled by default. The interactive preview allows you to interact with a preview as it would work on a device. The interactive preview is isolated from other preview in a sandbox environment, where you can click elements and enter user input in the preview. It’s a quick way to test different states and gestures of your composable, like a checkbox being checked or empty.

Preview interactive mode runs directly inside Android Studio without an emulator running, which results in some limitations:

No network access.

No file access.

Some Context APIs may not be fully available.

Animated Vector Drawable (AVD) preview

The Animated Vector Drawable tool offers the ability to preview animated drawable resources. This tools helps you preview , , and resources in Android Studio and makes it easier to refine your custom animations.

To simplify designing your app for the diverse number of Android devices, we’ve updated the device picker in various design tool windows, such as Layout Editor and Layout Validation, with reference devices that reflect popular sizes of each device form factor. From phones to tablets, and Wear devices to Android TVs, it’s now easier to preview, validate, or edit your layout on screen sizes that are most representative of popular real-world devices.

KMP test execution

You can run tests for Kotlin Multiplatform (KMP) projects from Android Studio Bumblebee.

In order to ensure that your tests run successfully from Android Studio, you must have all of the requirements below:

AGP 7.0.0-alpha08 or higher

Gradle 6.8.2 or higher

Kotlin plugin 1.4.30 or higher

Non-transitive R classes on by default

Non-transitive R classes are now on by default. You can use non-transitive R classes with the Android Gradle plugin to build faster builds for applications with multiple modules. Doing so helps prevent resource duplication by ensuring that each module’s R class only contains references to its own resources, without pulling references from its dependencies. This leads to more up-to-date builds and the corresponding benefits of compilation avoidance.

You can get help using this feature by going to Refactor > Migrate to Non-Transitive R Classes…

For those using macOS on Apple Silicon (arm64) hardware, Android Studio Arctic Fox and the Android Emulator have supported this new architecture since last year. However, with this release, we have now updated the Android SDK platform tools v32.0.0 (which includes adb and fastboot) and build tools v32.1.0 (which includes aapt) to be universal binaries so that your Android developer tools no longer need the Rosetta binary translator to run. See the SDK platform tools release notes.

New in Layout Inspector

Capture layout hierarchy snapshots

Layout Inspector now allows you to save snapshots of your running app’s layout hierarchy, so that you can easily share them with others or refer to them later.

Snapshots capture the data you would typically see when using the Layout Inspector, including a detailed 3D rendering of your layout, the component tree of your View, Compose, or hybrid layout, and detailed attributes for each component of your UI. To save a snapshot, do the following:

Deploy your app to a device running API level 23 or higher Open the Layout Inspector by selecting View > Tool Windows > Layout Inspector. The Layout Inspector should connect to your app process automatically. If not, select the app process from the dropdown menu. When you want to capture a snapshot, click Export snapshot from the Layout Inspector toolbar. In the system dialog that appears, specify the name and location you want to save your snapshot. Make sure to save the file with a *.li extension.

You can then load a Layout Inspector snapshot by selecting File > Open from the main menu bar, and opening a *.li file.

Support for inspecting Compose semantics

In Compose, Semantics describe your UI in an alternative manner that is understandable for Accessibility services and for the Testing framework. In Android Studio Bumblebee, you can now use the Layout Inspector to inspect semantic information in your Compose layouts.

When selecting a Compose node, use the Attributes window to check whether it declares semantic information directly, merges semantics from its children, or both. To quickly identify which nodes include semantics, either declared or merged, use select the View options dropdown in the Component Tree window and select Highlight Semantics Layers. This highlights only the nodes in the tree that include semantics, and you can use your keyboard to quickly navigate between them.

Avoid Activity restarts

Connecting the Layout Inspector to a running app on older versions of Android Studio would cause your app’s Activity to restart. This is required to set a device flag that enables inspection of your app’s layouts.

In Android Studio Bumblebee, you can avoid Activity restarts when connecting the Layout Inspector by setting this flag ahead of time using one of the following steps:

Enable a Run Configuration option Select Run > Edit Configurations from the main menu bar. The Run/Debug Configurations dialog appears. Navigate to the run configuration you would like to use. In the Layout Inspector options section, check the box next to Connect to Layout Inspector without restarting activity . Use the run configuration the next time you want to inspect your app using the Layout Inspector.

Set the flag from the command line: Open a terminal window on the machine that’s connected to your device Set the device flag for your app using the following command: adb shell settings put global debug_view_attributes_application_package Deploy your app to the device and connect the Layout Inspector. Android Studio will check whether the flag is set and avoid restarting the Activity if possible.

Note: While typically not noticeable, setting this device flag when not using the Layout Inspector might affect the app’s performance.

Document Layout Inspector snapshots

You can now capture snapshots of your app’s layout hierarchy to save, share, or inspect later. Snapshots capture the data you would typically see when using the Layout Inspector, including a detailed 3D rendering of your layout, the component tree of your View, Compose, or hybrid layout, and detailed attributes for each component of your UI. When inspecting the layout of a live running app, click Export snapshot from the Layout Inspector toolbar and save the snapshot with an *.li extension. You can then load a Layout Inspector snapshot by selecting File > Open from the main menu bar, and opening a *.li file. The snapshot appears in a tab in the Editor window, so that you can easily compare it with your running app.

New in App Inspection

In Android Studio Bumblebee, there are new tools and functionalities in the App Inspection window. You can open the App Inspector by selecting View > Tool Windows > App Inspection from the main menu bar.

Network Inspector

The Network Profiler in the Profilers tool window has now moved to the App Inspection tool window. If you’ve previously used the Network Profiler, all the same features and rich network traffic data is still available. Simply deploy your app to a device running API level 26 and higher and open the App Inspector > Network Inspector tab.

Inspect Jobs, Alarms, and Wakelocks

The Background Task Inspector now allows you to inspect your app’s Jobs, Alarms, and Wakelocks, in addition to the existing support for inspecting Workers. Each type of asynchronous task now appears under the appropriate heading in the inspector tab, allowing you to easily monitor its status and progress. Similar to Workers, you can select a Job, Alarm, or Wakelock to inspect its detailed information in the Task Details panel.

Note: Background task inspector to inspect all of your app’s asynchronous tasks. This functionality has been migrated from the Energy profiler . So you should now use theto inspect all of your app’s asynchronous tasks.

Because Workers use Jobs and Wakelocks under the hood, those tasks that are scheduled by Workers appear as children of each Worker. Keep in mind, you can only see Workers in the Graph mode.

Wireless debugging

Android Studio Bumblebee supports the wireless debugging feature on Android 11 and higher devices. Pair and deploy your app from Android Studio over Wi-Fi without using a USB cable or managing Android Debug Bridge (adb) connections using the command line. To use, navigate to the Pair devices using Wi-Fi option from the device selection menu, and then either choose a QR code or Pairing PIN Code. Then on your Android 11 and higher device, under Developer options, and find the Wireless Debugging screen and initialize and connect to an adb session wirelessly with Android Studio. Learn more about the wireless debugging setup at Connect to a device over Wi-Fi (Android 11+).

Unified Gradle test runner

Android Gradle plugin 7.1.0 and Android Studio Bumblebee and higher use Gradle’s own implementation of the Android instrumented test runner to run instrumented tests. By using the same test runner, results are likely to be consistent whether you run using AGP from the command line, such as on a continuous integration server, or from Android Studio.

Previous versions of Android Studio use the IntelliJ Android instrumented test runner instead of Gradle’s Android instrumented test runner. So if you’re not using the latest version of Android Studio, depending on whether you run your tests from Android Studio or from the command line using the Gradle plugin, you might see different test results, such as tests passing using one runner and failing on another.

If you already have instrumented test configurations saved to your project, they’ll use Gradle to run tests on your connected device. You can create a new instrumented test configuration using the gutter action next to your test class or method, as shown below.

When running your instrumented tests, you can confirm that Android Studio is using the Gradle test runner by inspecting the test output in the Test Matrix for Gradle task output. Although we are improving this feature with each release of Android Studio, there are some known issues. If you are experiencing issues, please report a bug. You can also disable the new testing pipeline to revert to the old behavior.

Android Emulator now runs directly inside Android Studio by default

The Android Emulator runs directly inside Android Studio by default. This allows you to conserve screen real estate, navigate quickly between the emulator and the editor window using hotkeys, and organize your IDE and emulator workflow in a single application window.

When the emulator is running, you’ll have access to common emulator actions like rotating, and extended control options like navigation playback. To run the emulator in a separate window instead go to File > Settings > Tools > Emulator (Android Studio > Preferences > Tools > Emulator on macOS) and deselect Launch in a tool window.

Disable the new testing pipeline

By default, Android Studio Bumblebee uses Gradle to run its instrumentation tests. If you’re experiencing issues, you can disable this behavior as follows:

Select File > Settings > Build, Execution, Deployment > Testing (or Android Studio > Preferences > Build, Execution, Deployment > Testing on MacOS.) Uncheck the box next to Run Android instrumented tests using Gradle and click OK.

You can also revert to older behaviors by doing one of the following:

When running Gradle tasks from the command line, use the following command line parameter: -Pandroid.experimental.androidTest.useUnifiedTestPlatform=false

Add the following parameter to your project’s gradle.properties file: android.experimental.androidTest.useUnifiedTestPlatform=false

To help resolve issues that you might be experiencing, please report a bug.

New Device Manager

The Device Manager is a stand-in replacement for the AVD Manager, both from Android Studio’s Welcome Screen or after you open a project. The Device Manager introduces some new capabilities that make it easier for you to create and manage all of your local test devices, such as:

A more flexible UI that supports being docked in the IDE, floating, or in a separate window, like you can with other Android Studio tool windows. This gives you easier access to your devices without obstructing other windows of the IDE.

A Virtual tab that allows you to create, manage, and deploy virtual devices; see details of each device at a glance; or quickly inspect the device in the Device File Explorer with a single click.

tab that allows you to create, manage, and deploy virtual devices; see details of each device at a glance; or quickly inspect the device in the Device File Explorer with a single click. A Physical tab that allows you to quickly pair to a new device using ADB Wifi and see details of each physical device at a glance. You can also quickly inspect each device’s file system using the Device File Explorer with a click of a button.

To open the new Device Manager, do one of the following:

From the Android Studio Welcome screen, select More Actions > Virtual Device Manager.

Note: You can currently create and manage only virtual devices from the welcome screen.

After opening a project, select View > Tool Windows > Device Manager from the main menu bar.

UI jank detection

When profiling your app using devices running Android 11 (API level 30) or higher, the CPU profiler now shows a new group of tracks that illustrate the stages of each frame under Frame Lifecycle: Application, Wait for GPU, Composition and Frames on display. Each track labels the frames with a frame number and color-codes the rectangle to make it easy for you to visualize where a particular frame is in its lifecycle, along with guides you can toggle to compare with Vsync events. You can use this data to understand where jank might occur in your app and investigate the root causes. In the Analysis panel, there is now a Frames tab, which conveniently summarizes rendering information for all frames. For more information, see UI jank detection.

Profileable app profiling support

When profiling your app, it’s important to generate accurate data with the version of your app that most closely resembles what your users will install. To do so, you can now include the property in your app’s manifest to profile apps that are not debuggable, as shown by the following code.

Profileable is a manifest configuration introduced in Android 10, and is available for CPU and Memory profiling tasks. Using the profileable flag instead of the debuggable flag has the key advantage of lower overhead for performance measurement; however, certain profiling features are not available for Profileable builds, such as the Event timeline, API initiated CPU profiling, heap dumps, or live location recordings. For more information, see Profileable applications.

Collapse callstack frames

You can now collapse frames that are irrelevant to your investigation when inspecting a Callstack Sample Recording in the Profilers tool window. Callstacks are useful to understand which part of the code has been executed, and why it was invoked. However, the callstack for a Java/Kotlin program usually includes not only Java/Kotlin code, but also frames from native code that can be distracting. To learn more about refining the callstack view, see Inspect callstack frames.

Patch releases

The following is a list of the Patch releases in Android Studio Bumblebee.

Android Studio Bumblebee | 2021.1.1 Patch 3 (April 2022)

This minor update includes the following bug fixes:

Android Gradle plugin Duplicate class issues reported by R8

Build Variants versionNameSuffix no longer works if the variant’s version name is set via the new onVariants API

Compose Preview Performance and stability related bug fixes. Solve freeze that occurred occasionally when using the Live Edit of Literals feature.

Network Inspector New Network inspector crashes after Bumblebee update I am constantly getting this error when the debugger is connected on the latest version of Android Studio. TrackedHttpURLConnection.getHeaderField crashes with NullPointerException

For more information, see the Android Studio Bumblebee Patch 3 blog post

Android Studio Bumblebee | 2021.1.1 Patch 2 (February 2022)

This update includes the following bug fixes:

C++ Build ModelCache.safeGet(androidProjectResult.androidProject::getNdkVersion, “”) must not be null

Code Editor Bug in Android Studio Live Templates – the className() expression is not resolving the class name

D8/R8 java.lang.NoSuchMethodError: No static method $jacocoInit Android test coverage broken due to Mockito error Need workaround for broken CAS implementation on API 31 Sealed classes are not supported NullPointerException when enabling horizontal class merging in Chrome AbstractMethodError after virtual method merging Failure to verify stack frames due to incorrect init-class out-type Dex input uses a register that is not defined StringBuilderOptimizerAnalysisTest is failing on release branches Non-determinism in R8

Deployment Running the project of a device owner application fails with “Couldn’t terminate the existing process for” error message

Design Tools Compose Previews fail to find resources from other modules when non-transitive R classes is enabled Studio freezes on build.

Embedded Emulator Miscellaneous performance and stability improvements.

Import/Sync IDE error when launching Bumblebee: Output listing build file is not available for output type Apk in IdeBuildTasksAndOutputInformationImp

IntelliJ Env variables not sourced when launched from Mac OS X Monterey Dock

Jetpack (androidx) > Navigation Upgrade SafeArgs to be built on latest stable AGP

Tools Windows Can’t run Android Device Manager Network Inspector in BumbleBee doesn’t show the api response in readable format

For more information, see the Android Studio Bumblebee Patch 2 blog post

Android Studio Bumblebee | 2021.1.1 Patch 1 (February 2022)

This minor update includes the following bug fixes:

Emulator Unable to connect to embedded emulator after upgrading to Bumblebee (Mac M1)

IntelliJ Env variables not sourced when launched from Mac OS X Monterey Dock

For more information, see the Android Studio Bumblebee Patch 1 blog post.

Android Studio Arctic Fox | 2020.3.1

Android Studio Arctic Fox is a major release that includes the following features and improvements.

New version numbering

We have changed the version numbering system for Android Studio to more closely align with IntelliJ IDEA, the IDE that Android Studio is based on.

In the previous numbering system, this release would have been numbered as Android Studio 4.3 or version 4.3.0.1. With the new numbering system, it is now Android Studio – Arctic Fox | 2020.3.1, or version 2020.3.1.

Intellij Version Old Name Old – Number System New – Year System New Version Name 2020.3 4.3 4.3.0 2020.3.1 Arctic Fox | 2020.3.1

Going forward, here’s how the Android Studio version number is determined:

. . .

The first two number groups represent the version of the IntellIj platform that a particular Android Studio release is based on. For this release, it’s version 2020.3.

The third number group represents the Studio major version, starting at 1 and incrementing by one for every major release.

The fourth number group represents the Studio minor/patch version, starting at 1 and incrementing by one for every minor release.

We are also giving each major release a version name, incrementing from A to Z based on animal names. This release is named Arctic Fox.

We have changed the version numbering for Android Gradle plugin (AGP) to more closely match the underlying Gradle build tool. Therefore, AGP 7.0 is the next release after AGP 4.2.

For more details, see Versioning changes in the AGP release notes.

Android Gradle plugin 7.0.0

The latest version of the Android Gradle plugin includes many updates. To learn more, read the full Android Gradle plugin release notes.

Unit tests now uses Gradle test runner

To improve overall consistency of test executions, Android Studio now uses Gradle to run all unit tests by default. In many cases, this change will not affect your testing workflow in the IDE.

For example, when you click the Run command in the context menu (visible when you right-click on a test class) or its corresponding gutter action , Android Studio will use the Gradle run configuration by default to run unit tests.

However, Android Studio no longer recognizes existing Android JUnit run configurations, so you should migrate Android JUnit run configurations that you might save as project files to Gradle run configurations.

To create a Gradle test configuration, select the Gradle template when following the instructions in Create a new run/debug configuration. When you’ve created a new configuration, it will appear in the Edit Configurations dialog in the Gradle section:

If you want to inspect Android JUnit configurations that are no longer recognized, you can do one of two things:

Open manually saved configurations in a text editor. The locations of these files are specified by the user, but the files typically appear in /.idea/runConfigurations/ .

. Look for temporary configurations in /.idea/workspace.xml and look under the node. For example:

New Background Task Inspector

You can visualize, monitor, and debug your app’s background workers using the new Background Task Inspector. To get started, deploy your app to a device running WorkManager library 2.5.0 or higher, and select View > Tool Windows > App Inspection from the menu bar.

You can view more detailed information by clicking on a worker. For example, you can see the description of the worker, how it was executed, details of its worker chain, and the result of the execution.

You can also view a visual representation of a worker chain by selecting a worker from the table and clicking Show Graph View from the toolbar. You can then select any worker in the chain to see its details, or stop it if it’s currently enqueued or running. To return to the table, click Show List View .

To help you investigate issues from workers that fail execution, you can stop a currently running or enqueued worker by selecting it from the table and clicking Cancel Selected Worker from the toolbar. You can also filter workers in the table by tags you’ve assigned to them using the All tags dropdown menu.

Updates Database Inspector

The Database Inspector is now included in the new App Inspection tool window, where you can also find the new Background Task Inspector. Open the App Inspection tool window from the tool window bar, or select View > Tool Windows > App Inspection from the menu bar.

Export data from the Database Inspector

In Arctic Fox, you can easily export databases, tables, and query results from the Database Inspector to save, share, or recreate locally. When you open up an app project in Android Studio and inspect the app for that project in the Database Inspector, you can start exporting data in one of the following ways:

Select a database or table in the Databases panel and click Export to file near the top of the panel.

panel and click near the top of the panel. Right-click on a database or table in the Databases panel and select Export to file from the context menu.

panel and select from the context menu. When inspecting a table or query results in a tab, click Export to file above the table or query results.

After selecting an export action, you use the Export dialog to help you through the final steps, as shown below. Depending on whether you are trying to export a database, table, or query results, you have the option of exporting the data in one or more of the following formats: DB, SQL, or CSV.

Updated UI for recording in Memory Profiler

We have consolidated the Memory Profiler user interface (UI) for different recording activities, such as capturing a heap dump and recording Java, Kotlin, and native memory allocations.

The Memory Profiler provides the following options:

Capture heap dump : View objects in your app that are using memory at a specific point in time.

: View objects in your app that are using memory at a specific point in time. Record native allocations : View how each C/C++ object was allocated over a period of time.

: View how each C/C++ object was allocated over a period of time. Record Java/Kotlin allocations: View how each Java/Kotlin object was allocated over a period of time.

Here’s how to use these three options:

To capture a heap dump, select Capture heap dump , then select Record . After the profiler finishes capturing the heap dump, the Memory Profiler UI transitions to a separate screen displaying the heap dump.

To record native allocations on devices running Android 10 and higher, select Record native allocations , then select Record . The recording continues until you click Stop , after which the Memory Profiler UI transitions into a separate screen displaying the native recording. On Android 9 and lower, the Record native allocations option is not available.

To record Java and Kotlin allocations, select Record Java / Kotlin allocations, then select Record. If the device is running Android 8 or higher, the Memory Profiler UI transitions to a separate screen displaying the ongoing recording. You can interact with the mini timeline above the recording (for example, to change the selection range). To complete the recording, select Stop . On Android 7.1 and lower, the memory profiler uses legacy allocation recording, which displays the recording on the timeline until you click Stop.

Updates to Refresh Linked C++ Project

We have moved files unrelated to configuration from the .cxx/ folder into the build/ folder. CMake C++ builds require a configuration phase that generates the Ninja project that’s used to execute the compile and link steps. Projects generated by CMake are expensive to generate and are expected to survive across gradle clean. For this reason, they’re stored in a folder called .cxx/ , next to the build/ folder. Typically, Android Gradle plugin will notice configuration changes and automatically regenerate the Ninja project. However, not all cases can be detected. When this happens, the “Refresh Linked C++ Project” option can be used to manually regenerate the Ninja project.

New test matrix for multi-device testing

Instrumentation tests can now run across multiple devices in parallel and can be investigated using a specialized instrumentation test results panel. Using this panel, you can determine if tests are failing due to API level or hardware properties.

Testing your app across a wide variety of API levels and form factors is one of the best ways to ensure that all users have a great experience when using your app.

To take advantage of this feature:

Choose Select Multiple Devices in the target device dropdown menu from the top-center of the IDE). Select the target devices and click OK. Run your tests.

To view your test results in the Run panel, go to View > Tool Windows > Run.

The new test results panel allows you to filter your test results by status, device, and API level. Additionally, you can sort each column by clicking the header. By clicking on an individual test, you can view logs and device information individually for each device.

StateFlow support in data binding

For Kotlin apps that use coroutines, you can now use StateFlow objects as a data binding source to automatically notify the UI about changes in the data. Your data bindings will be lifecycle aware and will only be triggered when the UI is visible on the screen.

To use a StateFlow object with your binding class, you need to specify a lifecycle owner to define the scope of the StateFlow object, and in your layout, assign the properties and methods of your ViewModel component to the corresponding views using binding expressions, as shown in the following example:

class ViewModel() { val username: StateFlow }

If you’re in a Kotlin app that uses AndroidX, StateFlow support is automatically included in the functionality of data binding, including the coroutines dependencies.

To learn more, see Work with observable data objects.

Improved suggested import

We’ve improved the number of libraries that are supported by the suggested import feature and update the index more frequently. Suggested import helps you quickly and easily import certain Google Maven artifacts into both your class and Gradle project. When Android Studio detects unresolved symbols from certain Google libraries, the IDE suggests importing the library into both the class and the project.

Support for configuration cache in Build Analyzer

Build Analyzer now identifies when a project doesn’t have configuration cache enabled, and offers it as an optimization. Build Analyzer runs a compatibility assessment to inform you if there are any issues with configuration cache in your project before it gets enabled.

Improved Upgrade Assistant for AGP

The Upgrade Assistant for Android Gradle plugin now has a persistent tool window with the list of steps that will be completed. Additional information is also presented on the right side of the tool window. If needed, you can also choose a different version of AGP to upgrade to. Clicking on the Refresh button updates the corresponding update steps.

Refactoring for non-transitive R classes

You can use non-transitive R classes with the Android Gradle plugin to build faster builds for applications with multiple modules. Doing so helps prevent resource duplication by ensuring that each module’s R class only contains references to its own resources, without pulling references from its dependencies. This leads to more up-to-date builds and the corresponding benefits of compilation avoidance.

You can access this feature by going to Refactor > Migrate to Non-transitive R Classes.

Note: Previously, the option to use non-transitive R classes with AGP only applied to libraries. Now, in AGP 4.2 and higher, this option applies to all modules.

Support for Jetpack Compose tooling

We now offer additional support for previewing and testing apps that use Jetpack Compose. For the best experience developing with Jetpack Compose, you should use the latest version of Android Studio Arctic Fox so that you can benefit from smart editor features, such as New Project templates and the ability to immediately preview your Compose UI.

Compose preview

The following parameters for @Preview methods are now available:

showBackground : Switch on and off a background for your preview.

: Switch on and off a background for your preview. backgroundColor : Set a color that is only used in the preview surface.

: Set a color that is only used in the preview surface. uiMode: This new parameter can take any of the Configuration.UI_* constants and allows you to change the behavior of the preview to, for example, set it to Night Mode to see how the theme reacts.

Interactive preview

You can use this feature to interact with your UI components, click them, and see how the state changes. It’s a quick way to get feedback on how your UI reacts and to preview the animations. To enable it, click the Interactive icon , and the preview will switch modes.

To stop, click on Stop Interactive Preview in the top toolbar.

Deploy to device

You can use this feature to deploy a snippet of your UI to a device. This helps test small parts of your code in the device without having to start the full application.

Click the Deploy to Device icon next to the @Preview annotation or at the top of the preview, and Android Studio will deploy that @Preview to your connected device or emulator.

Live Edit of literals

We have added Live Edit of literals to help developers using Compose quickly edit literals (strings, numbers, booleans) in their code and see the results immediately without needing to wait for compilation. The goal of this feature is to help increase your productivity by having code changes appear near instantaneously in the previews, emulator, or physical device.

Compose support in the Layout Inspector

The Layout Inspector allows you to see rich detail about your app’s layout running on your connected device. You can interact with your app and see live updates in the tool to quickly debug issues that might arise.

You can inspect layouts written with the new Android declarative UI framework, Jetpack Compose. Whether your app uses layouts fully written in Compose or layouts that use a hybrid of Compose and Views, the Layout Inspector helps you understand how your layouts are rendered on your running device.

Get started

To get started, deploy your app to a connected device and then open the Layout Inspector window by selecting View > Tool Windows > Layout Inspector. If the Layout Inspector doesn’t automatically connect to your app process, select the desired app process from the process pulldown. You should soon see your app’s layout rendered in the tool window. To get started inspecting your Compose layout, select the layout component visible in the rendering or select it from the Component Tree.

The Attributes window shows you detailed information about the Compose function currently selected. In this window, you can inspect the function’s parameters and their values, including modifiers and lambda expressions. For lambda expressions, the inspector provides a shortcut to help you navigate to the expression in your source code.

The Layout Inspector shows all Compose functions in the call stack that emit components to your app’s layout. In many cases, this includes Compose functions that are called internally by the Compose Library. If you want to see only the Compose functions in the Component Tree that your app calls directly, click the filter action, which might help reduce the number of nodes shown in the tree to the ones you are likely to want to inspect.

Improved deploy dropdown

The device dropdown now distinguishes between different kinds of errors within your chosen device configuration. Iconography and stylistic changes now differentiate between errors (device selections that result in a broken configuration) and warnings (device selections that may result in unexpected behavior but are still runnable).

In addition, Android Studio will now warn you if you attempt to launch your project to a device that has an error or a warning associated with it.

New Wear OS pairing assistant

The new Wear OS pairing assistant guides developers step-by-step through pairing Wear OS emulators with physical or virtual phones directly in Android Studio. The assistant can help you get the right Wear OS Companion app installed on your phone and set up a connection between the two devices. You can get started by going to the device dropdown > Wear OS Emulator Pairing Assistant.

Responsive layout template

Android Studio Arctic Fox now includes a new layout template that adapts to various display dimensions and app resizing, such as phones, foldables, tablets, and split screen modes. When creating a new project or module, select the Responsive Activity template to create a layout with components that dynamically resize.

To get started, navigate to File > New, select either New Project or New Module, and select the Responsive Activity template.

Known issues for Arctic Fox

This section describes current known issues in Android Studio Arctic Fox.

Patches not working on Windows for v3.6-v4.1

Patches on Windows platform for v3.6-v4.1 to Android Studio Arctic Fox stable may not work.

4.2 (April 2021)

Android Studio 4.2 is a major release that includes a variety of new features and improvements.

Android Gradle plugin 4.2.0

The latest version of the Android Gradle plugin includes many updates. To learn more, read the full Android Gradle plugin release notes.

Gradle compatibility and configuration changes

When running in Android Studio, the Gradle build tool uses Studio’s bundled JDK. In previous releases, JDK 8 was bundled with Studio. In 4.2, however, JDK 11 is now bundled instead. When using the new bundled JDK to run Gradle, this may result in some incompatibility or impact JVM performance due to changes to the garbage collector. These issues are described in the AGP release notes.

Option to optimize Gradle sync time

To improve Gradle Sync performance, Android Studio skips building the task list during sync. This allows Gradle Sync to complete faster and improves UI responsiveness for very large projects. This option is on by default in Android Studio 4.2. To turn it off, go to File > Settings > Experimental (Preferences > Experimental on a Mac) and uncheck Do not build Gradle task list during Gradle sync.

Database Inspector

Query editor improvements

The Database Inspector includes some improvements to help you write and execute your custom SQL statements. When you open the inspector and open a New query tab, you should notice a larger, resizable editor surface to author and format your queries, as shown below.

Additionally, we now provide a history of your previous queries. When you click on the Show query history button, you should see a list of queries you previously ran against the currently selected database. Click a query in the list to see a preview of the full query in the editor and press Enter to copy it to the editor. Then, click Run to execute the statement.

Offline mode

In previous versions of Android Studio, disconnecting from an app process while using the Database Inspector resulted in closing the inspector and its data. In Android Studio 4.2, we’ve added the ability to keep inspecting your app’s databases after a process disconnects, making it easier to debug your app after a crash.

When a disconnect occurs, the Database Inspector downloads your databases and then makes them available to you in offline mode. When offline, you can open tables and run queries.

Keep in mind, when you reconnect to a live app process, the Database Inspector returns to live mode and shows you only the data that is on the device. That is, data shown in offline mode doesn’t persist when you reconnect to an app process. Because of this, the Database Inspector does not allow editing or running modification statements while in offline mode.

Upgrade Assistant for AGP

A new Upgrade Assistant for Android Gradle plugin can help you update the AGP version for your project.

Built on top of the existing AGP upgrade functionality, this tool guides you through project-wide updates/refactorings and includes a preview of the updates to help prevent potential breaking changes before executing the AGP upgrade.

In the CPU profiler, the System Trace feature now includes new metrics for analyzing app performance and includes the following:

Events Table. Lists all trace events in the currently selected thread.

BufferQueue. In the Display section, this new track shows the buffer count of the app’s surface BufferQueue (0, 1, or 2) to help you understand the state of image buffers as they move between the Android graphics components.

CPU Frequency. In the CPU cores section, this new track displays CPU frequency by core, indicating how hard each core is working.

Process Memory (RSS). This new window shows the amount of physical memory currently in use by the app.

For more details, see Inspect CPU activity with CPU Profiler.

New Layout Inspector refresh action

Introduced in Android Studio 4.0, the Layout Inspector was designed for real-time inspection of your running app’s UI stack. However, you might not always want the Layout Inspector to immediately reflect what’s happening in your app, since you might want to inspect a snapshot of your app’s layout at a specific point in time or minimize the performance impact of live updates on your app.

Pause live updates and refresh the screen capture in the Layout Inspector.

To manually load a snapshot of UI data from your app, first disable the Live updates option. You can then click the Refresh button to take a new snapshot of the UI stack for inspection. The Layout Inspector now remembers your preference to keep Live updates enabled or disabled between sessions.

Support for Safe Args

Safe Args is a Gradle plugin that generates simple object and builder classes for type-safe navigation and access to any associated arguments. Android Studio now includes richer support when working with Safe Args, as described below:

Autocompletions for Directions, Args, and the various builder classes

Support for both Java and Kotlin safe args plugins

Navigation from source to XML

R8 retrace now available in command-line tools

Available in version 4.0 of the command-line tools, R8 retrace is a standalone tool for obtaining the original stack trace from an obfuscated stack trace.

You can download this package with the SDK manager, which installs R8 retrace in android_sdk /cmdline-tools . Alternatively, you can download the standalone command-line tools package.

For usage information, see R8 retrace in the user guide.

Deploy to multiple devices

To help streamline app testing across devices and API levels, you can now deploy your app to multiple devices or emulators simultaneously by following these steps:

Choose Select Multiple Devices in the target device dropdown menu (in the top-center of the IDE). Select the target devices and click OK. Run your app.

Note: Running and viewing tests across multiple devices is an experimental feature. When running a test configuration across multiple devices, you might be prompted to enable this feature before you can proceed.

New removable setting for feature modules

Android Gradle plugin 4.2 uses bundletool 1.0.0, which introduces a behavior change for apps using feature modules: Any feature module specified as dist:install-time that’s not explicitly marked as dist:removable will become non-removable by default. This new setting optimizes fusing of install-time modules with the base module, potentially improving app performance for some apps.

To keep feature modules removable, set dist:removable=”true” on any module you want to uninstall.

For more information on this new setting, see the documentation for the dist:removable tag in the documentation for feature module manifest.

Apply Changes

To help you be more productive as you iterate on your app, we’ve made the following enhancements to Apply Changes for devices running Android 11 or higher:

Support for additional code changes

For devices running Android 11 or higher, you can now add static final primitive fields and then deploy those changes to your running app by clicking either Apply Code Changes or Apply Changes and Restart Activity .

You can now also add resources and then deploy those changes to your running app on Android 11 devices by clicking Apply Changes and Restart Activity .

Updated New Project and New Module wizards

The New Project and New Module wizards have been updated to make it easier to browse, select a template, and input information about the new project or module.

The option to Import .JAR/.AAR Package from the New Module wizard has also been removed. To import a JAR or AAR into your project, use the Project Structure Dialog instead.

Kotlin 1.4.31

Android Studio 4.2 bundles Kotlin 1.4.31. Check out the Kotlin 1.4.0 changelog to review the major changes.

ANDROID_SDK_HOME environment variable deprecated

The ANDROID_SDK_HOME environment variable is deprecated and has been replaced with ANDROID_PREFS_ROOT . For more information, see Emulator Environment Variables.

Known Issues with Android Studio 4.2

This section describes known issues that exist in Android Studio 4.2. For a complete list, go to the Known issues page.

Android Studio 4.2.0 generates projects with wrong Kotlin version: “1.5.0-release-764”

If you are using Android Studio 4.2.0 and have upgraded to Kotlin plugin 1.5.0, then new Kotlin projects created by Studio will fail to build due to the following Gradle sync error: Could not find org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.0-release-764.

As a workaround, replace “1.5.0-release-764” with “1.5.0” in the project’s build.gradle files.

Error when using different passwords for key and keystore

Starting with version 4.2, Android Studio now runs on JDK 11. This update causes an underlying behavior change related to signing keys.

When you navigate to Build > Generate Signed Bundle / APK and attempt to configure app signing for an app bundle or an APK, entering different passwords for the key and keystore may result in the following error:

Key was created with errors: Warning: Different store and Key passwords not supported for PKCS12 Key stores

To work around this issue, enter the same password for both the key and keystore.

Android Studio doesn’t start after installing version 4.2

Studio tries to import previous .vmoptions and sanitize them to work with the garbage collector used by JDK 11. If that process fails, the IDE may not start for certain users who set custom VM options in the .vmoptions file.

To work around this issue, we recommend commenting out custom options in .vmoptions (using the “#” character). The .vmoptions file can be found in the following locations:

Windows

C:\Users\YourUserName\AppData\ [Local|Roaming] \Google\AndroidStudio4.2\studio64.exe.vmoptions

macOS

~/Library/Application Support/Google/AndroidStudio4.2/studio.vmoptions

Linux

~/.config/Google/AndroidStudio4.2/studio64.vmoptions

If Studio still doesn’t start after trying this workaround, see Studio doesn’t start after upgrade below.

4.1 (August 2020)

Android Studio 4.1 is a major release that includes a variety of new features and improvements.

Android Gradle plugin 4.1.0

The latest version of the Android Gradle plugin includes many updates. To learn more, read the full Android Gradle plugin release notes.

New Database Inspector

Inspect, query, and modify your databases in your running app using the new Database Inspector. To get started, deploy your app to a device running API Level 26 or higher, and select View > Tool Windows > Database Inspector from the menu bar.

To learn more, see Debug your database with the Database Inspector.

Run the Android Emulator directly in Android Studio

You can now run the Android Emulator directly in Android Studio. Use this feature to conserve screen real estate, to navigate quickly between the emulator and the editor window using hotkeys, and to organize your IDE and emulator workflow in a single application window.

To learn more, see the Android Emulator documentation.

Use TensorFlow Lite models

ML Model Binding makes it easy for you to directly import .tflite model files and use them in your projects. Android Studio generates easy-to-use classes so you can run your model with less code and better type safety.

Supported models

The current implementation of ML Model Binding supports image classification and style transfer models, provided they are enhanced with metadata. Over time, support will be expanded to other problem domains, like object detection, image segmentation, and text classification.

A wide range of pre-trained models with metadata are provided on TensorFlow Hub. You can also add metadata to a TensorFlow Lite model yourself, as is outlined in Adding metadata to TensorFlow Lite model.

Import a model file

To import a supported model file, follow these steps:

Open the TensorFlow Lite model import dialog in the File menu at File > New > Other > TensorFlow Lite Model. Select the .tflite model file that you previously downloaded or created. Click Finish.

This imports the model file into your project and places it in the ml/ folder; if the directory doesn’t exist, Android Studio will create it for you.

View model metadata and usage

To see the details for an imported model and get instructions on how to use it in your app, double-click the model file in your project to open the model viewer page, which shows the following:

Model: High-level description of the model

High-level description of the model Tensors: Description of input and output tensors

Description of input and output tensors Sample code: Example of how to interface with the model in your app

Here is an example using mobilenet_v1_0.25_160_quantized.tflite:

As the example demonstrates, Android Studio creates a class called MobilenetV1025160Quantized for interacting with the model.

If the model does not have metadata, this screen will only provide minimal information.

Known issues and workarounds

Support for TensorFlow Lite models for problem domains other than image classification and style transfer is currently limited. Although import should work fine, some model inputs and/or outputs are represented by TensorBuffers rather than friendly types. For models without any metadata, all model inputs and outputs will be TensorBuffers.

Models with Input and Output data types different from DataType.UINT8 or DataType.FLOAT32 are not supported.

This feature is still under development, so please provide feedback or report bugs.

Native Memory Profiler

The Android Studio Memory Profiler now includes a Native Memory Profiler for apps deployed to physical devices running Android 10 or later. With the Native Memory Profiler, you can record memory allocations and deallocations from native code and inspect cumulative statistics about native objects.

To learn more about the Native Memory Profiler, see Inspect your app’s memory usage with Memory Profiler.

Known issues and workarounds

The Native Memory Profiler in Android Studio 4.1 does not work for Android 11 devices. Support for profiling Android 11 devices is currently available in the 4.2 preview release

As of the initial 4.1 release, app startup profiling has been disabled. This option will be enabled in an upcoming release. As a workaround, you can use the Perfetto standalone command-line profiler to capture startup profiles.

System Trace UI: Easier selection, new analysis tab, and more frame rendering data

The System Trace UI in the Android Studio profiler includes the following improvements:

Box selection: In the Threads section, you can now drag your mouse to perform a box selection of a rectangular area, which you can zoom into by clicking the Zoom to Selection button on the top right (or use the M keyboard shortcut). When you drag and drop similar threads next to each other, you can select across multiple threads to inspect all of them at once. For example, you may want to perform analysis on multiple worker threads.

Summary tab: The new Summary tab in the Analysis panel displays: Aggregate statistics for all occurrences of a specific event, such as an occurrence count and min/max duration. Trace event statistics for the selected occurrence. Data about thread state distribution. Longest-running occurrences of the selected trace event. To navigate to another occurrence, select another row from the table.

Display data: In the Display section, new timelines for SurfaceFlinger and VSYNC help you investigate rendering issues in your app’s UI.

For basic usage instructions on how to record a system trace, see the Record traces section of Inspect CPU activity with CPU Profiler.

Windows users: If labels are missing in the thread activity timeline when you profile your app, see the known issues for a workaround. This issue is fixed in the 4.2 release.

Standalone profilers now available

With the new standalone profilers, it’s now possible to profile your app without running the full Android Studio IDE.

For instructions on using the standalone profilers, see Run standalone profilers.

Dagger navigation support

Android Studio makes it easier to navigate between your Dagger-related code by providing new gutter actions and extending support in the Find Usages window.

New gutter actions: For projects that use Dagger, the IDE provides gutter actions that help you navigate between your Dagger-annotated code. For example, clicking on the gutter action next to a method that consumes a given type navigates you to the provider of that type. Conversely, clicking on the gutter action navigates you to where a type is used as a dependency.

Find Usages node: When you invoke Find Usages on a provider of a given type, the Find window now includes a Dependency consumer(s) node that lists consumers of that type. Conversely, invoking this action on a consumer of a Dagger-injected dependency, the Find window shows you the provider of that dependency.

Material Design Components: Updated themes and styles in new project templates

Android Studio templates in the Create New Project dialog now use Material Design Components (MDC) and conform to updated guidance for themes and styles by default. Updates include:

MDC: Projects depend on com.google.android.material:material in build.gradle. Base app themes use Theme.MaterialComponents.* parents and override updated MDC color and “on” attributes.

Projects depend on in Base app themes use parents and override updated MDC color and “on” attributes. Color resources: Color resources in colors.xml use literal names (for example, purple_500 instead of colorPrimary ).

Color resources in use literal names (for example, instead of ). Theme resources: Theme resources are in themes.xml (instead of styles.xml ) and use Theme. names.

Theme resources are in (instead of ) and use names. Dark theme: Base application themes use DayNight parents and are split between res/values and res/values-night .

Base application themes use parents and are split between and . Theme attributes: Color resources are referenced as theme attributes (for example, ?attr/colorPrimary ) in layouts and styles to avoid hard-coded colors.

IntelliJ IDEA 2020.1

The core Android Studio IDE has been updated with improvements from IntelliJ IDEA through the 2020.1 release, including a new Commit window that enables version control operations and a new Zen mode that can be toggled by selecting View > Appearance > Enter Distraction Free Mode.

To learn more about the improvements in version 2020.1, see the following page:

IDE configuration directory changes

The locations of user configuration directories have been changed to the following:

Windows

Syntax: %APPDATA%\Google\

Example: C:\Users\YourUserName\AppData\Roaming\Google\AndroidStudio4.1

macOS

Syntax: ~/Library/Application Support/Google/

Example: ~/Library/Application Support/Google/AndroidStudio4.1

Linux

Syntax: ~/.config/Google/

Example: ~/.config/Google/AndroidStudio4.1

These new directory locations are consistent with recent updates to IntelliJ IDEA, the IDE on which Android Studio is based.

Note: If Studio doesn’t restart after an upgrade, you may need to delete the configuration directory from a previous Studio version. See the known issues page for more information.

Kotlin 1.3.72

Android Studio 4.1 bundles Kotlin 1.3.72, which includes a number of fixes to improve Kotlin highlighting, inspections, and code completion. Check out the 1.3.72 Kotlin changelog for details.

Custom view preview

When creating a custom view (for example, by extending the View or Button class), Android Studio now shows you a preview of your custom view. Use the dropdown menu in the toolbar to switch between multiple custom views, or click the buttons to wrap vertically or horizontally to the content.

Note: If you don’t see your changes in the preview, select Build > Make Project from the menu bar.

Symbolication for native crash reports

When a crash or ANR occurs in native code, the system produces a stack trace, which is a snapshot of the sequence of nested functions called in your program up to the moment it crashed. These snapshots can help you to identify and fix any problems in the source, but they must first be symbolicated to translate the machine addresses back into human-readable function names.

If your app or game is developed using native code, like C++, you can now upload debug symbols files to the Play Console for each version of your app. The Play Console uses these debug symbols files to symbolicate your app’s stack traces, making it easier to analyze crashes and ANRs. To learn how to upload debug symbols files, see Native crash support.

Apply Changes

To help you be more productive as you iterate on your app, we’ve made the following enhancements to Apply Changes for devices running Android 11 Developer Preview 3 or higher:

Faster deploy speeds

We’ve invested heavily in optimizing your iteration speed by developing a method to deploy and persist changes on a device without installing the application. After an initial deploy, subsequent deploys to Android 11 devices using either Apply Code Changes or Apply Changes and Restart Activity are now significantly faster.

To learn more about the difference between these two actions, see Apply Changes.

Support for additional code changes

For devices running Android 11 Developer Preview 3 or higher, you can now add methods and then deploy those changes to your running app by clicking either Apply Code Changes or Apply Changes and Restart Activity .

4.0 (May 2020)

Android Studio 4.0 is a major release that includes a variety of new features and improvements.

Android Gradle plugin 4.0.0

The latest version of the Android Gradle plugin includes many updates, such as Java 8 desugaring for older versions of Android and feature-on-feature dependencies. To learn more, read the full Android Gradle plugin release notes.

Additionally, Android Studio now includes new features to help you improve your build performance.

Build Analyzer

When using Android Studio 4.0 with Android Gradle plugin 4.0.0 and higher, the Build Analyzer window helps you understand and diagnose issues with your build process, such as disabled optimizations and improperly configured tasks. To open the Build Analyzer window, proceed as follows:

If you haven’t already done so, build your app by selecting Build > Make Project from the menu bar. Select View > Tool Windows > Build from the menu bar. In the Build window, open the Build Analyzer window in one of the following ways: After Android Studio finishes building your project, click the Build Analyzer tab.

tab. After Android Studio finishes building your project, click the link in the right side of the Build Output window.

The Build Analyzer window organizes possible build issues in a tree on the left. You can inspect and click on each issue to investigate its details in the panel on the right. When Android Studio analyzes your build, it computes the set of tasks that determined the build’s duration and provides a visualization to help you understand the impact of each of these tasks. You can also get details on warnings by expanding the Warnings node.

Inspecting the tasks that determined the build’s duration.

Java 8 library desugaring in D8 and R8

Android Studio now includes support for using a number of Java 8 language APIs without requiring a minimum API level for your app.

Through a process called desugaring, the DEX compiler, D8, in Android Studio 3.0 and higher already provided substantial support for Java 8 language features (such as lambda expressions, default interface methods, try with resources, and more). In Android Studio 4.0, the desugaring engine has been extended to be able to desugar Java language APIs. This means that you can now include standard language APIs that were available only in recent Android releases (such as java.util.streams ) in apps that support older versions of Android.

The following set of APIs is supported in this release:

Sequential streams ( java.util.stream )

) A subset of java.time

java.util.function

Recent additions to java.util.{Map,Collection,Comparator}

Optionals ( java.util.Optional , java.util.OptionalInt and java.util.OptionalDouble ) and some other new classes useful with the above APIs

, and ) and some other new classes useful with the above APIs Some additions to java.util.concurrent.atomic (new methods on AtomicInteger , AtomicLong and AtomicReference )

(new methods on , and ) ConcurrentHashMap (with bug fixes for Android 5.0)

To support these language APIs, D8 compiles a separate library DEX file that contains an implementation of the missing APIs and includes it in your app. The desugaring process rewrites your app’s code to instead use this library at runtime.

To enable support for these language APIs, include the following in your app module’s build.gradle file:

Groovy android { defaultConfig { // Required when setting minSdkVersion to 20 or lower multiDexEnabled true } compileOptions { // Flag to enable support for the new language APIs coreLibraryDesugaringEnabled true // Sets Java compatibility to Java 8 sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } } dependencies { coreLibraryDesugaring ‘com.android.tools:desugar_jdk_libs:1.0.4’ } Kotlin android { defaultConfig { // Required when setting minSdkVersion to 20 or lower multiDexEnabled = true } compileOptions { // Flag to enable support for the new language APIs coreLibraryDesugaringEnabled = true // Sets Java compatibility to Java 8 sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 } } dependencies { coreLibraryDesugaring(“com.android.tools:desugar_jdk_libs:1.0.4”) }

Note that you may also need to include the above code snippet in a library module’s build.gradle file if:

The library module’s instrumented tests use these language APIs (either directly or through the library module or its dependencies). This is so that the missing APIs are provided for your instrumented test APK.

You want to run lint on the library module in isolation. This is to help lint recognize valid usages of the language APIs and avoid reporting false warnings.

Feature-on-feature dependencies

In previous versions of the Android Gradle plugin, all feature modules could depend only on the app’s base module. When using Android Gradle plugin 4.0.0 and higher, you can now include a feature module that depends on another feature module. That is, a :video feature can depend on the :camera feature, which depends on the base module, as shown in the figure below.

Feature module :video depends on feature :camera , which depends on the base :app module.

This means that when your app requests to download a feature module, the app also downloads other feature modules it depends on. After you create feature modules for your app, you can declare a feature-on-feature dependency in the module’s build.gradle file. For example, the :video module declares a dependency on :camera as follows:

Groovy // In the build.gradle file of the ‘:video’ module. dependencies { // All feature modules must declare a dependency // on the base module. implementation project(‘:app’) // Declares that this module also depends on the ‘camera’ feature module. implementation project(‘:camera’) … } Kotlin // In the build.gradle file of the ‘:video’ module. dependencies { // All feature modules must declare a dependency // on the base module. implementation(project(“:app”)) // Declares that this module also depends on the ‘camera’ feature module. implementation(project(“:camera”)) … }

Additionally, you should enable the feature-on-feature dependency feature in Android Studio (to support the feature when editing the Run configuration, for example) by clicking Help > Edit Custom VM Options from the menu bar and including the following:

-Drundebug.feature.on.feature=true

Dependencies metadata

When building your app using Android Gradle plugin 4.0.0 and higher, the plugin includes metadata that describes the dependencies that are compiled into your app. When uploading your app, the Play Console inspects this metadata to provide you with the following benefits:

Get alerts for known issues with SDKs and dependencies your app uses

Receive actionable feedback to resolve those issues

The data is compressed, encrypted by a Google Play signing key, and stored in the signing block of your release app. However, you can inspect the metadata yourself in the local intermediate build files in the following directory: //build/outputs/sdk-dependencies/release/sdkDependency.txt .

If you’d rather not share this information, you can opt-out by including the following in your module’s build.gradle file:

Groovy android { dependenciesInfo { // Disables dependency metadata when building APKs. includeInApk = false // Disables dependency metadata when building Android App Bundles. includeInBundle = false } } Kotlin android { dependenciesInfo { // Disables dependency metadata when building APKs. includeInApk = false // Disables dependency metadata when building Android App Bundles. includeInBundle = false } }

Support for Kotlin DSL script files

The Android Gradle plugin now supports Kotlin DSL build script files ( *.kts ). When used with Android Studio, certain IDE features, such as the Project Structure dialog and build script quick fixes, now also support reading and writing to Kotlin build script files.

CPU Profiler upgrades

Based on your feedback, we’ve focused our efforts on improving the user experience in the CPU Profiler in two important ways.

First, compared to previous Android Studio releases, error rates for CPU recordings in the CPU Profiler have been reduced significantly.

Second, the CPU Profiler UI has been overhauled to provide a more intuitive workflow. Some notable UI changes include the following:

CPU recordings are now separated from the main profiler timeline to allow for easier analysis. Recorded data are organized in groups on the left side of the Profiler window. You can move groups up and down to reorganize the list by clicking the options iconicon in the top-right corner of the window, or by dragging-and-dropping individual items within a group.

window. You can move groups up and down to reorganize the list by clicking the options iconicon in the top-right corner of the window, or by dragging-and-dropping individual items within a group. For easier side-by-side analysis, you can now view all thread activity in the thread activity timeline (including methods, functions, and events). There are several ways to navigate the timeline: To focus on a specific point in time, drag a range in the CPU usage chart on the top left. To zoom in or out, use the mouse wheel while holding down Control (or Command on MacOS). To pan left or right, drag while holding down the spacebar. Alternatively, use the W and A keys for fine-grained zooming in and out, and the S and D keys for fine-grained panning left and right.

The tabs for Flame Chart , Top Down , and Bottom Up analyses are now in the righthand column. In the Threads group, threads are automatically expanded for System Trace recordings and collapsed by default for other recording types. Double-click (or press Enter) on thread names to expand or collapse them.

, , and analyses are now in the righthand column. In the Threads group, threads are automatically expanded for System Trace recordings and collapsed by default for other recording types. Double-click (or press Enter) on thread names to expand or collapse them. The System Trace UI, as shown in the screenshot, also includes improvements: Events are now uniquely colored for easier differentiation. Threads are sorted by the number of trace events within them so that the “busier” threads are ranked higher in the list. You can select one or more threads to see analysis in the right hand column for those selected threads only. Similarly you can select a trace event within any thread to see analysis data for it.

This version of Android Studio includes updates to the design tools, such as the Layout Inspector and an all-new Motion Editor.

New Motion Editor

Android Studio now includes a visual design editor for the MotionLayout layout type, making it easier to create and preview animations.

The Motion Editor provides a simple interface for manipulating elements from the MotionLayout library that serves as the foundation for animation in Android apps. In previous releases, creating and altering these elements required manually editing constraints in XML resource files. Now, the Motion Editor can generate this XML for you, with support for start and end states, keyframes, transitions, and timelines.

To learn more about how to use the Motion Editor, see the user guide.

Note: Before using the Motion Editor, be sure to set the ConstraintLayout dependency in your build.gradle file to version 2.0.0-beta3 or higher.

Live Layout Inspector

Debug your layout with an updated Live Layout Inspector that provides complete, real-time insights into your app’s UI while it’s deployed to a device.

To open a Layout Inspector window, go to View > Tools Windows > Layout Inspector. Along with many of the same features of the existing Layout Inspector, the Live Layout Inspector also includes:

Dynamic layout hierarchy: Updates as the views on the device change.

Property values resolution stack: Investigate where a resource property value originates in the source code and navigate to its location by following the hyperlinks in the properties pane.

3D view: See your app’s view hierarchy at runtime with advanced 3D visualization. To use this feature, in the Live Layout Inspector window simply click on the Layout and rotate it.

You can use the Live Layout Inspector only when deploying your app to a device or emulator running API level 29 or higher. To enable the Live Layout Inspector, go to File > Settings > Experimental and check the box next to Enable Live Layout Inspector. Then click the checkbox next to Live updates above the Layout Display.

Layout Validation

Layout Validation is a visual tool for simultaneously previewing layouts on different devices and configurations, helping you detect layout errors and create more accessible apps.

You can access this feature by clicking on the Layout Validation tab in the top-right corner of the IDE window:

In the Layout Validation window, you can select from four different configuration sets, including:

Pixel Devices: Preview your app on a selection of Pixel devices.

Preview your app on a selection of Pixel devices. Custom: Preview your app using custom display options such as screen orientation or language.

Preview your app using custom display options such as screen orientation or language. Color Blind: Preview your app using simulations of common types of color blindness.

Preview your app using simulations of common types of color blindness. Font Sizes: Preview your app using a variety of font sizes.

To learn more about using Layout Validation, see Debug Your Layout with Layout Inspector.

Smart editor features for code shrinker rules

Android Studio now provides smart editor features when you open code shrinker rules files for R8, such as syntax highlighting, code completion, and error checking. The editor also integrates with your Android Studio project to provide full symbol completion for all classes, methods, and fields, and includes quick navigation and refactoring.

Kotlin Android live templates

Android Studio now includes Android live templates for your Kotlin classes. For example, you can now type toast and press the Tab key to quickly insert a Toast. For a full list of available live templates, click File > Settings from the menu bar (or Android Studio > Preferences on macOS) and navigate to Editor > Live Templates.

Fragment wizard and new fragment templates

A New Android Fragment wizard and new fragment templates are now available when you navigate to File > New > Fragment > Gallery or click Create new destination in the Navigation editor.

Expanded camera support in Android emulator

When using the Android 11 image, Android Emulator camera includes the following new features:

RAW capture

YUV reprocessing

Level 3 devices

Logical camera support

To learn more about developing for Android 11, see the Android 11 documentation.

clangd now available for C++ code editor

Jetbrains CLion, the technology underpinning Android Studio’s C++ language support, now uses an inspection engine based on LLVM clangd and clang-tidy, speeding up C/C++ code completion and providing a more seamless integration with clang-tidy.

Now available in the Android Studio C++ code editor, clangd and clang-tidy are both part of open-source LLVM extra tooling:

clangd features code completion, compile error messages in the editor, and go-to-definition navigation.

clang-tidy is a C++ linter tool with an extensible framework for diagnosing and fixing typical programming errors.

In prior releases, Android Studio users could use clang-tidy through the NDK; with this change, Android Studio is no longer dependent on the NDK for clang-tidy functionality.

ndk.dir setting in local.properties file is deprecated

The value for ndk.dir should no longer be set in your app’s local.properties file, and support for this ndk.dir setting will be removed in a future version. The Android Gradle Plugin sets the NDK version by default, but if you need a specific version of the NDK, you can set android.ndkVersion in build.gradle .

For more information on setting up the NDK, see Install and configure the NDK and CMake.

IntelliJ IDEA 2019.3.3

The core Android Studio IDE has been updated with improvements from IntelliJ IDEA through the 2019.3.3 release.

To learn more about the improvements from other IntelliJ versions that are included cumulatively with version 2019.3.3, see the following pages:

3.6 (February 2020)

Android Studio 3.6 is a major release that includes a variety of new features and improvements.

We’d also like to thank all of our community contributors who have helped with this release.

This version of Android Studio includes updates to several design tools, including the Layout Editor and Resource Manager.

Split view and zoom in design editors

The following updates to the visual design editors are included in this release:

Design editors, such as the Layout Editor and Navigation Editor, now provide a Split view that enables you to see both the Design and Code views of your UI at the same time. In the top-right corner of the editor window, there are now three buttons for toggling between viewing options: To enable split view, click the Split icon . To enable XML source view, click the Source icon . To enable design view, click the Design icon .

The controls for zooming and panning within design editors have moved to a floating panel in the bottom-right corner of the editor window.

To learn more, see Build a UI with Layout Editor.

Color Picker Resource Tab

To help you quickly update color resource values in your app when you’re using the color picker in your XML or the design tools, the IDE now populates color resource values for you.

Resource Manager

The Resource Manager contains the following updates:

The Resource Manager now supports most resource types.

When searching for a resource, the Resource Manager now displays results from all project modules. Previously, searches returned results only from the selected module.

The filter button lets you view resources from local dependent modules, external libraries, and the Android framework. You can also use the filter to show theme attributes.

You can now rename resources during the import process by clicking within the textbox above the resource.

To learn more, see Manage your app’s UI resources with Resource Manager.

Updates to the Android Gradle plugin

The latest version of the Android Gradle plugin includes many updates, including optimizations for build speed, support for the Maven publishing plugin, and support for View Binding. To learn more, read the full release notes.

View binding

View binding allows you to more easily write code that interacts with views by generating a binding class for each XML layout file. These classes contain direct references to all views that have an ID in the corresponding layout.

Because it replaces findViewById() , view binding eliminates the risk of null pointer exceptions resulting from an invalid view ID.

To enable view binding, you need to use Android Gradle plugin 3.6.0 or higher and include the following in each module’s build.gradle file:

Groovy android { buildFeatures.viewBinding = true } Kotlin android { buildFeatures.viewBinding = true }

Apply Changes

You can now add a class and then deploy that code change to your running app by clicking either Apply Code Changes or Apply Changes and Restart Activity .

To learn more about the difference between these two actions, see Apply Changes.

Refactor menu option to enable Instant Apps support

You can now instant-enable your base module at any time after creating your app project as follows:

Open the Project panel by selecting View > Tool Windows > Project from the menu bar. Right-click on your base module, typically named ‘app’, and select Refactor > Enable Instant Apps Support. In the dialog that appears, select your base module from the dropdown menu. Click OK.

Note: The option to instant-enable your base app module from the Create New Project wizard has been removed.

To learn more, read Overview of Google Play Instant.

Deobfuscate class and method bytecode in APK Analyzer

When using the APK Analyzer to inspect DEX files, you can deobfuscate class and method bytecode as follows:

Select Build > Analyze APK from the menu bar. In the dialog that appears, navigate to the APK you want to inspect and select it. Click Open. In the APK Analyzer, select the DEX file you want to inspect. In the DEX file viewer, load the ProGuard mappings file for the APK you’re analyzing. Right-click on the class or method you want to inspect and select Show bytecode.

Native tooling

The following updates support native (C/C++) development in Android Studio.

Kotlin support

The following NDK features in Android Studio, previously supported in Java, are now also supported in Kotlin:

Navigate from a JNI declaration to the corresponding implementation function in C/C++. View this mapping by hovering over the C or C++ item marker near the line number in the managed source code file.

Automatically create a stub implementation function for a JNI declaration. Define the JNI declaration first and then type “jni” or the method name in the C/C++ file to activate.

Unused native implementation functions are highlighted as a warning in the source code. JNI declarations with missing implementations are also highlighted as an error.

When you rename (refactor) a native implementation function, all corresponding JNI declarations are updated. Rename a JNI declaration to update the native implementation function.

Signature checking for implicitly-bound JNI implementations.

Other JNI improvements

The code editor in Android Studio now supports a more seamless JNI development workflow, including improved type hints, auto-completion, inspections, and code refactoring.

APK reloading for native libraries

You no longer need to create a new project when the APK in your project is updated outside the IDE. Android Studio detects changes in the APK and gives you the option to re-import it.

Attach Kotlin-only APK sources

It is now possible to attach Kotlin-only external APK sources when you profile and debug pre-built APKs. To learn more, see Attach Kotlin/Java sources.

Leak detection in Memory Profiler

When analyzing a heap dump in the Memory Profiler, you can now filter profiling data that Android Studio thinks might indicate memory leaks for Activity and Fragment instances in your app.

The types of data that the filter shows include the following:

Activity instances that have been destroyed but are still being referenced.

instances that have been destroyed but are still being referenced. Fragment instances that do not have a valid FragmentManager but are still being referenced.

In certain situations, such as the following, the filter might yield false positives:

A Fragment is created but has not yet been used.

is created but has not yet been used. A Fragment is being cached but not as part of a FragmentTransaction .

To use this feature, first capture a heap dump or import a heap dump file into Android Studio. To display the fragments and activities that may be leaking memory, select the Activity/Fragment Leaks checkbox in the heap dump pane of the Memory Profiler.

Filtering a heap dump for memory leaks.

Emulators

Android Studio 3.6 helps you take advantage of several updates included in Android Emulator 29.2.7 and higher, as described below.

Improved Location Support

Android Emulator 29.2.7 and higher provides additional support for emulating GPS coordinates and route information. When you open the Emulators Extended controls, options in the Location tab are now organized under two tabs: Single points and Routes.

Single points

In the Single points tab, you can use the Google Maps webview to search for points of interest, just as you would when using Google Maps on a phone or browser. When you search for or click on a location in the map, you can save the location by selecting Save point near the bottom of the map. All of your saved locations are listed on the right side of the Extended controls window.

To set the Emulators location to the location you have selected on the map, click the Set location button near the bottom right of the Extended controls window.

.

Routes

Similar to the Single points tab, the Routes tab provides a Google Maps webview that you can use to create a route between two or more locations. To create and save a route, do the following:

In the map view, use the text field to search for the first destination in your route. Select the location from the search results. Select the Navigate button. Select the starting point of your route from the map. (Optional) Click Add destination to add additional stops to your route. Save your route by clicking Save route in the map view. Specify a name for the route and click Save.

To simulate the Emulator following the route you saved, select the route from the list of Saved routes and click Play route near the bottom right of the Extended controls window. To stop the simulation, click Stop route.

.

To continuously simulate the Emulator following the specified route, enable the switch next to Repeat playback. To change how quickly the Emulator follows the specified route, select an option from the Playback speed dropdown.

Multi-display support

The Android Emulator now allows you to deploy your app to multiple displays, which support customizable dimensions and can help you test apps that support multi-window and multi-display. While a virtual device is running, you can add up to two additional displays as follows:

Open the Extended controls and navigate to the Displays tab. Add another display by clicking Add secondary display. From the dropdown menu under Secondary displays, do one of the following: Select one of the preset aspect ratios Select custom and set the height, width, and dpi for your custom display. (Optional) Click Add secondary display to add a third display. Click Apply changes to add the specified display(s) to the running virtual device.

New virtual devices and project templates for Android Automotive OS

When you create a new project using Android Studio, you can now select from three templates from the Automotive tab in the Create New Project wizard: No Activity, Media service, and Messaging service. For existing projects, you can add support for Android Automotive devices by selecting File > New > New Module from the menu bar, and selecting Automotive Module. The Create New Module wizard then guides you through creating a new module using one of the Android Automotive project templates.

.

Additionally, you can now create an Android Virtual Device (AVD) for Android Automotive OS devices by selecting one of the following options in the Automotive tab in the Virtual Device Configuration wizard.

Polestar 2: Create an AVD that emulates the Polestar 2 head unit. Automotive (1024p landscape): Create an AVD for generic 1024 x 768 px Android Automotive head units.

.

Resumable SDK downloads

When downloading SDK components and tools using the SDK Manager, Android Studio now allows you to resume downloads that were interrupted (for example, due to a network issue) instead of restarting the download from the beginning. This enhancement is especially helpful for large downloads, such as the Android Emulator or system images, when internet connectivity is unreliable.

In addition, if you have an SDK download task running in the background, you can now pause or resume the download using the controls in the status bar.

A background download task in the status bar with new controls that let you pause or resume the download.

Win32 deprecated

The Windows 32-bit version of Android Studio will no longer receive updates after December 2019, and it will no longer receive support after December 2020. You can continue to use Android Studio. However, to receive additional updates, upgrade your workstation to a 64-bit version of Windows.

To learn more, read the Windows 32-bit depreciation blog.

New option for optimizing Gradle sync time

In previous releases, Android Studio retrieved the list of all Gradle tasks during Gradle Sync. For large projects, retrieving the task list could cause slow sync times.

To improve Gradle Sync performance, go to File > Settings > Experimental and select Do not build Gradle task list during Gradle sync.

When you enable this option, Android Studio skips building the task list during sync, which allows Gradle Sync to complete faster and improves UI responsiveness. Keep in mind, when the IDE skips building the task list, the task lists in the Gradle panel are empty, and task name auto-completion in build files does not work.

New location to toggle Gradle’s offline mode

To enable or disable Gradle’s offline mode, first select View > Tool Windows > Gradle from the menu bar. Then, near the top of the Gradle window, click Toggle Offline Mode .

IntelliJ IDEA 2019.2

The core Android Studio IDE has been updated with improvements from IntelliJ IDEA through the 2019.2 release.

To learn more about the improvements from other IntelliJ versions that are included cumulatively with version 2019.2, see the following pages:

Community contributors

Thank you to all of our community contributors who have helped us discover bugs and other ways to improve Android Studio 3.6. In particular, we’d like to thank the following people who reported bugs:

3.5 (August 2019)

Android Studio 3.5 is a major release and a result of Project Marble. Beginning with the release of Android Studio 3.3, the Project Marble initiative has spanned multiple releases that focus on improving three main areas of the IDE: system health, feature polish, and fixing bugs.

For information about these and other Project Marble updates, read the Android Developers blog post or the sections below.

We also want to thank all of our community contributors who have helped with this release.

Project Marble: System health

This section describes the changes in Android Studio 3.5 that are focused on improving system health.

Recommended memory settings

Android Studio now notifies you if it detects that you could improve performance by increasing the maximum amount of RAM that your OS should allocate for Android Studio processes, such as the core IDE, Gradle daemon, and Kotlin daemon. You can either accept the recommended settings by clicking the action link in the notification, or you can adjust these settings manually by selecting File > Settings (or Android Studio > Preferences on macOS), and then finding the Memory Settings section under Appearance & Behavior > System Settings. To learn more, see Maximum heap size.

A notification about recommended memory settings.

Memory usage report

Memory problems in Android Studio are sometimes difficult to reproduce and report. To help solve this problem, Android Studio lets you generate a memory usage report by clicking Help > Analyze Memory Usage from the menu bar. When you do so, the IDE locally sanitizes the data for personal information before asking whether you want to send it to the Android Studio team to help identify the source of the memory issues. To learn more, see Run a memory usage report.

A memory usage report.

Windows: Antivirus file I/O optimization

Android Studio now automatically checks whether certain project directories are excluded from real-time antivirus scanning. When adjustments can be made to improve build performance, Android Studio notifies you and provides instructions on how to optimize your antivirus configuration. To learn more, see Minimize the impact of antivirus software on build speed.

Project Marble: Feature polish

This section describes the changes in Android Studio 3.5 that are focused on improving existing features.

Apply Changes

Apply Changes lets you push code and resource changes to your running app without restarting your app—and, in some cases, without restarting the current activity. Apply Changes implements a completely new approach for preserving your app’s state. Unlike Instant Run, which rewrote the bytecode of your APK, Apply Changes redefines classes on the fly by leveraging the runtime instrumentation supported in Android 8.0 (API level 26) or higher.

To learn more, see Apply Changes.

The toolbar buttons for Apply Changes.

App deployment flow

The IDE has a new drop-down menu that lets you quickly select which device you’d like to deploy your app to. This menu also includes a new option that lets you run your app on multiple devices at once.

Target device drop-down menu.

Improved Gradle sync and cache detection

The IDE now better detects when Gradle periodically clears your build cache when reducing its hard disk consumption. In previous versions, this state caused the IDE to report missing dependencies and Gradle sync to fail. Now, the IDE simply downloads dependencies as needed to ensure that Gradle sync completes successfully.

Improved build error output

The Build window now provides better error reporting, such as a link to the file and line of the reported error, for the following build processes:

AAPT compilation and linking

R8 and ProGuard

Dexing

Resource merging

XML file parsing

Javac, Kotlinc, and CMake compilation

Project Upgrades

Improved update experience to provide more information and actions to help you update the IDE and the Android Gradle plugin. For example, more sync and build errors include actions to help you mitigate errors when updating.

It’s important to keep in mind, you can update the IDE independently of other components, such as the Android Gradle plugin. So, you can safely update the IDE as soon as a newer version is available, and update other components later.

Layout Editor

Android Studio 3.5 includes several improvements to layout visualization, management, and interaction.

When working with ConstraintLayout , a new Constraints section in the Attributes panel lists the constraints relationships of the selected UI component. You can select a constraint either from the design surface or from the constraints list to highlight the constraint in both areas.

Constraint relationships for a selected UI element.

Similarly, you can now delete a constraint by selecting it and pressing the Delete key. You can also delete a constraint by holding the Control key ( Command on macOS) and clicking on the constraint anchor. Note that when you hold the Control or Command key and hover over an anchor, any associated constraints turn red to indicate that you can click to delete them.

When a view is selected, you can create a constraint by clicking on any of the + icons in the Constraint Widget section of the Attributes panel, as shown in the following image. When you create a new constraint, the Layout Editor now selects and highlights the constraint, providing immediate visual feedback for what you’ve just added.

Using the constraint widget to create constraints .

When creating a constraint, the Layout Editor now shows only the eligible anchor points to which you can constrain. Previously, the Layout Editor highlighted all anchor points on all views, regardless of whether you could constrain to them. In addition, a blue overlay now highlights the target of the constraint. This highlighting is particularly useful when attempting to constrain to a component that overlaps with another.

Creating a constraint for an overlapping component in Android Studio 3.4.

Creating a constraint for an overlapping component in Android Studio 3.5.

In addition to the above updates, Android Studio 3.5 also contains the following Layout Editor improvements:

The Constraint Widget and default margin drop-down now allow you to use dimension resources for margins.

and default margin drop-down now allow you to use dimension resources for margins. In the Layout Editor toolbar, the list of devices that determine the size of the design surface has been updated. In addition, snapping behavior while resizing has been improved, and the resizing handles on the design surface are now always visible. When resizing, new overlays appear that show common device sizes.

The Layout Editor has a new color scheme that improves consistency and reduces contrast between components, text, and constraints.

Blueprint mode now includes text support for some components where text wasn’t being shown.

For more information about these changes, see Android Studio Project Marble: Layout Editor.

Data Binding

In addition to adding incremental annotation processing support for Data Binding, the IDE improves smart editor features and performance when creating data binding expressions in XML.

Code editor performance on Android Studio 3.4.

Improved code editing performance on Android Studio 3.5.

Improved support for C/C++ projects

And

Android Studio Dolphin

Android Studio is the official IDE for Android development, and includes everything you need to build Android apps.

This page lists new features and improvements in the latest version in the stable channel, Android Studio Dolphin. You can download it here or update to it inside Android Studio by clicking Help > Check for updates (Android Studio > Check for updates on macOS)

To view the release notes for older versions of Android Studio, see Past releases.

For early access to upcoming features and improvements, see the Preview builds of Android Studio.

If you encounter problems in Android Studio, check the Known issues or Troubleshoot page.

The following are new features in Android Studio Dolphin.

New in Compose

The following are new features and improvements to Jetpack Compose in Android Studio.

Compose Animation Coordination

If your animations are described in a composable preview, you can now use Animation Preview to inspect and coordinate all of them at once. You can also freeze a specific animation.

Compose Multipreview Annotations

You can now define an annotation class that includes multiple Preview definitions and use that new annotation to generate those previews at once. Use this new annotation to preview multiple devices, fonts, and themes at the same time—without repeating those definitions for every single composable.

Compose Recomposition Counts in Layout Inspector

When debugging your Compose layouts, knowing when composables do or do not recompose is important in understanding whether your UI is implemented properly. For example, if it’s recomposing too many times, your app might be doing more work than is necessary. On the other hand, components that do not recompose when you expect them to can lead to unexpected behaviors.

The Layout Inspector now allows you to see when discrete composables in your layout hierarchy have either recomposed or skipped. This information is shown live, while you interact with your app. To get started, make sure your app is using Compose 1.2.0-alpha03 or higher. Then deploy your app as you normally would.

Open the Layout Inspector window and connect to your app process. In the Component Tree, you should see two new columns appear next to the layout hierarchy. The first column show the number of compositions for each node. The second columns displays the number of skips for each node. You can also see similar information in the Attributes pane when you select a composable from the Component Tree or the Layout Display.

If you want to reset the count, click Reset near the top of the Component Tree panel. Resetting the count can help you understand recompositions or skips during a specific interaction with your app.

Note: Component Tree panel, you can enable or disable them by selecting Show Recomposition Counts from the View Options menu near the top of the Component Tree, as shown in the following image. If you don’t see the new columns in thepanel, you can enable or disable them by selectingfrom themenunear the top of the, as shown in the following image.

Updated Wear OS emulator pairing assistant

Starting with Android Studio Dolphin Canary 3, the Wear OS emulator pairing assistant has improved features that make it easier to manage and connect Wear emulators. You can now do the following:

See Wear devices in the Device Manager .

. Pair multiple Wear devices with a single virtual or physical phone.

Automatically reconnect previously paired devices when they’re launched. Android Studio now remembers and re-pairs the last pair set up.

To use these new features, make sure your phone emulators are API level 30 or higher and have the Google Play Store installed. Also, make sure your Wear emulators are API level 28 or higher. To upgrade to the latest system images for your emulated devices, go to Tools > SDK Manager.

For more information, see Use the Wear OS emulator pairing assistant.

Updated Wear OS emulator toolbar

Starting with Android Studio Dolphin Canary 2, for Wear emulators with API level 28 or higher, the emulator toolbar now has buttons that simulate the physical buttons and common actions on the device. The new buttons are: Button 1 and Button 2 (Button 2 is only available on API level 30 or higher), the Palm button, and the Tilt button. Here are some of the actions you can do using the new buttons on your Wear emulator:

To set your device to ambient mode, click the Palm button.

To return your device to the last screen it was on before ambient mode, click the Tilt button.

For more information, see Perform common actions in the emulator.

New Wear OS run configurations

New run configurations have been added to quickly run and debug surfaces specific to Wear OS like watch faces, Tiles, and complications. You can create these new configurations from the Run/Debug Configurations dialog when running your application.

For more information, see Wear OS run/debug configurations.

New Logcat

Logcat has been updated to make it easier to parse, query, and track logs.

New formatter

Logcat now formats logs to make it easier to scan useful information, such as tags and messages, and identify different types of logs, such as warnings and errors.

Create multiple Logcat windows

You can now create multiple tabs within Logcat, so that you can easily switch between different devices or queries. Right-clicking a tab allows you to rename it, and you can click and drag to rearrange the tabs.

Additionally, to help you more easily compare between two sets of logs, you can now split the view within a tab by right-clicking in the log view and selecting either Split Right or Split Down. To close a split, right-click and select Close. Each split allows you to set its own device connection, view options, and query.

Switch between view presets

Logcat now allows you to quickly switch between different view modes—Standard, Compact, and Custom—by clicking . Each view mode provides a different default setting for showing you more or less information, such as timestamps, tags, and process IDs (PID). You can also customize each of these default view modes, as well as a custom view mode, by selecting Modify View.

New key-value search

In the previous version of Logcat, you had the option to either use string search (with support for regular expressions) or create a new filter by populating various fields using the Logcat UI. The first option made search more complex and the second option made sharing and setting up queries more difficult. We’ve now simplified the experience by introducing key-value searches right from the main query field.

This new query system provides the accuracy of what you want to query, without relying on regular expressions, with the ability to recall past queries from history, and share those queries with others. Additionally, you still have the option to use RegEx and also exclude logs based on key-values. Here are some examples of how to use the new query system, but you can also simply start typing in the query field to see suggestions:

PIDs for the local app project : package:mine

: Specific values : package: tag: level:[VERBOSE | INFO | ASSERT |DEBUG | WARN | ERROR ]

: Exclude a specific value by preceding the key with – : -tag:

by preceding the key with : Use regular expressions with a given key by placing a ~ after the key: tag~: Combine with the exclude tag: -tag~:

with a given key by placing a after the key:

You can also see a history of queries by clicking in the query field and selecting them from the drop down. To favorite a query so that it stays at the top of the list across all your studio projects, click the at the end of the query field..

Track logs across app crashes/restarts

The new Logcat now makes it easier to track logs from your app across app crashes and restarts, so that you don’t miss important logs across these events. When a Logcat notices that your app process has stopped and restarted you’ll see a message in the output—such as PROCESS ENDED and PROCESS STARTED —as shown below:

And, restarting Logcat preserves your session configuration, such as tab splits, filters, and view options, so that you can continue your session easily.

Gradle Managed Devices

In order to improve consistency, performance, and reliability when using Android Virtual Devices for your automated instrumented tests, we’re introducing Gradle Managed Devices. This feature, available for API levels 27 and higher, allows you to configure virtual test devices in your project’s Gradle files. The build system uses the configurations to fully manage—that is, create, deploy, and tear down—those devices when executing your automated tests.

This feature grants Gradle visibility into not only the tests you’re running, but also the lifecycle of the devices, thus improving the quality of your testing experience in the following ways:

Handles device-related issues in order to ensure your tests are executed

Utilizes emulator snapshots to improve device startup time and memory usage, and restore devices to a clean state between tests

Caches test results and reruns only tests that are likely to provide different results

Provides a consistent environment for running your tests between local and remote test runs

Additionally, Gradle Managed Devices introduce a new type of Emulator device, called Automated Test Devices (ATD), that are optimized to improve performance when running your instrumentation tests. Combined with support for test sharding, you can experiment with splitting your test suite across multiple ATD instances in order to reduce overall test execution time. To learn more about Gradle Managed Devices and its associated features, see Scale your tests with Gradle Managed Devices.

R8 support using mapping files based on DEX instruction offsets

When optimizing line information, R8 can now encode the information in shared debug information objects with line tables based on instruction offsets. This substantially reduces the overhead of line information. The effect is that lines in methods are no longer consecutive but might jump at intervals depending on the size of the instructions. Note that some tooling does not consider this shared encoding.

In addition, Android VMs starting from O (API Level 26) support printing instruction offsets in stack traces if the method has no line number information. When compiling with minSdk 26 or higher, and with no source file information, R8 strips the line number information completely.

Stateless lambdas are no longer desugared as singletons

Stateless lambdas are no longer allocated as singletons when desugaring. The representation as singletons adds code size overhead due to the added field and class initializer, as well as startup overhead, due to static class initialization. Stateless lambdas are now allocated at use sites the same way stateful lambdas (lambdas with captures) are.

R8 avoids verification slowdown on Android runtimes

To eliminate performance issues on Android runtimes (Dalvik and ART), R8 (not D8) now introduces library stubs and outline calls to library methods for library classes and methods that might not exist at runtime. Doing so eliminates many verification issues and improves runtime performance. This feature is always enabled.

Support for JDK-11 APIs with Java 8+ API desugaring

When using the coreLibraryDesugaring dependency there is now support for an implementation library based on JDK-11. See the desugar_jdk_libs change log for more information.

Android Gradle plugin and Android Studio compatibility

The Android Studio build system is based on Gradle, and the Android Gradle plugin adds several features that are specific to building Android apps. The following table lists which version of the Android Gradle plugin is required for each version of Android Studio.

If your project is not supported by a specific version of Android Studio, you can still open and update your project using an older version of Android Studio.

Android Studio version Required plugin version Arctic Fox | 2020.3.1 3.1-7.0 Bumblebee | 2021.1.1 3.2-7.1 Chipmunk | 2021.2.1 3.2-7.2 Dolphin | 2021.3.1 3.2-7.3 Electric Eel | 2022.1.1 3.2-7.4 Flamingo | 2022.2.1 3.2-8.0

For information on what’s new in the Android Gradle plugin, see the Android Gradle plugin release notes.

Patch releases

The following is a list of the Patch releases in Android Studio Dolphin.

Android Studio Dolphin | 2021.3.1 Patch 1 (October 2022)

With the Patch 1 release, Android Studio Dolphin now supports the Kotlin plugin 1.7.20. This minor update also includes the following bug fixes:

Lỗi đã đóng của Android Studio 2021.1.1

Android Studio Lỗi #179701680 Kênh alpha không xuất hiện trong rãnh của Android Studio cho các màu của Compose

Trình phân tích bản dựng Lỗi #156912156 Thẻ Sao chép và Dán bị lỗi cho cảnh báo của trình phân tích bản dựng

Bản dựng C++ Lỗi #173689862 Không thể tạo dự án trên cửa sổ do các tệp git chỉ đọc. Lỗi #188860472 Nullpointer trong bản dựng có cmake ( prebuild SFO , tạo libgit2) Lỗi #189966589 GNUMAKE tạo ngoại lệ cho những đối số như “-mllvm -oXXXX” Lỗi #187448826 target_prepre_headers không hoạt động Lỗi #159434435 Android Gradle Plugin 4.0: Đối số CMake bắt đầu từ ‘-C’ không được chuyển đến cmake có thể thực thi, dựng bản dựng hiển thị bị hỏng

Trình chỉnh sửa C++ Lỗi #190648005 Lỗi dấu phân tách dòng khi tự động tạo phương thức JNI

Phân tích mã Lỗi #188859854 Cảnh báo không hợp lệ trong gradle để nâng cấp lên phiên bản alpha của lib thời gian làm việc Lỗi #187443140 Cảnh báo dương tính giả về vấn đề liên quan đến tìm lỗi mã nguồn ShowToast với Snackbar

Chỉnh sửa soạn Lỗi #188681421 LiveLiteral gây ra sự cố trong mô-đun không phải của ứng dụng Compose

Liên kết dữ liệu Lỗi #191494170 Hỗ trợ thẻ

Layout Inspector Lỗi #162526806 Việc sao chép thuộc tính sẽ sao chép tệp đối chiếu vào giá trị đó

Tích hợp tìm lỗi mã nguồn Lỗi #186431684 Cách sử dụng RAM AGP 7.0.0 Alpha 14 Lint không bị ràng buộc Lỗi #190855628 Các vấn đề về tìm lỗi mã nguồn tính năng động không được báo cáo khi checkDependencies=true của ứng dụng và có các mô-đun thư viện

Trình hướng dẫn dự án mới Lỗi #171989189 Cập nhật tệp Gradle đã tạo để dùng trình bổ trợ mới của DSL Lỗi #181415187 Lỗi: các dự án mới vẫn không thể xóa “jcenter” mặc dù sắp bị xóa và cũng không giúp ích những gì nên được thực hiện

Hệ thống dự án Lỗi #37140083 Sự cố API mục tiêu RenderScript trong các công cụ tạo bản dựng Android r25

Tài nguyên Lỗi #183860580 Tài nguyên hợp nhất không thành công trên tài nguyên chuỗi thoát

Chạy thử nghiệm Lỗi #190426050 Bumblebee 2021.1.1 Canary 2 không hiển thị thử nghiệm không thành công nữa

Trình thu hẹp (R8) Lỗi #170709331 Shrinker loại bỏ các mục có thể vẽ vectơ đã qua sử dụng với agp 4.1.0 mới Lỗi #191160291 R8 không xóa chú thích (thời gian biên dịch) (FAILED_BUILD)

Liên kết chế độ xem Lỗi #189498003 Kết nối với ViewBinding bị tắt sau các hành động ngẫu nhiên trong tệp xml của tệp đó

Android Studio 2021 “Bumblebee” now available to download

Android Studio 2021.1 “Bumblebee” has a new Device Manager and improved Apple Silicon support

Android Studio is the main integrated development environment (IDE) for creating Android applications, with a feature-packed code editor, debugging tools, emulators, and much more. The last major release was in March of last year, nicknamed Android Studio Arctic Fox. After a few months in testing, there’s now another upgrade available: Android Studio Bumblebee. Google clearly named it after the small flying insect, but I like the idea of naming it after a Transformer better.

Android Studio Bumblebee, also known as version 2021.1.1, coincides with version 7.1.0 of the Android Gradle plugin (AGP). There’s a brand new Device Manager tool window in Android Studio, replacing the old AVD Manager, which makes it easy to manage physical and emulated devices for testing. Android Studio also now has a simplified process for connecting to ADB devices over Wi-Fi, which uses QR codes for fast pairing, and the emulator tool window introduced in Android Studio 4.1 is now enabled by default.

XDA VIDEO OF THE DAY

Google has also spent some time improving tests in Android Studio for this release. The updated Gradle plugin has a new unified tester, which replaces the two existing testing environments (the one offered by Android Studio, and the one in Gradle) and should reduce headaches for developers. Android Studio’s profilers are also improved, with new CPU profiling features on Android 11+ devices and a few other helpful additions.

There’s also more progress on native support for Apple Silicon processors. Google finally updated the Android SDK Platform Tools package, which includes commonly-used tools like ADB and Fastboot, to work as universal binaries (Silicon+x86_64) on macOS. This will speed up app installations, debugging, and many other workflows on Mac computers with Apple Silicon — such as the MacBook Pro 14 and MacBook Pro 16 (2021) and iMac 24-inch.

You can check out all the improvements in the full blog post and release notes. Android Studio is available to download from the Android Developers website. Now the waiting begins for Android Studio Optimus Prime.

키워드에 대한 정보 android studio bumblebee

다음은 Bing에서 android studio bumblebee 주제에 대한 검색 결과입니다. 필요한 경우 더 읽을 수 있습니다.

이 기사는 인터넷의 다양한 출처에서 편집되었습니다. 이 기사가 유용했기를 바랍니다. 이 기사가 유용하다고 생각되면 공유하십시오. 매우 감사합니다!

사람들이 주제에 대해 자주 검색하는 키워드 What’s new in Android Studio – Bumblebee

  • purpose: Inform
  • pr_pr: Android
  • series: Android Tool Time
  • type: DevByte (deck cleanup 0-10min)
  • GDS: Yes
  • what’s new in android studio bumblebee
  • what’s new in android studio
  • new in android studio
  • bumblebee
  • bumblebee tutorial
  • how to use bumblebee
  • intro to bumblebee
  • developer
  • developers
  • android developer
  • android developers
  • google developers
  • android
  • google
  • Wojtek Kalicińsk

What’s #new #in #Android #Studio #- #Bumblebee


YouTube에서 android studio bumblebee 주제의 다른 동영상 보기

주제에 대한 기사를 시청해 주셔서 감사합니다 What’s new in Android Studio – Bumblebee | android studio bumblebee, 이 기사가 유용하다고 생각되면 공유하십시오, 매우 감사합니다.

See also  Air Quality Korea Seoul | Air Quality In Seoul, South Korea 답을 믿으세요

Leave a Comment