仅在设备HTC Desire HD A9191上出现Gson错误

时间:2012-08-22 08:42:36

标签: json exception gson android

我使用以下代码将我的Json字符串转换为object:

Gson gson = new Gson();             
EntPocketPCDataCollection entPocketPCDataCollection = gson
            .fromJson(strJson,
            EntPocketPCDataCollection.class);

我有这些课程:

public class EntPocketPCDataCollection extends ArrayList<EntPocketPCData> {

    private static final long serialVersionUID = 1L;

}

public class EntPocketPCData {

    private String strFormat = "Can not convert %s to %s value for column %s";

    public String Command;
    public EntColumn[] Columns;
    public List<List<String>> RowsList;
    public String TypeName;
}

这些代码可以在Emulator,Asus平板电脑,Galaxy note,galaxy s和HTC Sensation上运行,没有任何错误。但是我只在具有Android 2.2的HTC Desire HD A9191设备上出现以下错误。

为什么?

com.google.gson.JsonParseException: The JsonDeserializer com.google.gson.DefaultTypeAdapters$CollectionTypeAdapter@47751a08  
failed to deserialized json object [{"Command":"Insert","Columns":[{"Name":"Id","Type":"System.Int32"}, 
{"Name":"Caption","Type":"System.String"},{"Name":"Category","Type":"System.String"}, 
{"Name":"DefaultValue","Type":"System.String"},{"Name":"Description","Type":"System.String"}, 
{"Name":"Name","Type":"System.String"},{"Name":"Val1","Type":"System.String"},{"Name":"Val2","Type":"System.String"}, 
{"Name":"Val3","Type":"System.String"},{"Name":"Val4","Type":"System.String"},{"Name":"ValDesc1","Type":"System.String"}, 
{"Name":"ValDesc2","Type":"System.String"},{"Name":"ValDesc3","Type":"System.String"}, 
{"Name":"ValDesc4","Type":"System.String"},{"Name":"Visible","Type":"System.String"}, 
{"Name":"order","Type":"System.Int32"}],"RowsList":[[7,"تعداد رقم اعشار","Common","0","تعداد رقم  
اعشار","Common_DecimalDigits","","","","","","","","","false",1],[8,"فلدر مستندات برنامه","Common","","مستندات و عکس هاي  
دريافتي از وب سرويس در اين فلدر ذخيره مي شود","Common_DocumentsFolder","","","","","","","","","false",1],[9,"بازه زماني همسان سازي  
سريع","DataExchange","-1","بازه زماني همسان سازي سريع","DataExchange_SyncPartial_Interval","","","","","","","","","false",1], 
[10,"بازه زماني همسان سازي کامل","DataExchange","-1","بازه زماني همسان سازي  
کامل","DataExchange_SyncFull_Interval","","","","","","","","","false",1],[11,"بازه زماني ارسال سفارشات","DataExchange","2","بازه  
زماني ارسال سفارشات","DataExchange_Send_Interval","","","","","","","","","false",1],[12,"آدرس وب سرويس  
شرکت","WebService","http://test/MobileService/Service.asmx","آدرس وب سرويس داخلي شرکت جهت تبادل اطلاعات با  
سرور","WebService_URL","","","","","","","","","false",1],[13,"آدرس وب سرويس  
","WebService","http://test/Service.asmx","آدرس وب سرويس  جهت دريافت  
قفل","WebService_URL","","","","","","","","","false",1],[15,"شماره سرور","SMS","","شماره  
سرور","SMS_Server_NO","","","","","","","","","false",1],[17,"ارسال پيامک","SMS","0","نحوه ارسال  
پيامک","SMS_SendingOption","0","1","2","","عدم ارسال پيامک","ارسال پيامک با سوال از کاربر","ارسال پيامک بدون سوال از کاربر","","false",1], 
[18,"بازه زماني دريافت مکان جاري کاربر","GPS","2","بازه زماني دريافت مکان جاري کاربر","GPS_Interval","","","","","","","","","false",1], 
[19,"وضعيت مکان يابي","GPS","1","وضعيت مکان يابي","GPS_StartOption","0","1","2","","خاموش","روشن","روشن در غير اينصورت خروج از  
برنامه","","false",1],[20,"نحوه ارسال پيامک جي پي اس","GPS","false","هنگام ارسال پيامک درخواست اگر اين مقدار فعال باشد، چهار نقطه آخر دريافتي نيز با  
پيامک ارسال مي شود","GPS_SendSms","","","","","","","","","false",1],[21,"بازه ارسال پيامک جي پي اس","GPS","-1","اگر تنظيمات ارسال پيامک  
جي پي اس فعال باشد بازه زماني ارسال پيامک بر حسب دقيقه را مشخص مي کند","GPS_SmsInterval","","","","","","","","","false",1],[24,"نام کاربري  
فعالسازي ","Security","1","نام کاربري فعالسازي ","Security_UserName","","","","","","","","","false",1],[25,"کلمه عبور  
فعالسازي ","Security","","کلمه عبور فعالسازي ","Security_Password","","","","","","","","","false",1],[26,"مشخصه شرکت دوره  
مالي","Common","2012","مشخصه شرکت دوره مالي","Common_ScuCmpyDurID","","","","","","","","","false",1],[27,"مشخصه عمليات ثبت  
سفارش","Common","3","مشخصه عمليات ثبت سفارش","Common_InvOperationIDOrder","","","","","","","","","false",1],[28,"مشخصه  
عمليات اعلام برگشتي","Common","53","مشخصه عمليات اعلام برگشتي","Common_InvOperationIDBack","","","","","","","","","false",1], 
[29,"مشخصه مرکز هزينه","Common","10","مشخصه مرکز هزينه","Common_TotCostCenterID","","","","","","","","","false",1],[30," 
مشخصه ويزيتور","Common","8","مشخصه ويزيتور","Common_HrsEmployeeID","","","","","","","","","false",1],[32,"مقدار تعيين کننده فعال  
بودن برنامه توسط شرکت محلي","Security","true","مقدار تعيين کننده فعال بودن برنامه توسط شرکت  
محلي","Security_ActivationCompany","","","","","","","","","false",1],[33,"فعال بودن پروتکل پرينتر","Printer","false","فعال بودن پروتکل  
پرينتر","Printer_Protocol","","","","","","","","","true",1],[34,"نام پرينتر","Printer","","نام  
پرينتر","Printer_Name","","","","","","","","","true",1],[36,"آخرين شماره سريال ثبت شده سندها","Common","5","آخرين شماره سريال ثبت شده  
سندها","Common_Serial","","","","","","","","","false",1],[37,"آدرس سرور اف تي پي جهت دريافت فايلها","Ftp","ftp://1.2.3.4","آدرس سرور  
اف تي پي جهت دريافت فايلها","Ftp_URL","","","","","","","","","false",1],[38,"نام کاربر سرور اف تي پي","Security","ftpuser","نام کاربر  
سرور اف تي پي","Security_FtpUserName","","","","","","","","","false",1],[39,"رمز عبور سرور اف تي پي","Security","Symbian1","رمز  
عبور سرور اف تي پي","Security_FtpPassword","","","","","","","","","false",1],[40,"آدرس وب سرويس دريافت  
نقاط","WebService","http://test/MobileService/Service.asmx","آدرس وب سرويس دريافت موقعيت  
ويزيتور","WebService_GpsPointsURL","","","","","","","","","false",1],[41,"آدرس داخلي وب  
سرويس","WebService","http://test/MobileService/Service.asmx","آدرس داخلي وب  
سرويس","WebService_LanURL","","","","","","","","","false",1],[42,"کنترل نمايش موجودي","Common","true","کنترل نمايش  
موجودي","Common_ShowStockQty","","","","","","","","","false",1],[43,"فيلتر کردن مشتري ها بر اساس فاصله","Common","false","مشترياني  
که در فاصله مشخصي از ويزيتور هستند نشان داده مي شوند","Common_FilterNearCustomers","","","","","","","","","false",1],[44,"نمايش مشتريان  
اطراف در اين فاصله به متر","Common","50","فقط مشترياني که در اين فاصله از ويزيتور هستند نمايش داده مي  
شوند","Common_NearCustomersDistance","","","","","","","","","false",1],[45,"نمايش اعتبارسنجي مشتري","Common","true","اطلاعات  
اعتبارسنجي و صورت وضعيت مشتري نمايش داده مي  
شود","Common_ShowCustomerCredit","","","","","","","","","false",1]],"TypeName":"EntPreferences"}] given the type class  
org.order.dataModel.transferTools.EntPocketPCDataCollection

1 个答案:

答案 0 :(得分:1)

我们曾经在Desire HD上遇到过Gson的问题,因为我们的应用程序中嵌入的gson.jar文件并没有在运行时使用,而是HTC附带ROM的过时版本。我想,你有类似的问题。一种可能的解决方法可能是使用jarjar(http://code.google.com/p/jarjar/)来确保您的应用程序使用您的gson jar。

修改 这里最常见的问题是:GSON + HTC Desire: Conflict. Possible solution jarjar.jar causes error