1. 程式人生 > >【studio】整理了下studio中make Project、clean Project、Rebuild Project的區別

【studio】整理了下studio中make Project、clean Project、Rebuild Project的區別

以前在用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中遇到問題,它自己彈出來,我才點的。

其他幾個就不說了。

下面進入重點。

我去網上搬運幾個關於它們的區別,先上stackOverFlow的:

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

前面三段我還勉強能看懂,後邊就看不下去了,接下來,我去搬運一點中文版的區別。

  1. Make Project:編譯Project下所有Module,一般是自上次編譯後Project下有更新的檔案,不生成apk。
  2. Make Selected Modules:編譯指定的Module,一般是自上次編譯後Module下有更新的檔案,不生成apk。
  3. Clean Project:刪除之前編譯後的編譯檔案,並重新編譯整個Project,比較花費時間,不生成apk。
  4. Rebuild Project:先執行Clean操作,刪除之前編譯的編譯檔案和可執行檔案,然後重新編譯新的編譯檔案,不生成apk,這裡效果其實跟Clean Project是一致的,這個不知道Google搞什麼鬼~~
  5. Build APK:前面4個選項都是編譯,沒有生成apk檔案,如果想生成apk,需要點選Build APK。
  6. Generate Signed APK:生成有簽名的apk。

注意:

對於Clean和Rebuild看到最後的效果是一樣的。
平時小的改動直接用Make Project就可以,可以看到只有它有快捷方式,表明這個功能要經常用。對於一些大的改動比如更新lib,大功能修改等,用Clean或Rebuild,畢竟這兩個編譯起來要費時間。
如果有的時候死活編譯不過,多試試Clean吧,會有意想不到的效果!

這些東西看完之後我還是有點懵,但是比以前要清醒一點點,也許以後就會懂了吧。

中文的