Android Studio 2.0:为什么修改xml布局资源时Instant Run不起作用? [英] Android Studio 2.0: Why does Instant Run not work when modifying xml layout resources?

查看:43
本文介绍了Android Studio 2.0:为什么修改xml布局资源时Instant Run不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一项非常新的功能,因为 Android Studio 2.0 仅在 Canary 发布渠道中可用,但我希望有人能进一步解释 Instant Run 功能的工作原理.

This is a very new feature, as Android Studio 2.0 is only available in the canary release channel, however I was hoping someone could further explain how the Instant Run feature works.

如果我修改 Java 类(活动、片段等)中的代码,则 Instant Run 可以顺利运行.它使应用程序的实例保持运行并在幕后换出代码,大大缩短了我的测试时间(顺便说一句,这很棒).

If I modify code within my Java classes (Activities, Fragments, etc.) then Instant Run works smoothly. It keeps the instance of the app running and swaps out code behind the scenes, greatly improving the time it takes for me to test (which is awesome, btw).

但是,如果我修改现有布局 xml 资源,那么它必须重新编译并部署它.所以我的问题是:

However, if I modify existing layout xml resources, then it has to recompile a build and deploy it. So my questions are:

  1. 为什么修改现有布局xml资源需要rebuild?
  2. 未来是否有计划允许热交换 XML 资源,这样我就不必每次看到布局更改时都重新构建?(尽管我知道我只能在设计"视图中查看更改).

问题 1 目前对我来说更重要,因为我想了解这一切是如何运作的.另外,祝贺 Android Studio 团队.IDE 已经取得了长足的进步.性能改进改变了生活.

Question #1 is more important to me at the moment, because I'd like to understand how it all works. Also, congratulations to the Android Studio team. The IDE has come a long way. The performance improvements are life-changing.

推荐答案

如您所知,xml 文件中使用的所有资源都转换为 R 类中的静态字段.根据从 http://tools.android.com/tech-docs/instant-run Instant Run 不支持更改静态字段.

As you know all the resources used in your xml file are converted into static fields in R class. As per the information got from http://tools.android.com/tech-docs/instant-run changing static fields are not supported by instant Run.

这篇关于Android Studio 2.0:为什么修改xml布局资源时Instant Run不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