运行 应用与应用更改 android studio 2.3

run app vs apply changes android studio 2.3

两者的主要区别是什么

运行 应用应用更改?

使用每种方案的最佳方案是什么?

谢谢。

当您点击"Run" 应用程序图标时,它会卸载现有版本并每次安装版本。

只有在 android 工作室中启用 "Instant Run" 功能后,

"Apply Changes" 选项才可用。它将交换对现有构建和 运行 您的构建的更改。当您执行此操作时,您现有的构建不会被卸载。

"Apply changes" 将在您启用 "instant run" 时启用 并禁用即时 运行 检查

来自 Android 文档:https://developer.android.com/studio/run/index.html

Apply Changes button provides a faster workflow for most incremental changes to your app. [...]

You can clickApply Changes to push certain code and resource changes to your running app without building a new APK—and, in some cases, without even restarting the current activity. [...]

Clicking Run (or Debug ) forces a cold swap and an app restart. If you make a change to the app manifest or a resource referenced by the manifest, Android Studio always pushes your changes with a full APK reinstall. [...]

Apply Changes action is available only when you meet the following conditions:

  • Build your app using a debug build variant.
  • Use Android plugin for Gradle version 2.3.0 or higher.
  • Set minSdkVersion to 15 or higher in your app's module-level build.gradle file.
  • Deploy your app to a target device running Android 5.0 (API level 21) and higher.

Instant 运行 / Apply Changes 功能将尝试在不构建和部署完整 APK 的情况下推送您的更改,并且如果可能的话不重新启动应用程序甚至当前 activity。如果需要,它将求助于完全重新安装。更多详情 here.

在 Android Studio 2.3 之前,即时 运行 功能可通过 运行(或调试)按钮使用,只要满足特定条件即可。从 Studio 2.3 开始,我们有一个 Instant 运行 的专用按钮,即“应用更改”按钮。它仅在 Instant 运行 可用时可用。 运行 和调试按钮现在总是重启应用程序。

来自Release Notes

A separate button to push changes with Instant Run: After deploying your app, you now click Apply Changes to quickly push incremental changes to your running app using Instant Run. The Run and Debug buttons are always available to you when you want to reliably push your changes and force an app restart

对于 Android Studio 3.5 及更高版本