Android Studio 2.1及其以上版本中的instant run功能 介绍
Android Studio 2.0及其以后版本中的instant run功能 介绍
Studio 2.0 之后就有了instant run 功能
说说 instant run 功能:字面意思就能明白 即时运行
这个功能在2.1是默认开启的 而它的相关设置界面呢如下:
就是右边的是个设置了
如何判断是否可以呢 通过 看到了 运行案例左边的⚡️ 了吗? 那就是可以了
先给 大家贴上 官方介绍文档
这个功能就是当你修改了代码或者布局的时候 点击运行 它不会将整改项目都进行重新打包,而是能直接在你的测试机上体现。
比如我们以前调整了布局后 需要看到效果就得重新打包运行了。
而现在呢就不用了,当然了使用方法是一样的 。但是呢速度要快很多。几秒内就能完成。
而如果是整体打包的话那速度就慢了。以前1.4版本的时候一分钟就能打包完了。现在得3分钟。
Code Change | Instant Run Behavior |
---|---|
|
Supported with hot swap: This is the fastest type of swap and makes changes visible almost instantly. Your application keeps running and a stub method with the new implementation is used the next time the method is called. 如果是左边的这种情况,那就是热插拔模式了,修改后能马上看到效果(热插拔大家都了解,就是现在的U盘的那种模式,插上就能用) |
|
Supported with warm swap: This swap is still very fast, but requires an automatic activity restart when Instant Run pushes the changed resources to the target device. Your app keeps running, but a small flicker may appear on the screen as the activity restarts—this is normal. (如果是这种情况的话,那速度也挺快的 但是没有上面的快,如果你要修改的这个页面是正在显示的页面 它就会闪一下,然后你的修改就能看到你。 这种情况 你的app 不会重新启动的。成功后 你的设备中就会弹出一个Toash) |
Structural code changes, such as: (代码结构进行了变化)
|
Supported with cold swap (API level 21 or higher): Instant Run pushes the structural code changes to the target device and restarts the whole app. For target devices running API level 20 or lower, Android Studio deploys a full build of the APK.
就是说 如果发生了左边说的那种情况,而刚好你的api登记是在21或以上,那就会将修改结构代码更改推到目标设备运行。这个时候你的app会重新启动。但是耗时不会很长。 但是如果你的版本是20版本或以下,那就没什么好说的你。 重新生成构建整个apk了。那速度 可真是相当慢了。 |
|
When making changes to the app manifest or resources referenced by the manifest, Android Studio automatically deploys a new build in order to push changes to your target device. This is because certain information about the app, such as its name, app icon resources, and intent filters, are determined from the manifest when the APK is installed on the device. If your build process automatically updates any part of the app manifest, such as automatically iterating
这边就告诉你说,这种情况下 instant run 就不起作用了。得重新打包生成整个项目了
|
相关文章
- android端 socket长连接 架构
- Android Studio 超级简单的打包生成apk
- 酷炫的Android交互动画和视觉效果:高仿音悦台播放页面
- Android轻松实现RecyclerView悬浮条
- Android动态加载入坑指南
- Android开发之Path详解
- 2021年Android开发者跳槽指南,实战篇
- Android Studio项目目录结构介绍
- Android Studio 初体验
- 手动安装配置Android Studio
- Android之asset文件夹下文件的使用
- android 该项目的优化toast优化技巧
- Android Studio导入项目一直在下载gradle
- Android Studio实现一个小说阅读App
- Android Studio实现图书馆订座系统
- Android:kotlin中Gson与JSON的泛型映射解析解决方案
- Android Studio 创建文件快捷键 ,复写方法快捷键
- android studio viewBinding 老爆红
- Android仿茄子快传-实现面对面快传功能
- Android studio 二维码扫描的实现
- 8 个最优秀的 Android Studio 插件
- Android下的图片压缩及图片和视频的上传
- 高效 | 几个Android Studio 小技巧
- 85篇技术好文助你Android进阶
- Android学习记录