简体   繁体   中英

Why I can't use a library in my Android project from Maven repository? How to write a correct pom.xml for this?

I want to use Jackson JSON parser library in my android project. I saw this library in Maven repository, but I don't know how to use it. I've downloaded sources from the Maven repository and Jackson jars and attached sources to jar, but in the logcat I saw error message NoClassDefFoundError. When googling I' ve read that I have to declare Jackson dependencies in pom.xml file.I' ma newbie in Java development so I don't know what all these means. And have some questions:

1.How to write pom.xml for the Jackson library

2.Where to put this pom.xml

3. Do I really need to install Maven if I just want to use the library.

4. What else I need to begin work with the library?

No, you do not need to write a pom file, unless you are using Maven for building (in which case you need it regardless of Jackson).

What you need are just Jackson jars -- there is more than one, since some projects only need some pieces. This page:

http://wiki.fasterxml.com/JacksonDownload

should show what you need, and where to get them from. If you are starting from scratch, I would strongly recommend using Jackson 2.1 (not 1.9). And then you most likely need 3 jars (jackson-annotations, jackson-databind, jackson-core) -- although minimal is just jackson-core , if you use so-called "streaming API" (low-level, highest performance, but more work).

The benefit of using Maven would be just that you can define logical depenendency (group and artifact id of jar), and Maven would resolve it to physical jar, as well as references to other jars.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM