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

Source: Internet
Author: User
Tags modifier

Originally using Gsonconvertor, there is no problem on Android version 5.1.1, the result is switched to version 6.0.1, the following problem appears:

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

, StackOverflow has a post to talk about this issue 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 is flawed, it is the JSON object interface field definition requirements are relatively strict, If there are objects in the JSON that do not define the field will be error, this very limited version of the interface upgrade, there is no way back to continue to solve the problem of Gson. Gson, the root cause of the problem is:

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


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

      1. gsonbuilder builder = < span class= "keyword" >new gsonbuilder ();   
      2. builder.excludefieldswithmodifiers ( modifier.final, modifier.transient, modifier.static);   
      3. Gson gson  = builder.create ();   
      4.   
      5. &NBSP;&NBSP;
      6. Retrofit = new retrofit.builder ()   
      7.          .addconverterfactory (Gsonconverterfactory.create (Gson))   
      8.         .client (client)   
      9.         .build ();   

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

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.