android studio 4 2有什么新功能

Android Studio 4.2带来了CPU Profiler UI改进、新的可移动环境、Gradle 4.2支持、签名格式升级、Compose Jetpack支持等。其中,CPU Profiler存在超时错误,可以通过缩短记录时间解决。新版本还支持多设备并行测试,提供测试结果筛选和排序功能。同时,使用Compose Jetpack可实现UI设计功能。了解更多详情,可参与Android应用程序开发课程。
摘要由CSDN通过智能技术生成

Android overhauled the CPU Profiler UI in Android Studio 4.0, to provide a more intuitive recording workflow. Based on your feedback we continued to make changes and added more features in 4.1. However, Android studio 4.1 has issues that need to be solved,More info visit:android app development course

Android对Android Studio 4.0中的CPU Profiler UI进行了大修,以提供更直观的记录工作流程。 根据您的反馈,我们继续进行更改,并在4.1中添加了更多功能。 但是,Android Studio 4.1存在一些需要解决的问题,更多信息,请访问: Android应用程序开发课程

Android studio 4.1 rundown of known issues

Android Studio 4.1已知问题的概要

This section describes current known issues in an overview of Android Studio 4.1.

本节概述了Android Studio 4.1中的当前已知问题。

  • Patches which do not function in Canary 4.1 10

    在Canary 4.1 10中不起作用的补丁

Patches are currently broken to Android Studio 4.1 Canary 10. To upgrade Android Studio 4.1 to a newer version, shut down Android Studio and then download and install the latest set.

当前已将补丁修补到Android Studio 4.1 Canary10。要将Android Studio 4.1升级到较新版本,请关闭Android Studio,然后下载并安装最新的补丁。

This issue was fixed in Beta 1 of Android Studio 4.1.

此问题已在Android Studio 4.1的Beta 1中修复。

Workaround for missing canary module Kotlin 9

缺少金丝雀模块Kotlin 9的变通办法

You can note the following error in Android Studio 4.1 Canary 9 when you first launch Android Studio after upgrading.

升级后首次启动Android Studio时,您会在Android Studio 4.1 Canary 9中注意到以下错误。

  • Lack of critical org.jetbrains.android plug-in

    缺少关键的org.jetbrains.android插件

This can occur when importing the settings from an earlier version of Android Studio. It typically means you have a Kotlin plugin installed locally, which is not compatible with the new IDE.

从早期版本的Android Studio导入设置时,可能会发生这种情况。 这通常意味着您在本地安装了Kotlin插件,该插件与新的IDE不兼容。

To fix this problem, delete the Kotlin directory from the locations below:

要解决此问题,请从以下位置删除Kotlin目录:

~/.local / share / Google / AndroidStudioPreview4.1 Linux:

〜/ .local / share / Google / AndroidStudioPreview4.1 Linux:

C:\Users\UserName\AppData\Roaming\Google\AndroidStudioPreview4.1 Windows:

C:\ Users \ UserName \ AppData \ Roaming \ Google \ AndroidStudioPreview4.1 Windows:

MacOS: ~/Library / Use / Google / AndroidStudioPreview4.1

MacOS:〜/库/使用/Google/AndroidStudioPreview4.1

Since there is no Kotlin plugin currently available from JetBrains that is compatible with Canary 9, we have bundled our own Kotlin plugin with the Canary 9 update, so you don’t need to install a Kotlin plugin manually.

由于JetBrains当前没有与Canary 9兼容的Kotlin插件,因此我们将自己的Kotlin插件与Canary 9更新捆绑在一起,因此您不需要手动安装Kotlin插件。

  • Errors in CPU Profiler on timeout

    超时时CPU Profiler中的错误

When choosing the Sample Java Methods or Trace Java Methods configurations, you can encounter errors in the Android Studio CPU Profiler “Recording failed to stop” These are often timeout errors, particularly if the following error message appears in the.log file of idea:

在选择示例Java方法或跟踪Java方法配置时,您可能会在Android Studio CPU事件探查器中遇到“记录无法停止”错误,这些错误通常是超时错误,尤其是在idea.log文件中出现以下错误消息时:

  • Hang for Timed ART trace file

    挂起定时ART跟踪文件

Delay errors appear to have more impact on tracked methods than sampled methods and longer records than shorter files. Trying shorter recordings to see if the error disappears can be useful as a quick solution.

与采样方法相比,延迟错误似乎对跟踪方法的影响更大,与较短文件相比,延迟错误的记录更长。 尝试较短的记录以查看错误是否消失可以作为快速解决方案。

If you encounter problems with the Profiler over timeout, please file a report that includes your device(s) make / model and any related entries from idea.log and logcat.

如果在超时期间Profiler遇到问题,请提交报告,其中包括您的设备的品牌/型号以及idea.log和logcat中的所有相关条目。

  • Errors with Git version control in IDE

    IDE中的Git版本控制错误

For Android Studio 4.1 Canary 1 operations involving Git version control authentication are broken in IDE.

