Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4027406
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:05:34+00:00 2026-05-20T11:05:34+00:00

I am having a problem with GSON in my Android app. JSON Input [

  • 0

I am having a problem with GSON in my Android app.

JSON Input

[
    {"id":"1202","parent_id":"0","agrpcount":"0","disp_order":"1","code":"PROD-NEW","name":"New Products","active":"1"},
    {"id":"1119","parent_id":"0","agrpcount":"0","disp_order":"2","code":"PROD-VID","name":"\\\"How To\\\" Videos","active":"1"},
    {"id":"1685","parent_id":"0","agrpcount":"0","disp_order":"3","code":"SUPP-RESOUR","name":"Support Resources","active":"1"},
    {"id":"49","parent_id":"0","agrpcount":"0","disp_order":"109","code":"EQ","name":"Equipment for Sign Making","active":"1"},
    {"id":"22","parent_id":"0","agrpcount":"0","disp_order":"110","code":"application-tape","name":"Application Tapes","active":"1"}
]

Container class for each array item

public class Category {
    public int id;
    public int parent_id;
    public int agrpcount;
    public int disp_order;
    public String code;
    public String name;
    public int active;
}

Class to load category array

public static List<Category> getCategories(){
    Category[] cats;

    Gson gson = new Gson();

    cats = gson.fromJson(strJSON, Category[].class);

    List<Category> CatsList = Arrays.asList(cats);
    return CatsList;
}

When I run this code I get the following in the Log

02-28 15:15:42.471: ERROR/AndroidRuntime(777): Caused by: java.lang.RuntimeException: No-args constructor for class com.signwarehouse.catalog.SWService$Category does not exist. Register an InstanceCreator with Gson for this type to fix this problem.
02-28 15:15:42.471: ERROR/AndroidRuntime(777):     at com.google.gson.MappedObjectConstructor.constructWithNoArgConstructor(MappedObjectConstructor.java:64)
02-28 15:15:42.471: ERROR/AndroidRuntime(777):     at com.google.gson.MappedObjectConstructor.construct(MappedObjectConstructor.java:53)
02-28 15:15:42.471: ERROR/AndroidRuntime(777):     at com.google.gson.JsonObjectDeserializationVisitor.constructTarget(JsonObjectDeserializationVisitor.java:40)
02-28 15:15:42.471: ERROR/AndroidRuntime(777):     at com.google.gson.JsonDeserializationVisitor.getTarget(JsonDeserializationVisitor.java:56)
02-28 15:15:42.471: ERROR/AndroidRuntime(777):     at com.google.gson.ObjectNavigator.accept(ObjectNavigator.java:109)
02-28 15:15:42.471: ERROR/AndroidRuntime(777):     at com.google.gson.JsonDeserializationVisitor.visitChild(JsonDeserializationVisitor.java:107)
02-28 15:15:42.471: ERROR/AndroidRuntime(777):     at com.google.gson.JsonDeserializationVisitor.visitChildAsObject(JsonDeserializationVisitor.java:95)
02-28 15:15:42.471: ERROR/AndroidRuntime(777):     at com.google.gson.JsonArrayDeserializationVisitor.visitArray(JsonArrayDeserializationVisitor.java:72)
02-28 15:15:42.471: ERROR/AndroidRuntime(777):     at com.google.gson.ObjectNavigator.accept(ObjectNavigator.java:117)
02-28 15:15:42.471: ERROR/AndroidRuntime(777):     at com.google.gson.JsonDeserializationContextDefault.fromJsonArray(JsonDeserializationContextDefault.java:64)
02-28 15:15:42.471: ERROR/AndroidRuntime(777):     at com.google.gson.JsonDeserializationContextDefault.deserialize(JsonDeserializationContextDefault.java:49)
02-28 15:15:42.471: ERROR/AndroidRuntime(777):     at com.google.gson.Gson.fromJson(Gson.java:568)
02-28 15:15:42.471: ERROR/AndroidRuntime(777):     at com.google.gson.Gson.fromJson(Gson.java:515)
02-28 15:15:42.471: ERROR/AndroidRuntime(777):     at com.google.gson.Gson.fromJson(Gson.java:484)
02-28 15:15:42.471: ERROR/AndroidRuntime(777):     at com.google.gson.Gson.fromJson(Gson.java:434)
02-28 15:15:42.471: ERROR/AndroidRuntime(777):     at com.google.gson.Gson.fromJson(Gson.java:406)

I tried adding a no-args constructor to the Category class, but this didn’t help. No surprise since Java creates it automatically.

Does anyone have any idea how to fix this?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T11:05:35+00:00Added an answer on May 20, 2026 at 11:05 am

    Trying making the Category class a public static class…

    public static class Category {/* fields */}
    

    I bet what’s happening is since you didn’t make the class static it is trying to create your parent/outer class (com.signwarehouse.catalog.SWService) first which probably doesn’t have a no-arg constructor.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm having problem to deal with charset in ruby on rails app, specificially in
I'm having some trouble with GSON, mainly deserializing from JSON. I have the following
Having problem with this bit of code qith jQuery. it should pick the values
I am having problem with the title of a header in my jquery code.
i having problem in converting this C# code into VB.net. The loadLecturer seem to
Having problem to open form in new window, script is pulled from external service.
I having problem marshaling an iterator of objects using JAXB User class: @XmlRootElement(name=User) public
I'm having a problem serializing an object using Gson. @XmlRootElement class Foo implements Serializable
I am having problem with the database access in android. First, I created an
Im having problem's adding map markers to gmaps using jquery. Here is my code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.