Skip to content Skip to sidebar Skip to footer

Java.lang.NoClassDefFoundError: Com.google.gson.Gson

I am new on Android Development environment so need help from the experts. java.lang.NoClassDefFoundError: com.google.gson.Gson Gson library included in project but when calling G

Solution 1:

Here are a couple of reasons that this could be happening:

a) The library jar file is not being included

b) The wrong version of the jar file is being included

c) (if you are using maven) Another jar file is pulling in a newer/different version of the jar file

d) Your class path does not include the jar file.

A good starting point is to open the library jar file and see if you can actually see the class file in it. If you are using maven then you should view the dependency tree to see if there are any conflicts using:

mvn dependency:tree -Dverbose

Solution 2:

  1. Down load the latest version of gason.jar
  2. Add the jar of gason to the project[Eclipse: project proprieties => Java Build Path => Libraries =>Add External JARs]
  3. check the gason.jar in Order and Export


Solution 3:

This worked for me

java -cp gson.jar: JavaClassFile

Notice the : after gson.jar.


Solution 4:

put the jar file in web-inf/lib,not the lib


Solution 5:

A couple of reasons for the issue:

  1. .aar Library: if the code involving Gson is in a .aar that is included in an application project as a library; in this case, the application should also add gson as a dependency

reason: .aar libs do not propagate dependencies transitively

  1. proguard: wrong proguard rules required by gson, correct rules can be found here

Post a Comment for "Java.lang.NoClassDefFoundError: Com.google.gson.Gson"