Why do I get so many errors building my Android project with Ant?
Now that I sort of know my way around the SDK/API, I've switched from Eclipse back to my favorite text editor, which means I have to use ant to build my project, however:
It seems every other time I compile the project, a lot of drawables get corrupted, resources lose their ids (resulting in NPEs in the code), or classes throw "Verify Errors".
The only way to fix this is by removing the bin
and gen
folders, and recompiling, which is 开发者_如何学Pythonobviously annoying.
Is there any way to avoid this?
btw, I'm using ant 1.7.1, java version "1.6.0_20"
It seems every other time I compile the project, a lot of drawables get corrupted, resources lose their ids (resulting in NPEs in the code), or classes throw "Verify Errors".
Resources "lose their IDs" is relatively common, when you change something about the roster of resources (add one, remove one, etc.). You might consider adding an Ant target that does a clean
before your debug
/install
.
I have never seen classes randomly throw "Verify Errors". That occurs when compiled classes try referring to missing stuff, so you might get this when you first try to use a third-party JAR, for example. The only reason I can figure it might occur for you is if you are frequently refactoring your code or something. But I have developed a metric buttload of code using Ant and have never encountered this for any of my own code.
The Ant scripts and associated binaries could use a little work in terms of detecting changes, which is the root of both of these problems.
精彩评论