Android executes gson. toJson (object) and reports java. lang. StackOverflowError, gson. tojson

Source: Internet
Author: User
Tags tojson

Android executes gson. toJson (object) and reports java. lang. StackOverflowError, gson. tojson

The following code reports a java. lang. StackOverflowError after execution:

MusicSavedInfo musicSavedInfo=new MusicSavedInfo(currentStartTime,openOrCloseFlag,currentDayFlags,currentSelectMusicTitle,currentSelectMusicPath,"1");String jsonData=gson.toJson(musicSavedInfo);
In my mobile phone 4.1 system, the following error will not be reported if the operation is normal; In the 4.4 system, the following error will be reported.

06-25 20:31:50.092: E/AndroidRuntime(25122): java.lang.StackOverflowError06-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)
Finally, the gson-2.1.jar into the gson-1.7.1.jar, that is, the 4.4 system can also be executed through, although I do not know why, but it is resolved.

Gson-1.7.1.jar Pack: gson-1.7.1.jar

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.