Why are Clean
and Rebuild
identical in AS 2.3.3 and why then are both options found in the Build
menu?
As explained here, there is no difference in AS 2.3.3 between Build
> Clean
and Build
> Rebuild
. Simply checking the Event Log
verifies this.
So why not modify the AS 2.3.3 Build
menu to have ONE option, e.g., Clean and Rebuild
. It's an interesting historical note that Clean
used to do something different from Rebuild
, so that might justify having both in the menu, but it is confusing.
Note that (supposedly) in Visual Studio, the Clean
and Rebuild
options do different things, no doubt much like AS did in 1.0.
P.S. this and this point out that Gradle 4.1 doesn't always interpret commands in the "expected" order. Does this explain why Clean
and Rebuild
must be the same?
I use clean to update R values while I'm in the middle of coding. I don't want to know that there are errors in my unfinished code, I just want the R file links to be current.
On the other hand Rebuild lists out all the errors.
So behind the scenes they may be the same, but the results are presented in different ways to the user.
@Sam is correct. Looking ONLY at the Event log
is pretty superficial since it
only logs events, not details. Looking at the Gradle console
clarifies it all:
Here's what Clean
, even with an error in the code I'm compiling:
Executing tasks:
[clean, :app:generateDebugSources, :app:mockableAndroidJar,
:app:prepareDebugUnitTestDependencies,
:app:generateDebugAndroidTestSources,
:app:compileDebugSources, :app:compileDebugUnitTestSources,
:app:compileDebugAndroidTestSources]
Configuration on demand is an incubating feature.
Incremental java compilation is an incubating feature.
:clean
:app:clean
:app: preBuild UP-TO-DATE
(MY NOTE ^^^^^^^^
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAnimatedVectorDrawable2600Alpha1Library
:app:prepareComAndroidSupportAppcompatV72600Alpha1Library
:app:prepareComAndroidSupportConstraintConstraintLayout102Library
:app:prepareComAndroidSupportSupportCompat2600Alpha1Library
:app:prepareComAndroidSupportSupportCoreUi2600Alpha1Library
:app:prepareComAndroidSupportSupportCoreUtils2600Alpha1Library
:app:prepareComAndroidSupportSupportFragment2600Alpha1Library
:app:prepareComAndroidSupportSupportMediaCompat2600Alpha1Library
:app:prepareComAndroidSupportSupportV42600Alpha1Library
:app:prepareComAndroidSupportSupportVectorDrawable2600Alpha1Library
:app:prepareDebugDependencies
:app:compileDebugAidl
:app:compileDebugRenderscript
:app:generateDebugBuildConfig
:app:generateDebugResValues
:app:generateDebugResources
:app:mergeDebugResources
:app:processDebugManifest
:app:processDebugResources
:app:generateDebugSources
:app:mockableAndroidJar
:app:preDebugUnitTestBuild UP-TO-DATE
:app:prepareDebugUnitTestDependencies
:app:preDebugAndroidTestBuild UP-TO-DATE
:app:prepareComAndroidSupportTestEspressoEspressoCore222Library
:app:prepareComAndroidSupportTestEspressoEspressoIdlingResource222Library
:app:prepareComAndroidSupportTestExposedInstrumentationApiPublish05Library
:app:prepareComAndroidSupportTestRules05Library
:app:prepareComAndroidSupportTestRunner05Library
:app:prepareDebugAndroidTestDependencies
:app:compileDebugAndroidTestAidl
:app:processDebugAndroidTestManifest
:app:compileDebugAndroidTestRenderscript
:app:generateDebugAndroidTestBuildConfig
:app:generateDebugAndroidTestResValues
:app:generateDebugAndroidTestResources
:app:mergeDebugAndroidTestResources
:app:processDebugAndroidTestResources
:app:generateDebugAndroidTestSources
Rebuild
does all that PLUS THE FOLLOWING IF there's an error in the code:
:app:incrementalDebugJavaCompilationSafeguard
:app:javaPreCompileDebug
:app:compileDebugJavaWithJavac
:app:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
C:\Users\Dov\Desktop\SQhell\app\src\main\java\com\dslomer64\sqhell\MainActivity.java:221: error: not a statement
x return true;
^
C:\Users\Dov\Desktop\SQhell\app\src\main\java\com\dslomer64\sqhell\MainActivity.java:221: error: ';' expected
x return true;
^
2 errors
:app:compileDebugJavaWithJavac FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 16.398 secs
If there is NO error in the code, Rebuild
does this:
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources
:app:incrementalDebugUnitTestJavaCompilationSafeguard UP-TO-DATE
:app:javaPreCompileDebugUnitTest
:app:compileDebugUnitTestJavaWithJavac UP-TO-DATE
:app:processDebugJavaRes UP-TO-DATE
:app:processDebugUnitTestJavaRes UP-TO-DATE
:app:compileDebugUnitTestSources UP-TO-DATE
:app:incrementalDebugAndroidTestJavaCompilationSafeguard
:app:javaPreCompileDebugAndroidTest
:app:compileDebugAndroidTestJavaWithJavac
:app:compileDebugAndroidTestNdk UP-TO-DATE
:app:compileDebugAndroidTestSources
BUILD SUCCESSFUL
Total time: 26.83 secs
In any event, Build
performs a Clean
AND THEN COMPILES the code, terminating if errors are found (and listed); otherwise, doing a full compile.
So Clean
DOES differ from Rebuild
.
(This means some other posts, like the one listed in Question, have to be modified.)