run app vs apply changes android studio 2.3-ThrowExceptions

Exception or error:

What is the major difference between

Run app and Apply changes?

enter image description here

What could be the best scenario to use each?

Thanks.

How to solve:

“Apply changes” will be enabled if you have “instant run” enabled and to disable instant run check https://stackoverflow.com/a/35169716/2826147

From the Android documentation: 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.

###

When you click “Run” App icon, it will uninstall existing build and install build every time.

“Apply Changes” option will be available only if you enable “Instant Run” feature in android studio. It will swap changes to existing build and run your build. Your existing build will not get uninstalled when you do this.

###

The Instant Run / Apply Changes feature will try to push your changes without building and deploying a full APK, and if possible without restarting the application or even the current activity. It will resort to a full reinstall if needed. More details here.

Before Android Studio 2.3, the Instant Run feature was available through the Run (or Debug) button, as long as certain conditions were met. Starting with Studio 2.3 we have a dedicated button for Instant Run, which is the Apply Changes button. It is only available when Instant Run is possible. The Run and Debug button now always restart the app.

From the 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

###

for Android Studio 3.5 and higher
enter image description here

Leave a Reply

Your email address will not be published. Required fields are marked *