[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 ...
随机推荐
- Think different
Here's to the crazy ones.The misfits.The rebels.The troublemakers.The round pegs in the square holes ...
- orleans/Documentation
福利 奥尔良的主要好处是︰开发人员工作效率,甚至为非专家程序员;和默认的透明可伸缩性与程序员没有特别努力.我们扩大每个下面这些好处. 开发人员的生产力 奥尔良的编程模型通过提供以下关键的抽象. 担保和 ...
- 非常完善的Log4net详细说明
4.1.6 <filter> 过滤器,只能作为<appender>的子元素. 支持的属性: type 必须的,Filter的类型 支持的子元素: param 0个或多个, ...
- win10下vs2015创建asp,net core项目并运行在ubuntu14.04下
上文说了.net core程序在win10与ubuntu下运行,用的是示例程序(https://github.com/aspnet/cli-samples),今天用vs2015 构建asp.net c ...
- 【转】php中XML、XSLT的结合运用
原文:http://blog.csdn.net/bjbs_270/article/details/140253 下面我要讲的是一个简单的从数据库中抽取数据,生成XML文档,使用XSLT转换成HTM ...
- 【Linux_Fedora_应用系列】_1_如何安装音乐播放器和mp3解码
因为安装环境的不同,Fedora在安装后会安装不同的软件包.通常在安装的时候有多种选择: 1.桌面环境: 适合个人日常使用,安装包含办公软件(Fedora 默认安装Open Office).娱乐影音软 ...
- 初学C++之自定义类型名简化
说明:本人使用的是vc++ IDE:vs2013 我在自定义一些类时,有时会取一些很长的名字,但是这不利于使用,这个时候就可以使用类型名简化. class MathAddBBBB { }; using ...
- python 颜色定义
1.颜色定义说明格式:\033[显示方式;前景色;背景色m前景色 背景色 颜色---------------------------------------30 40 黑色31 41 红色32 42 ...
- Android总结篇系列:Android开发环境搭建
工欲善其事必先利其器. 1.安装并配置Java环境进入Java oracle官网,当前网址如下:http://www.oracle.com/technetwork/java/javase/downlo ...
- maven 检查依赖冲突和版本冲突
maven 检查依赖冲突和版本冲突 在项目发布的时候,一般都需要进行依赖冲突检查或者重复类的检查,这个时候我一般会使用下面的两个命令: 1 2 3 mvn -U clean package - ...