java - How to stop ProGuard from stripping the Serializable interface from a class -
is there explicit way stop proguard changing class implementing interface?
i have class implements java.io.serializable
, let's call com.my.package.name.foo
. i've found after running through proguard, no longer implements serializable
. null
after cast serializable
foo
, false
if check instance instanceof serializable
. i've made sure set proguard ignore class:
-keep class com.my.package.name.foo
i've tried:
-keep class com.my.package.name.foo { *; }
and i've tried whole package doing this:
-keep class com.my.package.name.** { *; }
or:
-keep class com.my.package.** { *; }
and keep serializable
classes:
-keep class * implements java.io.serializable { *; }
but no avail. have class in sibling package (roughly: com.my.package.name2.bar
) implements serializable
, used has no issues.
i'm not sure it's relevant, i'm packing in jar use android. code uses these classes include putting them in bundle
s why need serializable
. considered perhaps somehow proguard thinks foo
never used serializable
seems unlikely given pass parameter bundle.putserializable(string, serializable)
, implicit cast: serializable serializable = foo;
. in fact, when debug, can see foo
put bundle
, can examine bundle
, see instance of foo
there, when retrieving cast fails.
proguard doesn't ever strip interfaces defined in libraries (like serializable) classes in code processed (like foo). library code may casting interfaces, can't removed.
i null after cast serializable foo
this means instance must null start with. analysis correct if you'd classcastexception. can check foo still implements serializable javap
. problem lies elsewhere. tips on serialization, can @ proguard manual > examples > processing serializable classes.
update:
in case, turns out configuration problem. proguard can process class files if knows hierarchy (just compiler). have specify runtime classes:
-libraryjars <java.home>/lib/rt.jar
or android:
-libraryjars /usr/local/android-sdk/platforms/android-17/android.jar
the android ant/eclipse builds automatically specify necessary -injars/-outjars/-libraryjars options you, in custom build process, have specify them yourself. cfr. proguard manual > examples > a complete android application.
note option -dontwarn makes warnings go away, not problems. use if necessary.
Comments
Post a Comment