I'm using Retrofit and Gson in order to upload a custom objects list to the server. I didn't have any problem to do it: tested with Mororola, Asus, and many other devices. Never a problem! Now I'm working with a Zebra smartphone, an industrial one, and I'm getting my app almost always crash during the creation of the JSON (I've logged that the app was writing the JSON before crashing). I'm checking the data with TypeAdapter
s so it shouldn't be a problem of data values. This is the log:
D/dalvikvm: JIT unchain all for threadid=13
W/dalvikvm: threadid=15: spin on suspend #1 threadid=13 (pcf=0)
W/dalvikvm: threadid=15: spin on suspend #2 threadid=13 (pcf=0)
I/dalvikvm: "Retrofit-Idle" prio=5 tid=15 RUNNABLE JIT
I/dalvikvm: | group="main" sCount=0 dsCount=0 obj=0x41d52cc8 self=0x6065ec38
I/dalvikvm: | sysTid=14452 nice=10 sched=0/0 cgrp=apps/bg_non_interactive handle=1599766536
I/dalvikvm: | state=R schedstat=( 0 0 0 ) utm=9 stm=2 core=0
I/dalvikvm: at java.lang.AbstractStringBuilder.enlargeBuffer(AbstractStringBuilder.java:~94)
I/dalvikvm: at java.lang.AbstractStringBuilder.append0(AbstractStringBuilder.java:145)
I/dalvikvm: at java.lang.StringBuffer.append(StringBuffer.java:219)
I/dalvikvm: at java.io.StringWriter.write(StringWriter.java:167)
I/dalvikvm: at com.google.gson.stream.JsonWriter.string(JsonWriter.java:570)
I/dalvikvm: at com.google.gson.stream.JsonWriter.value(JsonWriter.java:419)
I/dalvikvm: at my.company.app.rest.RestClient$1.write(RestClient.java:197)
I/dalvikvm: at my.company.app.rest.RestClient$1.write(RestClient.java:165)
I/dalvikvm: at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:68)
I/dalvikvm: at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.write(ReflectiveTypeAdapterFactory.java:113)
I/dalvikvm: at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.write(ReflectiveTypeAdapterFactory.java:240)
I/dalvikvm: at com.google.gson.internal.bind.ObjectTypeAdapter.write(ObjectTypeAdapter.java:107)
I/dalvikvm: at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:68)
I/dalvikvm: at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.write(CollectionTypeAdapterFactory.java:96)
I/dalvikvm: at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.write(CollectionTypeAdapterFactory.java:60)
I/dalvikvm: at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:68)
I/dalvikvm: at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.write(ReflectiveTypeAdapterFactory.java:113)
I/dalvikvm: at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.write(ReflectiveTypeAdapterFactory.java:240)
I/dalvikvm: at com.google.gson.Gson.toJson(Gson.java:605)
I/dalvikvm: at com.google.gson.Gson.toJson(Gson.java:584)
I/dalvikvm: at com.google.gson.Gson.toJson(Gson.java:539)
I/dalvikvm: at com.google.gson.Gson.toJson(Gson.java:519)
I/dalvikvm: at retrofit.converter.GsonConverter.toBody(GsonConverter.java:80)
I/dalvikvm: at retrofit.RequestBuilder.setArguments(RequestBuilder.java:375)
I/dalvikvm: at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:298)
I/dalvikvm: at retrofit.RestAdapter$RestHandler.access$100(RestAdapter.java:220)
I/dalvikvm: at retrofit.RestAdapter$RestHandler$2.obtainResponse(RestAdapter.java:278)
I/dalvikvm: at retrofit.CallbackRunnable.run(CallbackRunnable.java:42)
I/dalvikvm: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
I/dalvikvm: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
I/dalvikvm: at retrofit.Platform$Android$2$1.run(Platform.java:142)
I/dalvikvm: at java.lang.Thread.run(Thread.java:841)
I worked on it for days with no concrete result: could it be a memory problem? (I tested the app with older devices with less memory and I hadn't the problem.)
Thank you very much!
UPDATE
Can it be the Dalvik? I make the upload of a list of objects, splitting it in multiple json and post call using a while(boolean) to wait that the transmission completes before make the next one. Looking on the net I've found that the vendor-modified dalvik could be the "killer", not letting the thread wait in loop.....see this answer https://stackoverflow.com/a/20804679/2306946