*WHY* can't android library projects be launched?
I know that Eclipse will not allow a library to b开发者_如何学Pythone run, but that seems like an unnecessary and unfortunate restriction to me. I sometimes make derivative projects that extend some basic one and I don't see why I should have to factor out a shared library project to do that.
Even if I wanted only one app using one library, I would still love to make that library able to run a simple, self-contained test program showing how it is expected to be used. That also serves as a good sanity test for the library. I've done this in Java Swing libraries for years and it works beautifully so I don't understand the restriction here. If Eclipse were better at knowing when to rebuild shared libraries, this might not be so painful, but as it is, I really have a dilemma when needing to maintain shared libraries.
Should this be viewed as an Android bug, an Eclipse bug, or just an unfortunate side-effect of the two? Regardless, have others faced this problem, and if so, how did you deal with it.
I know that Eclipse will not allow a library to be run, but that seems like an unnecessary and unfortunate restriction to me.
It is not an Eclipse restriction. Android library projects are not Android applications, and therefore cannot be run, whether from Eclipse or the command line.
I would still love to make that library able to run a simple, self-contained test program showing how it is expected to be used.
You can do what I do and create a demo/
sub-project that serves as the sample. Moreover, this helps ensure that your sample really uses the library the way that other projects would use the library.
That also serves as a good sanity test for the library.
No, it would not, because it would not use the library the way that other projects would use the library. Similarly, the sample app for a Swing JAR should not be in the Swing JAR itself, because it serves as an inadequate test of the JAR (not to mention that it bloats the JAR for production use).
Should this be viewed as an Android bug, an Eclipse bug, or just an unfortunate side-effect of the two?
IMHO, none of the above. I view it as helping to enforce a good programming practice: keeping your test/sample code and your production code separated.
精彩评论