[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 ...
随机推荐
- javascript事件分类解析
最近在学习javascript,就顺便把常用事件给大家整理整理,也让自己加深印象.不足之处欢迎各位补充. 一般事件 onclick 鼠标点击时触发此事件 ondblclick 鼠标双击时触发此事件 ...
- 载入条LoadingBar
这个控件太傻瓜了,只搁在博客里算了.日前需要用到一个载入条, 但不想找GIF图片,.NET里面没有提供这个控件,只有ProgressBar.自己写吧!要写也不难,就是周期性绘制一个长方形,让那个长方形 ...
- [DBW]一个小巧的Class方案
(function(){ function Extend(func,proto){ func.prototype.__proto__=proto.prototype; Object.definePro ...
- echarts 折线图动态x轴及数据
<!DOCTYPE html><html lang="en"><head> <meta charset="utf-8" ...
- Oracle--(Hierarchical Queries)层级查询
内容来自: Oracle® Database SQL Language Reference 11g Release 2 (11.2) E41084-03. empolyees表来自hr方案,wareh ...
- Malformed \uxxxx encoding解决方法
java.lang.IllegalArgumentException: Malformed \uxxxx encoding. at java.util.Properties.loadConvert(U ...
- [调整] Firemonkey TEdit 避免按下立即弹出键盘的问题
目前 Firemonkey 有一个问题,就是在 Edit 按下会立即弹出键盘,在红鱼儿的博客也提交了 QC: http://blog.sina.com.cn/s/blog_44fa172f0102vy ...
- 点我吧工作总结(技术篇) zookeeper
我思故我在,提问启迪思考! 1.什么是zookeeper? 2.zookeeper与dubbo.springMVC之间的协同工作? http://doc.okbase.net/congcong68/a ...
- Java基础复习笔记系列 二
1.Java中Static的相关用法总结?(静态方法:静态变量:静态代码块) public static void main(String args[])执行的关键,在于有static.有了stati ...
- [moka同学笔记]Yii2.0给一张表中增加一个属性
1.model中建立关联 public function getUser(){ return$this->hasOne(User::className(),['id'=>'uid']) ; ...