Difference between clean project and rebuild project in android studio

AndroidAndroid StudioIntellij Idea

Android Problem Overview


What is the difference between Clean Project and Rebuild Project (in Android Studio)?

  • I had a problem with the R file about res ids, so I changed the file extension from gif to png and then [my build failed.]
  • I found the solution was to Rebuild Project. This prompts my question above.

Android Solutions


Solution 1 - Android

A clean just removes all build artifacts. A rebuild does a clean followed by a build of your project.

EDIT #2 This is 100% true. Refer to this for a thorough demonstration of its correctness.

Solution 2 - Android

What I experienced,

When you do clean, it removes the binaries inside build folders, and postpones building them again to the next run.

When you do rebuild, it does clean and rebuild for those files inside build folder, which rebuilt again in the next run. It does not rebuild the APK!! Which is really weird.

so:

Clean removes the build folders contents.

Rebuild removes the build folder's contents. And builds some binaries; not including the APK!

BTW, I am using Android studio 2.0 Preview 7.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionFukkongView Question on Stackoverflow
Solution 1 - AndroidLarry SchieferView Answer on Stackoverflow
Solution 2 - AndroidMBHView Answer on Stackoverflow