对于Android Studio 4.1,涉及Git版本控制身份验证的Canary 1操作在IDE中已中断。

Upgrade to Android Studio 4.1 Canary 2 to address the problem.

升级到Android Studio 4.1 Canary 2即可解决该问题。

In this post, we’ll highlight what’s new for System Trace in Android Studio, one of the infrequently used but effective setups for CPU recording. Device Trace records application operations (e.g. CPU core scheduling) and Android system processes (e.g. SurfaceFlinger) as opposed to the Java Process or C / C++ task traces. Additionally, by calling the Trace API in your app you can trigger your code with custom events. This way, it will collect your custom events along with machine events. When you examine performance problems such as UI jankiness or high power consumption, all of this data combined can come in handy.

在本文中,我们将重点介绍Android Studio中System Trace的新增功能,这是一种不常用但有效的CPU记录设置。 设备跟踪记录了与Java Process或C / C ++任务跟踪相反的应用程序操作(例如,CPU核心调度)和Android系统进程(例如,SurfaceFlinger)。 此外,通过在应用程序中调用Trace API,您可以使用自定义事件触发代码。 这样,它将收集您的自定义事件以及机器事件。 当您检查性能问题(例如UI混乱或高功耗)时,所有这些组合在一起的数据将派上用场。

Android Studio 4.2

Android Studio 4.2

New removable environment for modules with dynamic feature

具有动态功能的模块的新可移动环境

Android Gradle plugin 4.2 uses bundle tool 1.0.0, which implements a dynamic feature module behavior change for apps: any dynamic feature module defined as dist: install-time that is not specifically marked as dist: but removable will be non-removable by default. This new environment optimizes the integration of install-time modules with the base module and theoretically increases the performance of apps for certain applications.

Android Gradle插件4.2使用捆绑工具1.0.0,该工具为应用程序实现了动态功能模块行为更改:任何动态功能模块定义为dist:安装时未明确标记为dist:但默认情况下不可移动。 这个新环境优化了安装时模块与基本模块的集成,并且在理论上提高了某些应用程序的性能。

See the documentation for the dist: removable tag in the Dynamic function module manifest for more detail on this new configuration.

有关此新配置的更多详细信息,请参见动态功能模块清单中dist:可移动标签的文档。

Android update to gradle 4.2

Android更新到Gradle 4.2

In Android Gradle plugin 4.2 a new JVM tool compiler is available now. This tool replaces portions of the AAPT2 resource compiler and, particularly on Windows machines, can potentially boost build performance.

在Android Gradle插件4.2中,现在提供了新的JVM工具编译器。 该工具替代了AAPT2资源编译器的某些部分,尤其是在Windows计算机上,可以潜在地提高构建性能。

Enable it in the gradle.properties file of your project to try out the JVM tool compiler.

在项目的gradle.properties文件中启用它,以试用JVM工具编译器。

Android.enableCompilerJvmResource = true

Android.enableCompilerJvmResource = true

Signing into v3 and v4 now accepted

现在可以登录v3和v4

Android Gradle Plugin 4.2 also supports the signing formats APK v3 and v4. Add the following properties to your build.gradle or build.gradle.kts module-level file to allow one or both of these formats within your build.

Android Gradle Plugin 4.2还支持签名格式APK v3和v4。 将以下属性添加到build.gradle或build.gradle.kts模块级文件中,以允许在构建中使用这两种格式中的一种或两种。

/ Make.gradle.kts

/ Make.gradle.kts

Ios (android)

iOS(安卓)

SigningThe Configures

对配置进行签名

Setup

建立

Enable(true)V3Signing

启用(true)V3Signing

Enable(true)V4Signing

启用(true)V4Signing

}

}

}

}

}

}

Signing APK v4 allows you to quickly deploy large APKs using the installation ADB Incremental APK in Android 11. The new flag is responsible for the signing phase of the APK during the deployment process.

通过对APK v4进行签名,您可以使用Android 11中的安装ADB增量APK快速部署大型APK。新标记负责在部署过程中APK的签名阶段。

Support Compose Jetpack

支持Compose Jetpack

Jetpack Compose toolkit offers a functional approach to designing the UI of your application. The toolkit also includes all the advantages of Kotlin, such as helping you write succinct and idiomatic code which is completely interoperable with Java.

Jetpack Compose工具包提供了一种功能性方法来设计应用程序的UI。 该工具包还包含Kotlin的所有优点,例如帮助您编写与Java完全可互操作的简洁代码。

You will use the new edition of Android Studio 4.2 for the best experience working with Jetpack Compose. That’s because you will benefit from smart editor features including New Project templates and the ability to preview your Compose UI instantly while using Android Studio to build your app with Jetpack Compose.

您将使用新版本的Android Studio 4.2获得与Jetpack Compose一起使用的最佳体验。 这是因为您将受益于智能编辑器功能,包括“新项目”模板以及在使用Android Studio通过Jetpack Compose构建应用程序时即时预览Compose UI的功能。

Current Jetpack Support for tooling compose in 4.2

