title: Best way to configure Proguard to strip out unused classes from Restlet library
body: <p>I use the Restlet 2.1.0 Java library for HTTP and HTTPS communication in my Android app.</p>
  
  <p>Until now I've configured Proguard to leave these libraries alone, using these keep and ignore rules:</p>
  
  <pre><code>-keep class org.restlet.** { *; }
  -dontwarn org.restlet.**
  -dontnote org.restlet.**
  </code></pre>
  
  <p>Since org.restlet.jar is 726KB and contains 5761 methods, I'm now trying to turn on Proguard to remove all the code that my app doesn't use, and safely optimize it.  </p>
  
  <p>Unfortunately, I'm struggling to write suitable Proguard rules, as my attempts result in Exceptions, because the Restlet library uses reflection.</p>
  
  <p>These parts of my rules seem safe enough:</p>
  
  <pre><code>-keep class org.restlet.engine.connector.Connection
  
  # Ignore these Restlet warnings, as we have never included the
  # org.jsslutils.* classes in our build
  -dontwarn org.restlet.ext.ssl.**
  </code></pre>
  
  <p>I've also tried to port the rules that I saw <a href="http://blog.stevenmohr.de/android/android-restlet-and-proguard/" rel="nofollow">on this blog</a>:</p>
  
  <pre><code>-keep class org.restlet.engine.log.LoggerFacade
  -keep class org.restlet.Application
  -keep class org.restlet.Client
  -keep class org.restlet.Context
  -keep class org.restlet.* extends org.restlet.Client { *; }
  -keep class org.restlet.* extends org.restlet.Context { *; }
  </code></pre>
  
  <p>Unfortunately I've been hitting <code>java.lang.NoSuchMethodException</code>s like this:</p>
  
  <pre><code>10-18 18:22:12.975  3142  3165 W System.err: Exception during the instantiation of the client connector.
  10-18 18:22:12.975  3142  3165 W System.err: java.lang.NoSuchMethodException: a(Client)
  10-18 18:22:12.975  3142  3165 W System.err:    at java.lang.Class.getMatchingConstructor(Class.java:643)
  10-18 18:22:12.975  3142  3165 W System.err:    at java.lang.Class.getConstructor(Class.java:472)
  10-18 18:22:12.975  3142  3165 W System.err:    at org.restlet.engine.e.a(Engine.java:510)
  10-18 18:22:12.975  3142  3165 W System.err:    at org.restlet.Client.&lt;init&gt;(Client.java:96)
  10-18 18:22:12.975  3142  3165 W System.err:    at org.restlet.Client.&lt;init&gt;(Client.java:120)
  10-18 18:22:12.975  3142  3165 W System.err:    at org.restlet.Client.&lt;init&gt;(Client.java:140)
  10-18 18:22:12.975  3142  3165 W System.err:    at org.restlet.d.a.j(ClientResource.java:830)
  10-18 18:22:12.975  3142  3165 W System.err:    at org.restlet.d.a.a(ClientResource.java:1045)
  10-18 18:22:12.975  3142  3165 W System.err:    at org.restlet.d.a.a(ClientResource.java:1454)
  10-18 18:22:12.985  3142  3165 W System.err:    at org.restlet.d.a.a(ClientResource.java:1400)
  </code></pre>
  
  <p>I'm working through them one-by-one by using my Proguard mapping.txt and the <a href="https://github.com/restlet/restlet-framework-java/tree/master/modules/org.restlet/src/org/restlet" rel="nofollow">Restlet source code</a>, but I thought I would check now in case somebody already knows the answer!</p>