Androidstudio clean project 和 rebuild project 的区别

Androidstudio clean project 和 rebuild project 的区别

clean project : 会删除build文件夹

rebuild project:会删掉module下build文件夹,然后再创建build文件夹。

所以创建了aidl文件后,可以rebuild project 一下,

这里会有一个问题,直接Build–Rebuild Project的话,会Rebuild 所有的 Project。这样耗时会很长,体验效果差。

那怎么只Clean/Rebuild 一个 module呢? 这样就需要用到gradle语句了。

Clean一个Project方法:

在 Terminal 标签下输入

gradlew :your_module_name:task_name

例如:

gradlew :testmyservice:clean

要写代码其实也很麻烦,但是要灵活很多。这种方式也告诉我们,所有的操作也是执行了相应的代码或命令

所以对比下Build窗口执行的命令就可以知道,就可以知道他们的区别了
Rebuild Project执行的代码:

:clean UP-TO-DATE
:app:clean UP-TO-DATE
:base_lib:clean UP-TO-DATE
:base_lib_yxputils:clean UP-TO-DATE
:base_pro_https:clean UP-TO-DATE
:base_lib_yxputils:preBuild UP-TO-DATE
:base_lib_yxputils:preDebugBuild UP-TO-DATE
:base_lib_yxputils:compileDebugAidl
:base_lib_yxputils:compileDebugRenderscript
:base_lib_yxputils:checkDebugManifest
:base_lib_yxputils:generateDebugBuildConfig
:base_lib_yxputils:generateDebugResValues
:base_lib_yxputils:generateDebugResources
:base_lib_yxputils:packageDebugResources
:base_lib_yxputils:platformAttrExtractor
:base_lib_yxputils:processDebugManifest
:base_lib_yxputils:prepareLintJar UP-TO-DATE
:base_lib_yxputils:generateDebugRFile
:base_lib_yxputils:generateDebugSources
:base_lib_yxputils:javaPreCompileDebug
:base_lib_yxputils:compileDebugJavaWithJavacע: ijЩ�����ļ�ʹ�û򸲸����ѹ�ʱ�� API��
ע: �й���ϸ��Ϣ, ��ʹ�� -Xlint:deprecation ���±��롣

:base_lib_yxputils:processDebugJavaRes NO-SOURCE
:base_lib_yxputils:transformClassesAndResourcesWithPrepareIntermediateJarsForDebug
:base_pro_https:preBuild UP-TO-DATE
:base_pro_https:preDebugBuild UP-TO-DATE
:base_pro_https:compileDebugAidl
:base_pro_https:compileDebugRenderscript
:base_pro_https:checkDebugManifest
:base_pro_https:generateDebugBuildConfig
:base_pro_https:generateDebugResValues
:base_pro_https:generateDebugResources
:base_pro_https:packageDebugResources
:base_pro_https:platformAttrExtractor
:base_pro_https:processDebugManifest
:base_pro_https:prepareLintJar UP-TO-DATE
:base_pro_https:javaPreCompileDebug
:base_pro_https:processDebugJavaRes NO-SOURCE

Clean Project执行的代码:

:clean UP-TO-DATE
:app:clean UP-TO-DATE
:base_lib:clean UP-TO-DATE
:base_lib_yxputils:clean UP-TO-DATE
:base_pro_https:clean UP-TO-DATE

可以看出build project包含clean project的。

如果我们想要用gradlew执行build project操作 ,那么就要执行如下这么多操作:

:base_pro_https:clean UP-TO-DATE
:base_pro_https:preBuild UP-TO-DATE
:base_pro_https:preDebugBuild UP-TO-DATE
:base_pro_https:compileDebugAidl
:base_pro_https:compileDebugRenderscript
:base_pro_https:checkDebugManifest
:base_pro_https:generateDebugBuildConfig
:base_pro_https:generateDebugResValues
:base_pro_https:generateDebugResources
:base_pro_https:packageDebugResources
:base_pro_https:platformAttrExtractor
:base_pro_https:processDebugManifest
:base_pro_https:prepareLintJar UP-TO-DATE
:base_pro_https:javaPreCompileDebug
:base_pro_https:processDebugJavaRes NO-SOURCE

这显然不显示,当然也有更简单的方法。如下:

点击右侧的Gradle窗口,直接找到想要的rebuild的项目,然后Tasks–build–双击modulename:build,就会执行build操作了,这样可以只build一个module。

最后需要注意的是:想要在terminal执行命令,需要工程根目录有这两个文件。

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值