My project works fine, but as soon as I start obfuscating the code I get the following exception
Fatal Exception: java.lang.RuntimeException: Parcelable encountered IOException reading a Serializable object (name = com.mypackage.service.b.a) Caused by java.io.InvalidClassException: com.mypackage.service.b.a); class invalid for deserialization
This is happening in the following BroadcastReceiver
public class MyReceiver extends BroadcastReceiver {
@Override
public void onReceive(final Context context, Intent intent) {
if (intent != null) {
UpdateServiceConfig config = null;
final Bundle bundle = intent.getBundleExtra(Keys.DATA);
if (bundle != null) {
crash => config = (UpdateServiceConfig) bundle.getSerializable(Keys.CONFIG);
}
}
}
}
Here are my Proguard rules
-keepnames class * implements java.io.Serializable
-keepclassmembers class * implements java.io.Serializable {
static final long serialVersionUID;
private static final java.io.ObjectStreamField[] serialPersistentFields;
!static !transient <fields>;
!private <fields>;
!private <methods>;
private void writeObject(java.io.ObjectOutputStream);
private void readObject(java.io.ObjectInputStream);
java.lang.Object writeReplace();
java.lang.Object readResolve();
}
-keep class com.mypackage.service.config.UpdateServiceConfig { *; }
-keep class com.mypackage.service.config.config.** { *; }
There are other parts of the app where this class is retrieved from a bundle in the exact same way without any excpetion. It looks like the fact that this is handled in a BroadcastReceiver is what's causing the issue. Any idea what's causing this and how to fix that?