Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio is not detecting code changes on build/run(

Whenever I make a code change in the Android Studio (version 3.0.1) I need to clean before I build in order for that change to take effect. Making a change and hitting the green arrow build/run button looks like it builds but the new changes are not incorporated unless the project is cleaned beforehand. For example, if I add some logging then build/run, the new logs don't appear until I clean then build/run again. This seems to be the case for almost all changes. Sometimes it works, most of the time it doesn't.

The compiler should detect changes to the code and rebuild those files every single time. It feels like they prioritized build speed over correctness. Has anyone else solved this problem? If not then is there some setting that forces a clean before every build/run?

like image 479
Clark Battle Avatar asked Mar 14 '18 21:03

Clark Battle


3 Answers

I had the same issue after updating Android Studio to version 3.1. It seems that the Before launch action of the default run configuration has been changed to Instant App Provision. Check it out and change to Gradle-aware Make here:

Run/Debug Configurations window

like image 190
4emodan Avatar answered Oct 11 '22 15:10

4emodan


I experienced that when I left my Android Studio opened for a long time. The solutions I found were:

  1. Hit the "Sync Project with Gradle files" button.

enter image description here

  1. Restart Android Studio.

I hope this helps you.

like image 1
Luis Morales Avatar answered Oct 11 '22 13:10

Luis Morales


This suddenly started: Code changes were not being reflected on the app / were not taking effect.

My "Run / Debug configurations" settings were as said by @4emodan.

Still, i was facing the problem.

"File -> Invalidate Caches / Restart ..."<br>

made it.

This could have been the result of my machine intermittently rebooting (because of hardware issues).

like image 1
sifr_dot_in Avatar answered Oct 11 '22 15:10

sifr_dot_in