Interacting with the JacksonParser database and the main reason "found duplicate file for APK"?

I'm trying to learn how to use the jackson parser to get more efficient parsing of json data. I have these jar files: Downloaded from this page

jackson-core-2.2.0.jar jackson-annotations-2.2.0.jar jackson-databind-2.2.0.jar 

And in the code, I'm just trying to parse json into an array of objects:

 @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); String json = ReadFromRaw(this, R.raw.json); ArrayList<Category> categories = null; try { ObjectMapper mapper = new ObjectMapper(); categories = mapper.readValue(json, mapper.getTypeFactory().constructCollectionType(List.class, Category.class)); // categories = mapper.readValue(json, new TypeReference<List<Category>>() {}); } catch (Exception e) { Log.e("MainActivity", "Error: " + e.getMessage()); } SimpleListView myList = (SimpleListView) findViewById(R.id.myList); myList.setAdapterWithItems(GetAdapter(categories)); } 

Not sure if this is necessary, but here is my Category class:

 @JsonIgnoreProperties({ "DisplayPriority" }) public class Category { @JsonProperty("Id") private String categoryId; @JsonProperty("name") private String categoryName; public String getCategoryId() { return categoryId; } public void setCategoryId(String categoryId) { this.categoryId = categoryId; } public String getCategoryName() { return categoryName; } public void setCategoryName(String categoryName) { this.categoryName = categoryName; } } 

Everything looks fine, no errors or warnings. But when I try to compile, it gives this error:

 [2013-04-25 09:32:08 - Training - JacksonParser] Error generating final archive: Found duplicate file for APK: LICENSE Origin 1: C:\~\workspace\Training - JacksonParser\libs\jackson-core-2.2.0.jar Origin 2: C:\~\workspace\Training - JacksonParser\libs\jackson-databind-2.2.0.jar 

As I look for this error in google, it says that there is some class in these jar files. And I don’t know how to do it ... Is there something that I am doing wrong? Or am I missing something?

Thanks in advance, any help is appreciated.

+7
source share
4 answers

I have the same problem. So, I am using the old version.

jackson-core-asl-1.9.12.jar

Jackson Mapper-ASL-1.9.12.jar

You can download from "Latest stable version 1.x" on the same page.

+2
source

This issue has been reported for version 2.2.0, see this issue ; but must be resolved in 2.2.1.

EDIT: it turns out that the main problem is that these files should be located under META-INF/ in the jar; if so, there is no conflict. And this is what 2.2.1 will do when it is released.

+12
source

Kind of pain, but it’s not so bad to rebuild the cans manually.

 git clone git://github.com/FasterXML/jackson-core.git git clone git://github.com/FasterXML/jackson-databind.git cd jackson-core git checkout jackson-core-2.2.0b # not sure what the "b" is about mv src/main/resources/NOTICE src/main/resources/META-INF/ mv src/main/resources/LICENSE src/main/resources/META-INF/ mvn install # jar will be at target/jackson-core-2.2.0.jar cd ../jackson-databind git checkout jackson-databind-2.2.0 mv src/main/resources/NOTICE src/main/resources/META-INF/ mv src/main/resources/LICENSE src/main/resources/META-INF/ mvn install # jar will be at target/jackson-databind-2.2.0.jar 

Le sigh. Such a pain.

EDIT . Turns out you need annotations for most things. This exercise remains for the reader. I also found that you can download jars for the new (fixed) version on Maven .

+3
source

As Steve says in his latest edition, you can download the latest jars from Maven: http://repo1.maven.org/maven2/com/fasterxml/jackson/core/

+2
source

All Articles