4.2中最新的Jetpack工具支持

Android Studio also provides additional support for applications that use Jetpack Compose for previewing and checking.

Android Studio还为使用Jetpack Compose进行预览和检查的应用程序提供了其他支持。

Review System

审查系统

For @Preview methods the following parameters are available now.

对于@Preview方法,以下参数现在可用。

  • Show Background:

    显示背景:

Move your preview to and from the context.

在上下文中移动预览。

  • Background Color:

    背景颜色:

Set a color used only on the preview board.

设置仅在预览板上使用的颜色。

  • Ui Mode:

    Ui模式:

This new parameter will take any of the constants of the Configuration. UI * and allows you to change the preview behavior to, for example, set it to Night Mode to see how the theme reacts.

此新参数将采用Configuration的任何常量。 UI *,并允许您更改预览行为,例如将其设置为“夜间模式”以查看主题的React。

You can communicate with components of your UI in this mode, click on them, and see how the state changes. It’s a fast way to get feedback on how your UI responds and the animations are previewed. Only click on the interactive icon to activate it and the preview will switch mode.

您可以在此模式下与UI组件进行通信,单击它们,然后查看状态如何变化。 这是一种获取有关UI响应方式和动画预览的反馈的快速方法。 仅单击交互式图标将其激活,预览将切换模式。

Apply to computer

适用于电脑

To deploy a snippet of your UI to a computer, use this feature. This will help check specific sections of the code within the computer without starting the full program.

要将用户界面的代码段部署到计算机,请使用此功能。 这将有助于在不启动完整程序的情况下检查计算机中代码的特定部分。

Click the deploy to the system icon next to the @Preview annotation or at the top of the preview and Android Studio will deploy the @Preview to the system or emulator connected to you.

单击@Preview批注旁边或预览顶部的部署到系统图标,Android Studio会将@Preview部署到连接到您的系统或模拟器。

View Rest Data sources

查看剩余数据源

The new API for data sources lets you create previews from your results. If you have an existing data set, or a set of themes, this API will allow you to inject it into the @Preview method as a parameter.

使用新的数据源API,您可以根据结果创建预览。 如果您有一个现有的数据集或一组主题,则此API将允许您将其作为参数注入@Preview方法。

class HelloWorldProvider : CollectionPreviewParameterProvider<String>(

类HelloWorldProvider:CollectionPreviewParameterProvider <String>(

@Preview@Composablefun HelloWorldPreview( @PreviewParameter(HelloWorldProvider::class) text: String) { MaterialTheme { Text(text = text) }}

@ Preview @ Composablefun HelloWorldPreview(@PreviewParameter(HelloWorldProvider :: class)text:String){MaterialTheme {Text(text = text)}}

Better Monitoring of instruments

更好地监控仪器

Beginning with Android Studio 4.2 Canary 1, instrumentation testing can now be performed in parallel across several devices and examined using a panel of expert instrumentation test results. With this panel you will assess if tests fail due to the level of the API or hardware properties.

从Android Studio 4.2 Canary 1开始,现在可以跨多个设备并行执行仪器测试,并使用一组专家仪器测试结果进行检查。 通过此面板,您将评估由于API或硬件属性的级别导致测试是否失败。

Panel Test Instrumentation

面板测试仪器

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

确保所有用户在使用您的应用程序时都拥有出色体验的最好方法之一是,检查各种API级别和尺寸形式的应用程序。

You can exploit this feature.

您可以利用此功能。

  • Select Modify Device Set in the dropdown menu of the target system (at the top of the IDE centre).

    在目标系统(位于IDE中心顶部)的下拉菜单中,选择“修改设备集”。
  • Dropdown of target device

    目标设备的下拉菜单
  • Pick the devices you want, and click OK.

    选择所需的设备,然后单击“确定”。
  • Modify the System dialog to load

    修改系统对话框以加载
  • In the dropdown menu of the target computer pick Multiple Devices and run your tests.

    在目标计算机的下拉菜单中,选择“多个设备”并运行测试。
  • From the target device pick Multiple Devices

    从目标设备中选择多个设备
  • To show the results of your check in the Run panel, go to View > Windows Tool > Run.

    要在“运行”面板中显示检查结果,请转到“视图”>“ Windows工具”>“运行”。
Image for post

The new panel of test results allows you to filter the test results by level of status, user, and API. Furthermore, each column can be sorted by clicking the header. You can display the logs and configuration information individually for each device by clicking on a single test.

新的测试结果面板允许您按状态,用户和API的级别过滤测试结果。 此外,可以通过单击标题对每一列进行排序。 您可以通过单击单个测试来分别显示每个设备的日志和配置信息。

Conclusion

结论

I hope you reach a conclusion about new features in Android Studio 4.2. You can learn more through android online training.

我希望您能得出有关Android Studio 4.2中新功能的结论。 您可以通过android在线培训了解更多信息。

翻译自: https://medium.com/@informationit27/what-is-new-in-android-studio-4-2-1dd66e3b6f8d

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值