HelloCW
HelloCW

Reputation: 2255

What happens after I run rebuild project in Android Studio?

The document http://www.jetbrains.com/idea/help/rebuilding-project.html?search=reb only tells me how to rebuild a project.

I don't know what does it mean to rebuild a project (Menu --> Build --> Rebuild Project), will it clean all edit cache? I find the size of the project reduced after I run rebuild project?

What does it mean to clear a project in Android Studio?

Upvotes: 6

Views: 4733

Answers (2)

Aldo Wachyudi
Aldo Wachyudi

Reputation: 18001

Android App is a Gradle project that uses com.android.application plugin. When you click rebuild button, clean button, or run button. It will run a series of command. Note that not all command is a Gradle Task. For example, run and debug button is going to run adb behind the scene.

In Rebuild button you're running multiple Gradle tasks. You can see it in the bottom right section of Android Studio.

Gradle Console Tab

In this case, Android Studio will run the following Gradle tasks: clean, :app:generateDebugSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :app:generateDebugAndroidTestSources, :app:compileDebugSources, :app:compileDebugUnitTestSources, :app:compileDebugAndroidTestSources

What you see before colon (:) is the module name. app:generateDebugSource is going to run generateDebugSource task on app module.

But what happened if you have multiple modules?

Multiple Module

Apparently, Android Studio will run those task on each module.

Executing tasks: [clean, :app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :app:compileDebugSources, :app:compileDebugAndroidTestSources, :app:compileDebugUnitTestSources, :myandroidlib:generateDebugSources, :myandroidlib:mockableAndroidJar, :myandroidlib:prepareDebugUnitTestDependencies, :myandroidlib:generateDebugAndroidTestSources, :myandroidlib:compileDebugSources, :myandroidlib:compileDebugUnitTestSources, :myandroidlib:compileDebugAndroidTestSources]

will it clean all edit cache? I find the size of the project reduced after I run rebuild project ?

It will clean files in build folder. Usually, this is not included in a project (added in .gitignore). A build folder will have your final apk, an R files, a report file (like lint / JUnit test report), and generated classes (from Dagger / Retrofit). That's why it will reduce the size of your project.

BTW, what mean does it to clear project in Android studio?

If what you mean by clear project is clean project.

Clean project

Android Studio will run these following tasks, which essentially deletes build folder.

Executing tasks: [clean, :app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :myandroidlib:generateDebugSources, :myandroidlib:mockableAndroidJar, :myandroidlib:prepareDebugUnitTestDependencies, :myandroidlib:generateDebugAndroidTestSources]

Upvotes: 0

flower_green
flower_green

Reputation: 1394

In Android Studio, almost every voice in the build menu is mapped to a (possibly more than one) gradle action, where Gradle is the official build system for android. In particular, when you clean the project you are deleting some files from the build folder inside your app module, and when you select rebuild that's the equivalent of doing a gradle clean and build. For more information on the topic I suggest this course on Udacity, which you can view for free. It teaches you gradle and how it integrates with android studio.

https://www.udacity.com/course/gradle-for-android-and-java--ud867

Upvotes: 6

Related Questions