title: Gson library and Proguard
body: <p>I have got an issue with proguard and the Gson library. My code is </p>
  
  <pre><code>AdServerResult result = (AdServerResult) new Gson().fromJson(json, 
        AdServerResult.class);
  </code></pre>
  
  <p><em>(I create a new <code>AdServerResult</code> object using the Gson library)</em></p>
  
  <p>My <code>AdServerResult</code> class :</p>
  
  <pre><code>public class AdServerResult {
  
      public ArrayList&lt;AdServerObject&gt; shorts ;
      public ArrayList&lt;AdServerObject&gt; longs ;
  
      public ArrayList&lt;AdServerObject&gt; getShorts() {
          return shorts;
      }
      public void setShorts(ArrayList&lt;AdServerObject&gt; shorts) {
          this.shorts = shorts;
      }
      public ArrayList&lt;AdServerObject&gt; getLongs() {
          return longs;
      }
      public void setLongs(ArrayList&lt;AdServerObject&gt; longs) {
          this.longs = longs;
      }
  
      //for debug
      @Override
      public String toString(){
  
          StringBuilder sb = new StringBuilder() ;
  
          if (shorts!=null &amp;&amp; shorts.size()&gt;0){
              for (AdServerObject s: shorts){
                  sb.append("url: "+s.getPicture_url());
              }
          }
  
          if (longs!=null &amp;&amp; longs.size()&gt;0){
              for (AdServerObject s: longs){
                  sb.append("url: "+s.getPicture_url());
              }
          }
  
          return sb.toString();
      }
  
  }
  </code></pre>
  
  <p>My <code>AdServerObject</code> (present in the <code>AdServerResult</code> class) :</p>
  
  <pre><code>public class AdServerObject{
  
      public String appli_id;
      public String picture_url;
  
      public String getAppli_id() {
          return appli_id;
      }
      public void setAppli_id(String appli_id) {
          this.appli_id = appli_id;
      }
      public String getPicture_url() {
          return picture_url;
      }
      public void setPicture_url(String picture_url) {
          this.picture_url = picture_url;
      }       
  }
  </code></pre>
  
  <p>And my "json" string is as below :</p>
  
  <pre><code>{ 
    "shorts": [
      { "appli_id": "282", "picture_url": "xxxx"},
      { "appli_id": "275", "picture_url": "xxx" }
    ], 
    "longs": [
      {"appli_id": "MyAppli3", "picture_url": "xxxxx"},
      {"appli_id": "MyAppli4", "picture_url": "xxxxx" }
    ]
  
  }
  </code></pre>
  
  <p>This code works but when exporting with proguard, the <code>AdServerResult</code> instance is <code>null</code>.</p>
  
  <p>My proguard file (only the json part) :</p>
  
  <pre><code># for gson (GSON @Expose annotation)
  -keep public class com.google.gson.Gson
  -keepattributes *Annotation*
  -keep class sun.misc.Unsafe { *; }
  -keep class com.google.gson.stream.** { *; }
  -keep class com.google.gson.examples.android.model.** { *; }
  
  ...
  
  -keepattributes Signature
  -keepattributes *Annotation*
  
  ...
  
  -keep public class jp.xxx.ad_server.AdServerResult
  -keep public class jp.xxx.ad_server.AdServerObject
  -keepclassmembers class jp.xxx.ad_server.AdServerObject
  -keepclassmembers class jp.xxx.ad_server.AdServerResult
  </code></pre>
  
  <p>I have used this <code>Gson().fromJson</code> many times but I never encountered a such problem.... I am struggling with this issue for 12 hours and my brain is about to explode. </p>
  
  <p>--
  EDIT</p>
  
  <p>I have updated proguard(4.11) but problem remains. </p>