user1526659
user1526659

Reputation:

Library import issues

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

Answers (2)

hellowell
hellowell

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

Mouna Cheikhna
Mouna Cheikhna

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 :

  1. Remove the libraries from the standard Java build path .

  2. Right click on the project name > Properties > Java Build Path >(tab) Libraries > remove everything except the “Android X.X” and the “Android Dependencies”

  3. 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".

  4. Clean the project

See here for more details.

Upvotes: 1

Related Questions