Note that there are some explanatory texts on larger screens.

plurals
  1. POGson Exception on deserialize (no-args constructor does not exist)
    primarykey
    data
    text
    <p>I've got a problem which occurs only in 10 of 5000 devices. There is no possibility to reproduce it with my emulators and test devices. It seems to be a very specific problem with only a few devices. All I've got is the stacktrace and my code. So I'm developing against a black hole and only after I released the new version at GooglePlay I see if the changes solved the problem. I just updated a new version to GooglePlay, but the error still exists. </p> <p>The changes were parameterless contructors and change the WorkIem <a href="https://stackoverflow.com/questions/5148011/android-and-gson-throwing-no-args-constructor-not-found-exception">class to static</a>.</p> <p>Here is the stacktrace:</p> <pre><code>W 6758/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x401a15a0) E 6758/AndroidRuntime: FATAL EXCEPTION: main **Caused by: java.lang.RuntimeException: No-args constructor for class com.mypackage.model.UpdaterObject$UpdateReport does not exist. Register an InstanceCreator with Gson for this type to fix this problem.** at com.google.gson.MappedObjectConstructor.constructWithNoArgConstructor(MappedObjectConstructor.java:64) at com.google.gson.MappedObjectConstructor.construct(MappedObjectConstructor.java:53) at com.google.gson.JsonObjectDeserializationVisitor.constructTarget(JsonObjectDeserializationVisitor.java:40) at com.google.gson.JsonDeserializationVisitor.getTarget(JsonDeserializationVisitor.java:56) at com.google.gson.ObjectNavigator.accept(ObjectNavigator.java:109) at com.google.gson.JsonDeserializationContextDefault.fromJsonObject(JsonDeserializationContextDefault.java:73) at com.google.gson.JsonDeserializationContextDefault.deserialize(JsonDeserializationContextDefault.java:51) at com.google.gson.Gson.fromJson(Gson.java:568) at com.google.gson.Gson.fromJson(Gson.java:515) at com.google.gson.Gson.fromJson(Gson.java:484) at com.google.gson.Gson.fromJson(Gson.java:434) at com.google.gson.Gson.fromJson(Gson.java:406) **at de.fliese.NewVersionCheckerActivity.onCreate(NewVersionCheckerActivity.java:35)** </code></pre> <p>This is line 35:</p> <pre><code>UpdateReport report = new Gson().fromJson(jsonStr, UpdateReport.class); </code></pre> <p>The json-String looks like this (Workitems can be null): </p> <pre><code>{"WorkItems": [{"Url":"http://url1.comfoo.zip","TypeId":1,"LastModifiedServer":1352598239000}, {"Url":"http://url2.com/bar.zip","TypeId":4,"LastModifiedServer":1352598265000}], "ShowQuestionDialog":false,"IsOffline":false,"DoUpdate":true} </code></pre> <p>And finally here is my UpdateReport class with the innerClass:</p> <pre><code>public class UpdaterObject{ public class UpdateReport { public boolean IsOffline; public boolean DoUpdate; public boolean ShowQuestionDialog; public List&lt;WorkItem&gt; WorkItems; public UpdateReport() { } public UpdateReport(boolean isoffline, boolean doUpdate, List&lt;WorkItem&gt; workitems) { IsOffline = isoffline; DoUpdate = doUpdate; WorkItems = workitems; } } public static class WorkItem { public int TypeId; public String Url; public long LastModifiedServer; public WorkItem() { } public WorkItem(int typeId, String url, long lastModifiedServer) { TypeId = typeId; Url = url; LastModifiedServer = lastModifiedServer; } } //some methods [....] } //end class UpdaterObject </code></pre> <p>I would be happy, if someone could help me. Please make sure and be sure that your answer ist absolutely correct, because I can't test it! That would be great! </p> <p>This is my first posting on StackOverFlow. Please be fair. :) </p> <p>Thanks qd0r</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload