Equivalent of Clean & Build in Android Studio

Equivalent of Clean & build in Android Studio?

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

Build -> Rebuild Project

How to project clean in Android Studio?

You can clean your project doing this

Build > Clean Project or Build > Rebuild Project

Also you can do the gradlew clean

Sample Image

As @Kellogs commented :

Manually delete the [project]/.gradle as hidden folder as that one is the main culprit for large cleaned projects sizes.

Difference between clean, gradlew clean

  1. ./gradlew clean

    Uses your project's gradle wrapper to execute your project's clean task. Usually, this just means the deletion of the build directory.

  2. ./gradlew clean assembleDebug

    Again, uses your project's gradle wrapper to execute the clean and assembleDebug tasks, respectively. So, it will clean first, then execute assembleDebug, after any non-up-to-date dependent tasks.

  3. ./gradlew clean :assembleDebug

    Is essentially the same as #2. The colon represents the task path. Task paths are essential in gradle multi-project's, not so much in this context. It means run the root project's assembleDebug task. Here, the root project is the only project.

  4. Android Studio --> Build --> Clean

    Is essentially the same as ./gradlew clean. See here.

For more info, I suggest taking the time to read through the Android docs, especially this one.

Difference between clean project and rebuild project in android studio

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.

Clean Project vs Rebuild Project vs Run Project in Android Studio

Using gradle and more specifically the gradle wrapper you can see exactly what each of these is doing by adding an info tag when running from the root of your project.

Will show you the main tasks runnable from root project
./gradlew tasks

Will show you all tasks available in your project
./gradlew tasks --all

you can find out more about any tasks by using

./gradlew help --task <task>

Android tasks

androidDependencies - Displays the Android dependencies of the project.

signingReport - Displays the signing info for each variant.

sourceSets - Prints out all the source sets defined in this project.

Build tasks

assemble - Assembles all variants of all applications and secondary packages.

assembleAndroidTest - Assembles all the Test applications.

assembleDebug - Assembles all Debug builds.

assembleDevelopment - Assembles all Development builds.

assembleRelease - Assembles all Release builds.

build - Assembles and tests this project.

buildDependents - Assembles and tests this project and all projects that depend on it.

buildNeeded - Assembles and tests this project and all projects it depends on.

mockableAndroidJar - Creates a version of android.jar that's suitable for unit tests.

Build Setup tasks

init - Initializes a new Gradle build. [incubating]

wrapper - Generates Gradle wrapper files. [incubating]

Verification tasks

check - Runs all checks.

clean - Deletes the build directory.

connectedAndroidTest - Installs and runs instrumentation tests for all flavors on connected devices.

connectedCheck - Runs all device checks on currently connected devices.

connectedDevelopmentDebugAndroidTest - Installs and runs the tests for
developmentDebug on connected devices.

deviceAndroidTest - Installs and runs instrumentation tests using all Device Providers.

deviceCheck - Runs all device checks using Device Providers and Test Servers.

lint - Runs lint on all variants.

lintDevelopmentDebug - Runs lint on the DevelopmentDebug build.

lintDevelopmentRelease - Runs lint on the DevelopmentRelease build.

This is a good way to learn the ./gradlew commands available for your project



Related Topics



Leave a reply



Submit