Android proguard, keep inner class

David Guan picture David Guan · Dec 27, 2012 · Viewed 37.5k times · Source

My android program has a class A, which has two static inner class. They are found to be stripped from .dex after applying proguard.

public class A{

  ...
  static class B{
    ...
  }

  static class C{
    ...
  }
}

I have put the following lines in proguard.flags, but seem no luck.

-keep class com.xxx.A
-keep class com.xxx.A$*

Any hint?

Answer

Alexander Lucas picture Alexander Lucas · Dec 27, 2012

Try adding InnerClasses to the keep attributes. e.g:

-keepattributes Exceptions, InnerClasses, ...

Also, try adding a body to the "keep" call with an asterisk, like so:

-keep class com.xxx.A$* {
    *;
}