Java.lang.SecurityException:Can ' t make Field constructor accessible__ technology

Source: Internet
Author: User


Originally using Gsonconvertor, there was no problem with the Android version 5.1.1, the result was switched to version 6.0.1, and the following problems occurred:

Java.lang.IllegalArgumentException:Unable to create converter for java.util.list<model>

, StackOverflow has a post to talk about the problem http://stackoverflow.com/questions/34315499/ Unable-to-create-converter-for-java-util-list-retrofit-2-0-0-beta2. But my own code is like the answer, so the answer is useless, look at the retrofit document, the Convertor library from Gson to Jackson, solve the problem, but Jackson has a flaw, it on the JSON Object interface field definition requirements are more stringent, If there is an object in JSON that doesn't have a definition, it's going to be error, which is very limiting the version upgrade of the interface, and there's no way to go back and solve the Gson problem. The Gson of the problem is that the root cause of the error is:

Java.lang.SecurityException:Can ' t make Field constructor accessible

Originally this is an Android M preview version of the issue, Gson has also admitted that, plus I also used the activeandroid, the solution:

            Gsonbuilder builder = new Gsonbuilder ();
            Builder.excludefieldswithmodifiers (modifier.final, modifier.transient, modifier.static);
            Gson Gson = Builder.create ();


            Retrofit = new Retrofit.builder ()
                    . BaseURL (BaseURL)
                    . Addconverterfactory (gsonconverterfactory.create )
                    . Client (client)
                    . Build ();


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.