How to prevent Android Studio 2.0 from doing a complete clean build after uninstalling app from device?

1.8k views Asked by At

I've been using Android Studio 2.0 Beta 5 with Gradle plugin 2.0.0-beta5. I've had Instant Run feature enabled, which is very useful when I want to do a quick change-and-test. Because it usually needs 50 seconds for my project to do a complete :assembleDebug. With Instant Run, I've been able to get my changed code running on device within about 10 seconds.

However, when I need to remove the app from the test device and have a complete new install. Android Studio always do the following thing when I click the "Run" button for the next time:

:clean, :generateDebugSources, :generateDebugAndroidTestSources, :prepareDebugUnitTestDependencies, :mockableAndroidJar, :assembleDebug

This is very slow. It takes up about 2 minutes for my project.

Is there a way to disable this behaviour? Or why is it not possible?

2

There are 2 answers

0
xiaomi On

The instant run, in order to be faster only target the API of the selected device.

Instant run uses different techniques to perform hot, warm, and cold swaps that are specific to the API level of the target device

Instant run ref.

But if you just need to push the apk again, you can use the gradle task install... (in general install+Flavor+Type i.e.:installProdRelease installPaidDebug) or use ADB to install your APK manually.

0
Luten On

Got the same problem.
Fixed by turning off Instant Run
(File -> Settings -> Build, Execution, Deployment -> Instant Run)