什么是 Android Studio Instant Run? [英] what is Android Studio Instant Run?

查看:55
本文介绍了什么是 Android Studio Instant Run?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天我更新了我的 Android Studio 并运行了与以前版本一起存在的应用程序.当我运行应用程序时,以前版本的应用程序启动速度非常快,但是当我更新了 android studio 并使用更新版本运行相同的应用程序时,应用程序是启动时间太长.我在谷歌上搜索了这个问题,发现如果启用了即时运行,则禁用它,所以我做了同样的事情,应用程序启动的速度和原来一样快.

Today I have updated my Android Studio and run the app which existing with previous version.When I was running the app with previous version app launching very fast but when I updated android studio and run the same app with updated version then app was taking too much time to launch.I googled for the issue and found that if instant run is enable then disable this so I have done the same and app launched as fast as it was.

现在我的问题是-

  1. 什么是即时运行?使用它的利弊是什么?
  2. 为什么在启用即时运行时应用需要花费太多时间来启动,而当我禁用它时,为什么它会像以前一样快速启动应用.

推荐答案

Instant run 附带最新版本的 Android Studio.但在某些情况下,使用它时它是有线的.

Instant run comes with the latest version of Android Studio. But in some cases it is wired when using that.

在普通的构建和运行中,整个 APK 文件都会更新并推送到设备.但是当使用即时运行时,只有更新的部分会在设备中被替换.Instant Run 通过执行热插拔热插拔冷插拔,将更新的代码和资源推送到您连接的设备或模拟器.它会根据您所做的更改类型自动确定要执行的交换类型.

In an ordinary build and run the whole APK file is updated and pushed to the device. But when using instant run only the updated part gets replaced in the device. 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.

它可能比普通构建更快.但它要求应用程序在 API 21 以下构建时正在运行.

It may be faster than an ordinary build. But it requires the application to be running at the time of build below API 21.

说真的,我觉得安装不变的问题.那是在某些时候使用即时运行时,应用程序似乎没有更新.它保持在以前的版本.有时我觉得它比普通构建慢.

Seriously I felt a problem of the unchanged installation. That is when using instant run at some times the application seems to not updating. It is staying at its previous build. And sometimes I felt it was slower than an ordinary build.

这是最快的交换类型,可以更快地看到更改.您的应用程序将继续运行,并且下次调用该方法时将使用具有新实现的存根方法.

This is the fastest type of swap and makes changes visible much more quickly. Your application keeps running and a stub method with the new implementation is used the next time the method is called.

这种交换仍然非常快,但是当 Instant Run 将更改的资源推送到您的应用时,它必须重新启动当前的 Activity.

This swap is still very fast, but Instant Run must restart the current activity when it pushes the changed resources to your app.

这个交换有点慢,因为虽然不需要新的 APK 文件,但 Instant Run 在推送结构代码更改时必须重新启动整个应用程序.

This swap is a bit slower because, although a new APK file is not required, Instant Run must restart the whole app when it pushes structural code changes.

禁用即时运行:File=>Settings=>Build,Execution anddeployment=>Instant Run=>取消选中为热插拔启用即时运行

参见这个 文档.

这篇关于什么是 Android Studio Instant Run?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