Types of code Swaps in Instant Run
There are three types of code swaps that Instant run enables to support faster debugging and running app from your code in Android Studio.
- Hot Swap
- Warm Swap
- Cold Swap
When are each of these swaps triggered?
HOT SWAP is triggered when an existing method’s implementation is changed.
WARM SWAP is triggered when an existing resource is changed or removed (anything in the res folder)
COLD SWAP whenever there is a structural code change in your app’s code e.g.
- Add, remove, or change:
- an annotation
- an instance field
- a static field
- a static method signature
- an instance method signature
- Change which parent class the current class inherits from
- Change the list of implemented interfaces
- Change a class’s static initializer
- Reorder layout elements that use dynamic resource IDs
What happens when a code swap happens?
HOT SWAP changes are visible instantly - as soon as the next call to the method whose implementation is changed is made.
WARM SWAP restarts the current activity
COLD SWAP restarts the entire app (without reinstall)