vvLavida / TechNotes

Issuses for coding summarize.
GNU General Public License v3.0
6 stars 3 forks source link

Android Instant Run #33

Open vvLavida opened 8 years ago

vvLavida commented 8 years ago

Instant Run 官方介绍 Instant Run 功能演示视频 What’s New in Android Studio 2.0

Instant Run功能可以让开发者像写html网页一样写Android原生代码,能做到一边修改代码,一边在模拟器或者实际设备上看到修改代码后的结果。iOS平台有Playground实现类似的功能。

依赖

image 看到运行符号旁边的闪电就可以了。

运行 模拟器打开要修改的目标页面 - 修改目标页面的代码 - Instant Run.

局限 当前Instant Run仅仅适用于布局的修改。即我们可以把一次修改到运行看作一个“周期”,在这个周期里面你仅仅修改了xml布局文件,或者说和逻辑代码不相关的文件,那么你点击运行的时候才会触发Instant Run,否则的话,Android Studio还是依然会重新编译运行。对此,官方文档的说明如下:

Not all code changes are supported by Instant Run currently. Here are some code changes that Instant Run does not currently support:

  • Add/remove/change
  • annotations
  • Add/remove/change
  • an instance field
  • Add/remove/change a static field
  • Add/remove a static method signature
  • Change a static method signature
  • Add/remove an instance method
  • Change an instance method signature
  • Changing which parent class the current class inherits from
  • Change the list of implemented interfaces
  • Changing static initializer of a class

Here is the current list of supported code change scenarios:

screen shot 2016-04-28 at 10 12 05 am

Over the coming months, we plan to expand the Instant Run enable more change types, and continue to make your edit, build, run cycle faster.

vvLavida commented 8 years ago

常见问题及解决方法

  1. 应用build-安装后启动报错:

Unable to instantiate application com.android.tools.fd.runtime.BootstrapApplication

Disable the Instant Run option in Android Studio. Instructions are in the Android Studio Instant Run documentation. Instant Run tries to do hot swapping of your code; this causes the application class to be moved.

vvLavida commented 8 years ago

动态

N Developer Preview users: Instant Run is currently incompatible with the Jack toolchain. This new toolchain is required to use Java 8 language features supported by Android N. To learn more, read about the new Java 8 language features and Jack.