Android Studio 2.0 Instant Run Not Working

4.3k Views Asked by At

This new feature, Instant Run, is not working always as described. I just modify a paint color in text and Instant Run, it restarts activity! But after modifying some other code, Instant Run works pretty well. Am I missing something?

3

There are 3 best solutions below

0
On BEST ANSWER

Instant Run looks like a great tool in our arsenal, just keep in mind it is a new addition to Android Studio 2.0, which is still in Preview (Canary channel), hence there might be some hiccups. As Google says though, they plan to improve it over the coming months. As of this writing, here's what's supported:

+--------------------------------------+-----------------------------------------+
|           Code Change                |         Instant Run Support             |
+--------------------------------------+-----------------------------------------+
| Change instance method implementation| Supported                               |
| Change static method implementation  |                                         |
| Add or remove a class                |                                         |
|--------------------------------------|-----------------------------------------|
| Add, remove, or change               | Supported but requires an Activity      |
| a string resource                    | restart.                                |
+--------------------------------------+-----------------------------------------+

And here are some code changes that Instant Run does not currently support:

  • Add/remove/change annotations
  • Add/remove/change an instance field
  • Add/remove/change a static field
  • Add/remove a static method signature
  • Change a static method signature
  • Add/remove an instance method
  • Change an instance method signature
  • Changing which parent class the current class inherits from
  • Change the list of implemented interfaces
  • Changing static initializer of a class

I've had similar experience testing Instant Run, but this is to be expected at this stage. Hey, it didn't even work few times for Dave Burke during Android Dev Summit ;)

0
On

Instant Run feature needs to some rules that;

  • Android plugin for gradle version must be 2.0.0 or higher
  • minSdkVersion must be 15 or higher
  • At the same time, if you use multidex support (multiDexEnabled true) for your app, minSdkVersion must be 21 or higher. Otherwise, android studio disables Instant Run.

Ref :

https://developer.android.com/studio/run/index.html#instant-run https://developer.android.com/studio/build/multidex.html#about

But i can still use hot swap feature of instant run at my project even though it's minimun sdk version is 14.

1
On

What about gradle apt usage e.g. apply plugin: 'com.neenbedankt.android-apt' ? Does using apt prevent Android Studio Instant Run from hot-swapping the code?

In my case I use Dagger 2 and Instant Run doesn't seem to work.... Am I missing something?

EDIT: NO - IT DOES NOT! :) My installation was obviously missing something - just like during Dave's presentation. Instant Run still seems to be unstable on 2.0 preview 3b...