Android Studio Instant Run - Override and rebuild full app
Asked Answered
A

1

6

I'm loving the Instant Run feature of Android Studio 2.0 so far. For little tweaks in the current activity it's great. However sometimes I need to make a tweak in an earlier activity and Instant Run either doesn't apply that change or maybe just doesn't rerun that previous activity. I'd like to be able to keep Instant Run as a quick option, but sometimes just want to tell AS to just reload the full app and not use Instant Run.

Is there a quick way to do this? I saw somewhere that there was a 3-step checklist to do it - Stop, Rebuild, Debug. But even that didn't seem to work and obviously was slower than the old method of pressing a single button.

Aliphatic answered 10/2, 2016 at 16:35 Comment(2)
Yep exactly, when you make bigger changes like changing method signatures instant run just tries to swap it and it can lead to ART exceptions. Docs just advice to stop the app and rebuild it which will install an apk tools.android.com/tech-docs/instant-run. However, that is slow and a simple non-instant run button from the old version would be faster.Posthumous
Clyde, you can use Build > Clean and Re-run in that case. Shift + Click on re-run icon will also do Clean and Re-run.Embarrassment
J
7

This happens because your changed code was never run again, so it's not a bug per se.

In the stable version of Android Studio 2.0, we have added a re-run button enter image description here to the toolbar. If you click it, it will push your changes and restart your app, essentially forcing a cold swap. The restarted process would then have all the changes you want to see because all your new code will get run again.

Hope that helps!

Jinnyjinrikisha answered 11/4, 2016 at 14:45 Comment(1)
In Studio 2.2 the re-run button restarts the app, but does not re-install the APK. I have changes in the code which are not getting pushed to the device. It's very frustrating because on a couple of occasions I have spent considerable time tearing my hair out because nothing I did seemed to solve a problem, only to realise that the APK was not being updated.Englebert

© 2022 - 2024 — McMap. All rights reserved.