I use ProGuard to optimize my Android Application. However for Android instrumentation test I need some (but not all) classes to keep all there members. I tried various approaches, the last being:
-keepclassmembers public class com.mycompany.myclass {
*;
}
But surprisingly I still get
java.lang.NoSuchMethodError: com.mycompany.myclass.<init>
The painful part here is that there are two constructors and one has quite a few parameters.
Does anyone know the correct syntax to keep a class completely unchanged and untouched by ProGuard?
Well, it is confession time. The question is bollocks. The
-keepclassmembers
is correct. The problem occurred because a team mate broke the code and the constructor was truly not there.Note that if there is a change that the whole class is optimized away then you should use
-keep
as kharles suggested but the{*;}
is needed to ensure that all methods stay in place.Note that the
{*;}
is for testing only. For production one should use a more fine grained approach.I keep the question for anybody with the same problem.
try
( use keep, and no {*;} )