Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
599 views
in Technique[技术] by (71.8m points)

performance - Android compilation is slow (using Eclipse)

When I change any .java file and build, the compilation takes 16 seconds. I don't understand why it should be so slow!?

I enabled verbose output for Andoroid.

Window > Preferences > Android > Build output > Verbose.

The result output (Console > Android) is:

[19:46:10] Refreshing resource folders.
[19:46:10] Starting incremental Pre Compiler: Checking resource changes.
[19:46:10] Nothing to pre compile!
[19:46:10] Starting incremental Package build: Checking resource changes.
[19:46:10] ignored resource ...in.classes.dex
[19:46:10] processing ...A.class
[19:46:10] processing ...B.class
    ...
[19:46:21] processing com/google/inject/util/Providers.class...
[19:46:21] processing com/google/inject/util/Types.class...
[19:46:24] Using default debug key to sign package
[19:46:24] Packaging ...in
esources.ap_
[19:46:24] Packaging classes.dex
    ...
[19:46:25] Packaging ...annotations.jar
[19:46:25] Build Success!
[19:46:25] Refreshing resource folders.
[19:46:25] Starting incremental Pre Compiler: Checking resource changes.
[19:46:26] Nothing to pre compile!

The "processing" of .class files took 14 seconds. And it "processed" all files, even from all .jar files linked. I think some thing wrong goes here, as only one .java file was changed.

What can I do to improve the compilation speed?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I think there's a misunderstanding here. As you say, only the modified classes are recompiled (by Eclipse in a matter of milliseconds); after that, however, the ADT plugin takes every compiled class and translates it into Dalvik's bytecode format via the dx tool. The output of this process is a single file, classes.dex, which contains all the classes in your application, including the ones coming from referenced libraries. This last "translation" step is the one that takes longer because it's really poorly optimized: the ADT plugin doesn't cache anything, it just retranslates every class at every build (and it's painfully slow). For medium to big projects this gets really frustrating... I hope Google will improve that in a future ADT/SDK release.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...