Showing posts with label gson error android. Show all posts
Showing posts with label gson error android. Show all posts

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



 

Copyright @ 2013 Android Developers Blog.