I wanted to use gson in my android project so I followed a tutorial and done this
- Create a new folder, libs, in your Eclipse/Android project.
- Right-click libs and choose Import -> General -> File System, then
Next, Browse in the filesystem to find the library’s parent
directory (i.e.: where you downloaded it to). - Click OK, then click the directory name (not the checkbox) in the
left pane, then check the relevant JAR in the right pane. This puts
the library into your project (physically). - Right-click on your project, choose Build Path -> Configure Build
Path, then click the Libraries tab, then Add JARs…, navigate to
your new JAR in the libs directory and add it. (This, incidentally,
is the moment at which your new JAR is converted for use on
Android.)
it worked perfectly in android 2.2 but with android 4.0.3 it is throwing an exception
05-06 19:12:18.946: E/AndroidRuntime(602): java.lang.NoClassDefFoundError: com.google.gson.Gson
With android 4, it is important the folder is called libs and not lib or something else, else it will not work.