Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Have to rebuild project every time in Android Studio and Gradle

I have a multi-project build setup in Android Studio 0.5.4 and Gradle 0.9.2 with dependencies on Multiple Android Library Projects and Java projects, and I'm noticing that Gradle thinks my code is UP TO DATE even though I've made changes.

If I change an xml layout file, I can just build and run and changes take effect. But for code changes, I have to use Build->Rebuild Project.

like image 522
M Dapp Avatar asked Apr 29 '14 16:04

M Dapp


2 Answers

this problem is related to gradle settings. you must disable configure on demand in the setting. to disable that, uncheck it in:

Settings -> Build, Execution, Deployment -> Compiler -> Configure On Demand

in my own case I wasnt able to see my .aar changes even after rebuilding !!! since this option make the build process faster. I only uncheck it whenever there is a change.

UPDATE: in upper versions of Android Studio you should check "Sync project with gradle before building if needed"

like image 79
Amir Ziarati Avatar answered Nov 20 '22 02:11

Amir Ziarati


In Edit Configuration for app, Go to General Tab and check that you should have Gradle-aware Make added in the general configuration's settings field for Before-launch

If it's not added yet than add it by pressing the + icon available with Before-launch

This solution is applied for Android Studio 3.3.2 and above.

For reference see below image.enter image description here

like image 44
Harpreet Avatar answered Nov 20 '22 01:11

Harpreet