Reputation: 117
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 Gson from a method inside the project getting the error like ths
Upvotes: 7
Views: 42831
Reputation: 400
This worked for me
java -cp gson.jar: JavaClassFile
Notice the :
after gson.jar
.
Upvotes: 1
Reputation: 41
A couple of reasons for the issue:
reason: .aar libs do not propagate dependencies transitively
Upvotes: 0
Reputation: 459
Upvotes: 4
Reputation: 451
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
Upvotes: 12