NoClassDefFoundError JsonAutoDetect while parsing JSON object
For those who come here in the future, the answer is:
If you've only copied jackson core
and jackson databind
, you need jackson annotations
to use the ObjectMapper
.
For example, make sure you have something like this:
[16:32:01]:/android-project/libs master]$ ls -lAF
total 2112
-rw-r--r--@ 1 jeffamaphone staff 33525 Jun 18 16:06 jackson-annotations-2.0.2.jar
-rw-r--r--@ 1 jeffamaphone staff 193693 Jun 7 16:42 jackson-core-2.0.2.jar
-rw-r--r--@ 1 jeffamaphone staff 847121 Jun 18 15:22 jackson-databind-2.0.2.jar
To expand on @jeffamaphone's excellent answer, for maven users
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.7.3</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.7.3</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.7.3</version>
</dependency>
Or the following gradle configuration:
compile 'com.fasterxml.jackson.core:jackson-core:2.2.2'
compile 'com.fasterxml.jackson.core:jackson-databind:2.2.2'
compile 'com.fasterxml.jackson.core:jackson-annotations:2.2.2'