Equivalent of Clean & build in Android Studio?

AndroidAndroid Studio

Android Problem Overview


Today while running an app from Android Studio, it didn't build from my latest code.

I looked for a Clean & build option but I couldn't find one.

So my question is: what is Android Studio's equivalent of Clean & build?

Android Solutions


Solution 1 - Android

Android studio is based on Intellij Idea. In Intellij Idea you have to do the following from the GUI menu.

Build -> Rebuild Project

Solution 2 - Android

I don't know if there's a way to get a clean build via the UI, but it's easy to do from the commandline using gradle wrapper. From the root directory of your project:

./gradlew clean 

Solution 3 - Android

In latest releases of Android Studio one more option has been added dedicatedly for Clean.

Build > Clean Project 

Solution 4 - Android

Also you can edit your Run/Debug configuration and add clean task.

Click on the Edit configuration

Click on the Edit configuration

In the left list of available configurations choose your current configuration and then on the right side of the dialog window in the section Before launch press on plus sign and choose Run Gradle task

choose Run Gradle task

In the new window choose your gradle project and in the field Tasks type clean.

type clean

Then move your gradle clean on top of Gradle-Aware make

Solution 5 - Android

reed these links

http://tools.android.com/tech-docs/new-build-system/version-compatibility https://developer.android.com/studio/releases/gradle-plugin.html

in android studio version 2+, use this in gradle config

android{
..

compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
        incremental = false;
}
...

}

after 3 days of search and test :(, this solve "rebuild for any run"

Solution 6 - Android

It is probably not a correct way for clean, but I made that to delete unnecessary files, and take less size of a project. It continuously finds and deletes all build and Gradle folders made file clean.bat copy that into the folder where your project is

  set mypath=%cd% 
    for /d /r %mypath% %%a in (build\) do if exist "%%a" rmdir /s /q "%%a"
    for /d /r %mypath% %%a in (.gradle\) do if exist "%%a" rmdir /s /q "%%a"

Solution 7 - Android

If none of the above works and Build->Make is grayed out. try this:,
First select the project and then
Go to file->Project_structure
Close the window and the Build->Make ; will be available.
This is for
enter image description here

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
QuestionGaurav VashisthView Question on Stackoverflow
Solution 1 - AndroidTarunView Answer on Stackoverflow
Solution 2 - AndroidalikondaView Answer on Stackoverflow
Solution 3 - AndroidPiyush AgarwalView Answer on Stackoverflow
Solution 4 - AndroidOleg OsipenkoView Answer on Stackoverflow
Solution 5 - AndroidHamid ZandiView Answer on Stackoverflow
Solution 6 - AndroidSergey PaukovView Answer on Stackoverflow
Solution 7 - Androidcliff2310View Answer on Stackoverflow