Reputation: 118
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.
The changes were parameterless contructors and change the WorkIem class to static.
Here is the stacktrace:
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)**
This is line 35:
UpdateReport report = new Gson().fromJson(jsonStr, UpdateReport.class);
The json-String looks like this (Workitems can be null):
{"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}
And finally here is my UpdateReport class with the innerClass:
public class UpdaterObject{
public class UpdateReport {
public boolean IsOffline;
public boolean DoUpdate;
public boolean ShowQuestionDialog;
public List<WorkItem> WorkItems;
public UpdateReport() { }
public UpdateReport(boolean isoffline, boolean doUpdate,
List<WorkItem> 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
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!
This is my first posting on StackOverFlow. Please be fair. :)
Thanks qd0r
Upvotes: 3
Views: 1484
Reputation: 149
In my case proguard was the problem. Disable proguard or put your model in proguard rules file. Worked for me.
Upvotes: 0
Reputation: 40595
From Gson issue 255, The HTC Desire HD included an obsolete copy of Gson in its application classpath. That issue has instructions on using jarjar to repackage your version of Gson as to not conflict with the preinstalled version.
Upvotes: 7