问题描述
今天我更新了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.
现在我的问题是-
- 什么是即时运行?使用它有什么弊端?
- 启用即时运行后,为什么应用程序花费太多时间启动,而当我禁用它时,为什么它却能如此快地启动应用程序.
推荐答案
最新版本的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将更改的资源推送到您的应用程序时,必须重新启动当前活动.
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.
请参见 此 文档.
See this documentation.
这篇关于什么是Android Studio Instant Run?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!