以前在用eclipse的时候,项目遇到了问题,我们一般点击“Project—>Clean..”就可以搞定,但到了studio后,Build下面一下子出来了好几个:
- Make Project
- Make Module
- Clean Project
- Rebuild Project
- Build APK
- Sync now
真是搞懵了
以前用Clean,现在找相似的,我就是在Clean Project和Rebuild Project之间选着用,具体选哪个,完全看心情。
Make Project:完全不明白是什么鬼,真不知美帝是怎么想的。
Make Module:就更让我晕了。顺便讲个笑话,我刚开始分不请Project和Module是什么关系,从来不用Module,一个程序建一个Project,现在想想当初好傻好天真。
Sync now:这个我一般没怎么用,我一般都是在gradle中遇到问题,它自己弹出来,我才点的。
其他几个就不说了。
下面进入重点。
我去网上搬运几个关于它们的区别,先上*的:
Most of the time you should use Make Project. Sometimes, after adding libraries and making big changes to the project you should use Rebuild Project.
If you look at the menu, you’ll see that Make Project and Compile have keyboard shortcuts, that suggests that they are often used. Others are seldom used.
It is the same as IntelliJ Idea.
Compile All the source files in the specified scope are compiled. The scope in this case may be a file, a package, etc.
Make Project All the source files in the entire project that have been modified since the last compilation are compiled. Dependent source files, if appropriate, are also compiled. Additionally, the tasks tied to the compilation or make process on modified sources are performed. For example, EJB validation is performed if the corresponding option is enabled on the Validation page.
Make Module Compiled are all the source files that have been modified since the last compilation in the selected module as well as in all the modules it depends on recursively.
Rebuild Project All the source files in the project are recompiled. This may be necessary when the classpath entries have changed, for example, SDKs or libraries being used added, removed or altered
前面三段我还勉强能看懂,后边就看不下去了,接下来,我去搬运一点中文版的区别。
- Make Project:编译Project下所有Module,一般是自上次编译后Project下有更新的文件,不生成apk。
- Make Selected Modules:编译指定的Module,一般是自上次编译后Module下有更新的文件,不生成apk。
- Clean Project:删除之前编译后的编译文件,并重新编译整个Project,比较花费时间,不生成apk。
- Rebuild Project:先执行Clean操作,删除之前编译的编译文件和可执行文件,然后重新编译新的编译文件,不生成apk,这里效果其实跟Clean Project是一致的,这个不知道Google搞什么鬼~~
- Build APK:前面4个选项都是编译,没有生成apk文件,如果想生成apk,需要点击Build APK。
- Generate Signed APK:生成有签名的apk。
注意:
对于Clean和Rebuild看到最后的效果是一样的。
平时小的改动直接用Make Project就可以,可以看到只有它有快捷方式,表明这个功能要经常用。对于一些大的改动比如更新lib,大功能修改等,用Clean或Rebuild,毕竟这两个编译起来要费时间。
如果有的时候死活编译不过,多试试Clean吧,会有意想不到的效果!
这些东西看完之后我还是有点懵,但是比以前要清醒一点点,也许以后就会懂了吧。