title: How do you stop Proguard from removing type parameters?
body: <p>I am currently attempting to obfuscate a series of libraries. My base library, which contains several classes and methods that use type parameters, is unusable by other code due to the type parameters being removed by Proguard obfuscation. Eliminating the obfuscation removes these issues. I have read through all of the ProGuard usage documents, examples, and troubleshooting, but have been unable to find any documentation on how to deal with type parameters or which aspect of ProGuard strips the type parameters.</p>
  
  <p><strong>Constructor Type Parameter Issue:</strong></p>
  
  <p>Library 1 contains the following class:</p>
  
  <pre><code>public abstract class AbstractFactoryFactory&lt;T&gt;
  </code></pre>
  
  <p>Library 2 contains several classes that extend the above class but the constructor throws a compiler error that states:</p>
  
  <pre><code>error: type AbstractFactoryFactory does not take parameters
  </code></pre>
  
  <p><strong>Return Type Parameter Issue:</strong></p>
  
  <p>Library 1 has a Foo class with the following method:</p>
  
  <pre><code>public List&lt;String&gt; doSomething()
  </code></pre>
  
  <p>Libary 2 tries to use the doSomething method, but after obfuscation the method returns an untyped list that generates the following compiler error that states:</p>
  
  <pre><code>error: incompatible types Object
  </code></pre>
  
  <p><strong>Proguard.cfg</strong></p>
  
  <pre><code>-dontoptimize
  
  -renamesourcefileattribute SourceFile
  -keepparameternames
  -keepattributes Exceptions,*Annotation*,InnerClasses,SourceFile,LineNumberTable,Deprecated
  
  -keep public class * {
      public protected *;
  }
  
  -keepclassmembers enum * {
      public static **[] values();
      public static ** valueOf(java.lang.String);
  }
  
  -keepclassmembernames class * {
      java.lang.Class class$(java.lang.String);
      java.lang.Class class$(java.lang.String, boolean);
  }
  
  -keepclasseswithmembernames class * {
      native &lt;methods&gt;;
  }
  
  -keepclassmembers class * implements java.io.Serializable {
      static final long serialVersionUID;
      private static final java.io.ObjectStreamField[] serialPersistentFields;
      private void writeObject(java.io.ObjectOutputStream);
      private void readObject(java.io.ObjectInputStream);
      java.lang.Object writeReplace();
      java.lang.Object readResolve();
  }
  </code></pre>