Reputation:
I've copied my work-project and setup app at home. I'm using Gson and it's located in /lib folder and referenced as library. However, during the runtime the Gson object couldn't be instantiated and console gave me the following
04-13 01:47:50.948: E/AndroidRuntime(386): FATAL EXCEPTION: main
04-13 01:47:50.948: E/AndroidRuntime(386): java.lang.NoClassDefFoundError: com.google.gson.Gson
Any suggestions, please?
ps I'm using Eclipse and I've already tried "clean"ing the project, resetting Gson library as a referenced.
Upvotes: 1
Views: 818
Reputation: 11
I have had a bad experience with this. I thought it was because the older version of android does not support Gson. However, once I copied out the whole project and changed the "target build" to the same version, it runs okay.
Then when I went back to the old copy and check the property>Java Build Path>(tab) Libraries
, I found there was no "Android Dependencies".
It must be there for Eclipse!!
Upvotes: 0
Reputation: 39638
Make sure you are adding gson jar as an under android dependency
and not Referenced Libraries
in Properties -> Java Build Path.
If that doesnt work do these steps :
Remove the libraries from the standard Java build path .
Right click on the project name > Properties > Java Build Path >(tab) Libraries > remove everything except the “Android X.X” and the “Android Dependencies”
Rename the libraries folder from “lib” to “libs”
By doing that, all the libraries in the folder "libs" are found by the Android plugin and are added to the "Android Dependencies".
Clean the project
See here for more details.
Upvotes: 1