为什么Clean
和 Rebuild
在AS 2.3.3中是相同的,为什么在 Build
菜单中都可以找到选项?
正如这里所解释的那样,As 2.3.3在Build
> Clean
和Build
> Rebuild
之间没有差异。只需检查Event Log
就可以验证这一点。
那么,为什么不修改AS 2.3.3 Build
菜单,使之只有一个选项,例如,Clean and Rebuild
。这是一个有趣的历史记录,Clean
过去常常做一些与Rebuild
不同的事情,因此这可能证明在菜单中同时使用这两种方法是合理的,但这是令人困惑的。
注意(据推测,)在Visual中,Clean
和Rebuild
选项所做的事情是不同的,这无疑与1.0中的情况非常相似。
P.S. 这和这指出,第4.1级并不总是按照“预期”顺序解释命令。这是否解释了为什么Clean
和Rebuild
必须相同?
发布于 2017-11-08 02:17:33
在编码过程中,我使用clean更新R值。我不想知道我的未完成代码中有错误,我只是希望R文件链接是当前的。
另一方面,重建列表列出所有错误。
因此,在幕后,它们可能是相同的,但结果以不同的方式呈现给用户。
发布于 2017-11-08 12:23:49
@萨姆是对的。只查看Event log
是相当肤浅的,因为它只记录事件,而不是细节。看看Gradle console
,我们就会明白这一切:
下面是Clean
,即使在我正在编译的代码中有一个错误:
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
会执行所有这些操作,并执行以下操作:
: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
如果代码中没有错误,Rebuild
将执行以下操作:
: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
无论如何,Build
执行一个Clean
,然后编译代码,如果发现错误(并列出错误),则终止;否则,执行完整编译。
因此,Clean
Rebuild
**.**与有区别。
(这意味着必须修改其他一些帖子,比如所列的帖子。)
https://stackoverflow.com/questions/47170318
复制相似问题