[Android] android studio 2.0即时运行功能探秘
Introduced in Android Studio 2.0, Instant Run is a behavior for the Run
and Debug
commands that significantly reduces the time between updates to your app. Although your first build may take longer to complete, Instant Run pushes subsequent updates to your app without building a new APK, so changes are visible much more quickly.
Instant Run is supported only when you deploy the debug build variant, use Android Plugin for Gradle version 2.0.0 or higher, and set minSdkVersion to 15 or higher in your app's module-level build.gradle file. For the best performance, set minSdkVersion to 21 or higher.
After deploying an app, a small, yellow thunderbolt icon appears within the Run
button (or Debug
button), indicating that Instant Run is ready to push updates the next time you click the button. Instead of building a new APK, it pushes just those new changes and, in some cases, the app doesn't even need to restart but immediately shows the effect of those code changes.
Instant Run pushes updated code and resources to your connected device or emulator by performing a hot swap, warm swap, or cold swap. It automatically determines the type of swap to perform based on the type of change you made. The following table describes how Instant Run behaves when you push certain code changes to a target device.

|
代码的改变类型
|
即时运行的行为
|
|
改变一个已经存在的方法的实现
|
支持热交换,这是最快的类型,可以快速地看到代码变化,你的应用会保持运行,下次你调用到那个更改的方法时,会执行新的代码。
热交换并没有重新实例化你app中的对象,在看到更新前,你可能需要重启当前的activity或者应用。默认情况下,studio会自动重启当前activity。也可以自己设置不自动重启。
|
|
更改或者移除一个存在的资源
|
支持暖交换,这种交换还是很快。即时运行必须重启你当前的activity来完成资源的更新,应用会一直运行,不过重启activity时屏幕可能会闪烁,这是正常情况。
|
| 结构代码的改变,例如: 增加,移除,更改: 1.注释 2.实例域 3.静态域 4静态方法名? 5.实例方法名? 6父类的改变 7继承的接口发生变化 8类的构造方法 9重新布局了使用动态资源ID的空间 |
在api21及以上的版本支持冷交换,该交换会慢一些,因为需要重新启动应用,才能将更改提交到应用中。
在21一下的版本中,studio会构建一个完整的apk
|
|
更改了androidmanifest文件
更改了androidmanifest文件中引用到的资源
更改了android插件的UI元素(需要clean和rerun)
|
修改了manifest文件或其引用的资源时,studio 会自动构建一个新的apk来更新该改变,因为应用在安装到设备上时的一些固定信息是由manifest文件中决定的。 |
[Android] android studio 2.0即时运行功能探秘的更多相关文章
- 告别编译运行 ---- Android Studio 2.0 Preview发布Instant Run功能
以往的Android开发有一个头疼的且拖慢速度的问题,就是你每改一行代码要想看到结果必须要编译运行到手机或者模拟器上,而且需要从头(可能是登录界面)一直点击到你修改的界面为止.开发一个完整的Andro ...
- [Android Pro] 告别编译运行 ---- Android Studio 2.0 Preview发布Instant Run功能
reference to : http://www.cnblogs.com/soaringEveryday/p/4991563.html 以往的Android开发有一个头疼的且拖慢速度的问题,就是你每 ...
- android studio2.0出现的gradle问题,instant Run即时运行不了.
android studio 2.0出现的gradle问题: instant Run即时运行不了.经历了几乎9个preView版本的AS2.0,终于迎来了正式版,然而晴天我的霹雳,好不容易装好的2.0 ...
- Android Studio 3.0 下载 使用新功能介绍
谷歌2017发布会更新了挺多内容的,而且也发布了AndroidStudio3.0预览版,一些功能先睹为快.(英语一般,有些翻译不太好) 下载地址 https://developer.android.g ...
- [Android Pro] Android P版本 新功能介绍和兼容性处理(三)Android Studio 3.0 ~ 3.2 其他特性
cp : https://blog.csdn.net/yi_master/article/details/80067198 1:JAVA8特性支持 1)Base64.java 在升级到as3.0之后, ...
- Android studio 使用flutter插件 运行第一个flutter项目 报错 Warning: License for package Android SDK Build-Tools 28.0.3 not accepted.
在Android studio中新建了flutter项目.运行报错licence not accepted. Warning: License for package Android SDK Buil ...
- Android Studio 2.0 Beta 5公布,修复几个与即时执行相关的严重BUG.
Android Studio 2.0 Beta 5公布,修复几个与即时执行相关的严重BUG. This build fixes a couple of important bugs related t ...
- Android Studio 3.0 新特性
最新Android Studio版本是Android Studio 3.0,本文提供了所有新功能和更改的摘要. 所有这些功能都可以在最新的金丝雀版本中发布,但beta测试版本可能尚未提供. 核心IDE ...
- Android Studio 1.0.2项目实战——从一个APP的开发过程认识Android Studio
Android Studio 1.0.1刚刚发布不久,谷歌紧接着发布了Android Studio 1.0.2版本,和1.0.0一样,是一个Bug修复版本.在上一篇Android Studio 1.0 ...
随机推荐
- Maven提高篇系列之(四)——使用Profile
这是一个Maven提高篇的系列,包含有以下文章: Maven提高篇系列之(一)——多模块 vs 继承 Maven提高篇系列之(二)——配置Plugin到某个Phase(以Selenium集成测试为例) ...
- qt 自动产生 Guid 方法
strcpy(cmd->uid,QUuid::createUuid().toString().toStdString().c_str());
- 自己动手写计算器v1.2
1.2版本主要添加了分数.取负.开方三个功能,由于这三中运算输入单目运算,所以,新声明了一个新类 class OPeratorV1_2 至此基本完成了一个标准计算器,至于拥有更多功能的科学计算器,日后 ...
- 第 1 章 HTML5 概述
学习要点: 1.HTML5 的历史 2.HTML5 的功能 3.HTML5 的特点 4.课程学习问题 主讲教师:李炎恢 HTML5 是继 HTML4.01 和 XHTML1.0 之后的超文本标记语言的 ...
- HDU 5510---Bazinga(指针模拟)
题目链接 http://acm.hdu.edu.cn/search.php?action=listproblem Problem Description Ladies and gentlemen, p ...
- php错误处理-错误处理
错误类型 因为错误类型整型值的巧妙设定,可以采用按位运算符 1 E_ERROR (integer) 致命的运行时错误.这类错误一般是不可恢复的情况,例如内存分配导致的问题. 导致脚本终止不再继续运行 ...
- PHP两个数组相加
在PHP中,当两个数组相加时,会把第二个数组的取值添加到第一个数组上,同时覆盖掉下标相同的值: <?php $a = array("a" => "apple& ...
- nginx和apache的比较
1.nginx的IO是非阻塞的,apache的IO是阻塞的. nginx accept一个连接以后会把它放到EPOLL的消息循环中,APACHE需要启动一个线程,当系统线程达到瓶颈以后,会阻塞网络IO ...
- 当EL遇到char
在EL表达式中,假设某个entity的status属性为char类型,此处假设为'1',在jsp中,对于${entity.status=='1'},我们预期的结果是true,但实际上是false - ...
- 实体类的枚举属性--原来支持枚举类型这么简单,没有EF5.0也可以
通常,我们都是在业务层和界面层使用枚举类型,这能够为我们编程带来便利,但在数据访问层,不使用枚举类型,因为很多数据库都不支持,比如我们现在用的SqlServer2008就不支持枚举类型的列,用的时候也 ...