Android Studio 3.5 Canary adds “Apply Changes”, a replacement for Instant Run

Android Studio 3.5 (currently in the Canary and Dev channels) now features a new way to apply code changes to your app and see their effects on the fly without having to restart the app. Dubbed simply “Apply Changes”, it is the successor to the “Instant Play” feature in previous versions of Android Studio.

Google’s Android Developer Blog says the following about Apply Changes:

Apply Changes allows you to send code and resource changes to your running app without restarting your app and, in some cases, without restarting the current activity. Apply Changes replaces Instant Run with a whole new approach to build optimization. Instead of rewriting your APK’s bytecode during build, Apply Changes redefines classes on the fly by taking advantage of runtime instrumentation supported in Android 8.0 (API level 26) or higher.

Additionally, Android Studio now prompts you to decide whether to restart your app or activity when it detects that the changes are not compatible with Apply Changes. This additional control should give you a more consistent and predictable experience compared to Instant Run’s behavior.

The blog post then lists some limitations of the new feature. For example, the device you’re testing your app on must at least be running Android 8.0 Oreo (API level 26) and some code changes will still require your app to be restarted. As with “Instant Run”, “Apply Changes” will force your application to restart if you:

  • Add or remove a class, method or field
  • Modification of the manifesto
  • Editing method signatures
  • Modifying method or class modifiers
  • Rename classes
  • Changing class inheritance
  • Add or remove a resource

Under “Known Issues”, the blog post states that since Google initially prioritized performance stability in this new feature, “Apply Changes” will sometimes work slower than its predecessor “Instant Execution”. Additionally, x86_x64 emulator images are not supported, and for debugging purposes only Android Pie (API level 28) is supported. You can see the full list of limitations and known issues at the source link below.

For a more detailed description of the difference between “Apply Changes” and “Instant Execution,” a Google employee on the Android Studio team said this on Reddit:

He’s doing something very, very different. Instant Run had a very specific build impact, instrumenting each of your classes at compile time to prepare them to be replaced during runtime with a new version of the class. It also splits your APK into multiple APKs to re-download your app in a more incremental way.

Applying the changes does nothing of the sort. Your APK is pretty much the same whether you use Apply Changes or not. Instead, it leverages new ART virtual machine runtime instrumentation capabilities to dynamically reload classes and replace them while the application is running. That’s why it requires much newer versions of Android.

“Apply Changes” should eventually replace “Instant Execution” in beta and stable channels as Google improves its performance and stability.

Source: Android Developer Blog

Comments are closed.