title: Android and GSON throwing No-Args Constructor not found exception
body: <p>I am having a problem with GSON in my Android app.  </p>
  
  <p>JSON Input</p>
  
  <pre><code>[
      {"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"}
  ]
  </code></pre>
  
  <p>Container class for each array item</p>
  
  <pre><code>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;
  }
  </code></pre>
  
  <p>Class to load category array</p>
  
  <pre><code>public static List&lt;Category&gt; getCategories(){
      Category[] cats;
  
      Gson gson = new Gson();
  
      cats = gson.fromJson(strJSON, Category[].class);
  
      List&lt;Category&gt; CatsList = Arrays.asList(cats);
      return CatsList;
  }
  </code></pre>
  
  <p>When I run this code I get the following in the Log</p>
  
  <pre><code>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)
  </code></pre>
  
  <p>I tried adding a no-args constructor to the Category class, but this didn't help. No surprise since Java creates it automatically.</p>
  
  <p>Does anyone have any idea how to fix this?</p>
  
  <p>Thanks.</p>