Friday, 11 May 2012

Android(Java) - gson\json deserialization error

Android Blog With example



Hello Friends,
 
     I found a strange issue in android application , My application is running 
     Fine but in few of the device(like:HTC Explorer, HTC Desire.....) its gives  
     parsing error.....
            
           JsonParseException: The JsonDeserializer com.google.gson.  
           DefaultTypeAdapters$CollectionTypeAdapter@4e76fba0 failed to
            deserialize ...
                
   After doing a lot of investigation  , Here are the steps which I follow to fixed 
   this issue:
    1) Download jarjar (http://code.google.com/p/jarjar/downloads/list)
    2) Put jarjar-1.3.jar and gson-2.1.jar in the same folder
    3) Create a new text file in this folder (rules.txt)
    4) Write the following line in the textfile:     
         rule com.google.gson.** com.google.myjson.@1
 
   5) From the command line, go in to the folder where you placed 
        jarjar-1.3.jar and gson-2.1.jar and run the following 
        command:
      "java -jar jarjar.jar process rules.txt gson-2.1.jar myjson-2.1.jar"  
 
  6) Replace the gson library in your project with myjson and
      update the imports.
  
  Hope this will helps you!
  cheers! :)
  Happy coding....... 
 



Mukesh Yadav

Hi Guys I am from Delhi working as Web/Mobile Application Developer(Android Developer), also have knowledge of Roboelctric and Mockito ,android test driven development... Blogging has been my passion and I think blogging is one of the powerful medium to share knowledge and ideas....

2 comments:

  1. great it's working fine !
    i looking for that code thanx to you.

    ReplyDelete

 

Copyright @ 2013 Android Developer Blog.

Blog Widget by LinkWithin