1

I'm using Google Cloud Endpoints in Android.
And these libs in gradle

implementation 'com.google.api-client:google-api-client-android:1.23.0'

Which include Jackson2.

I know how to write and read JSON from files using jackson. But problem is that I'm not able to create ObjectMapper It show error.

Can not resolve symbol 

Any ideas what the problem is? Please don't ask me to add jackson lib again, because if it is already in Google client libs, why do I add this?

Zoe
  • 27,060
  • 21
  • 118
  • 148

1 Answers1

1

Try to import directly jackson in your build.gradle! Currently they are at v-2.9.5

implementation 'com.fasterxml.jackson.core:jackson-core:2.9.5'
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.9.5'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.9.5'

Anyway you can refer to this guide https://developers.google.com/api-client-library/java/google-api-java-client/setup.

Reading this documentation it seems that you have to import jar files in your libs folder to prevent NoClassDefFoundError!

Or you can add this in your gradle:

compile group: 'com.google.api-client', name: 'google-api-client-jackson2', version: '1.23.0'

Official doc: Android

If you are developing for Android, and the Google API you want to use is included in the Google Play Services library, use the Google Play Services library for the best performance and experience.

If you are using the Google API Client Library for Java with Android, it is important to know which dependencies are compatible with Android, specifically which Android SDK level. Android applications require the following jar files, or newer compatible versions, from the libs folder:

google-api-client-1.23.0.jar
google-api-client-android-1.23.0.jar
google-oauth-client-1.23.0.jar
google-http-client-1.23.0.jar
google-http-client-android-1.23.0.jar
gson-2.1.jar
jackson-core-asl-1.9.11.jar
jackson-core-2.1.3.jar
jsr305-1.3.9.jar
protobuf-java-2.4.1.jar

Warning: For Android, you MUST place the .jar files in a directory named "libs" so that the APK packager can find them. Otherwise, you will get a NoClassDefFoundError error at runtime.

Roberto Manfreda
  • 2,345
  • 3
  • 25
  • 39