qwerty
qwerty

Reputation: 23

GSON error in HTC Explorer

Currently I'm working in a project which is using GSON Library. The problems occurs when I run my application in HTC explorer. The GSON class constructor generate the follow exception:

No-args constructor for class does not exist. Register an InstanceCreator with Gson for this type to fix this problem.

I've tested the application in a lot of devices. In fact the application has a lot of downloads, and any one of them has any crash like this.

Any ideas? I've seen some other post but I couldn't fixed the bug.

Thanks in advance.

Upvotes: 2

Views: 452

Answers (1)

Adil Bhatty
Adil Bhatty

Reputation: 17340

  1. Download jarjar
  2. Put jarjar-1.0.jar and gson-1.5.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 commandline, open jarjar with the command "java -jar jarjar.jar process rules.txt gson-1.5.jar myjson-1.5.jar"
  6. Replace the gson library in your project with myjson and update the imports

Don't use the GSON jar file, use the new myjson. Ans also make sure the library is selected in Order and Export (Project Properties -> Java Build Path -> Order and Export).

Hope it helps.

Upvotes: 7

Related Questions