如以下的代码,运行后报java.lang.StackOverflowError错误:
MusicSavedInfo musicSavedInfo=new MusicSavedInfo(currentStartTime,openOrCloseFlag,currentDayFlags,currentSelectMusicTitle,currentSelectMusicPath,"1"); String jsonData=gson.toJson(musicSavedInfo);我手机4.1的系统,运行正常不会报错;到4.4的系统上就报以下的错误
06-25 20:31:50.092: E/AndroidRuntime(25122): java.lang.StackOverflowError 06-25 20:31:50.092: E/AndroidRuntime(25122): at com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:380) 06-25 20:31:50.092: E/AndroidRuntime(25122): at com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:375) 06-25 20:31:50.092: E/AndroidRuntime(25122): at com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:380) 06-25 20:31:50.092: E/AndroidRuntime(25122): at com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:375) 06-25 20:31:50.092: E/AndroidRuntime(25122): at com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:380) 06-25 20:31:50.092: E/AndroidRuntime(25122): at com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:375)最后把gson-2.1.jar换成gson-1.7.1.jar。即4.4系统也能运行通过。尽管一时不知道为什么,但算是攻克了。
gson-1.7.1.jar包下载地址:gson-1.7.1.jar