Ants and JARs
You have two choices for integrating third‑party code into your project: use source code or use pre‑packaged JARs.
If you choose to use the third‑party source code, all you need to do is copy it into your own source tree (under in your project) so it can sit alongside your existing code, then let the compiler perform its magic.
If you choose to use an existing JAR, perhaps one for which you do not have the source code, you will need to teach your build chain how to use the JAR. If you are using an IDE, that’s a matter of telling it to reference the JAR. If, on the other hand, you are not using an IDE and are relying upon the Ant script, put the JAR in the directory created for you by , and the Ant build process will pick it up.
For example, in a previous draft of this book, we had a MailBuzz project. MailBuzz, as the name suggests, dealt with email. It leveraged the JavaMail APIs and needed two JavaMail JARs: and . With both of those in the directory, the told to link against those JARs, so any JavaMail references in the MailBuzz code could be correctly resolved. Then, those JARs were listed, along with the MailBuzz compiled classes, in the task that invokes the tool to convert the Java code into Dalvik VM instructions. Without this step, even though your code may compile, it won’t find the JavaMail classes at runtime and will fail with an exception.
As it turned out, though, the Dalvik VM and compiler supplied with the Android 0.9 and newer SDKs no longer supported some Java language features used by JavaMail. And, while the JavaMail source code is available, it is under an open‑source license (Common Development and Distribution License; CDDL) that… has issues.
Дата добавления: 2015-05-16; просмотров: 720;