i am using pcap4j on Android and everything works well on Debug Build. But in release build when activating Proguard/R8 following exception is thrown :
java.lang.IllegalStateException: Unsupported target: class org.pcap4j.packet.IpV4Rfc1349Tos
at org.pcap4j.packet.factory.PacketFactoryBinder.getPacketFactory(SourceFile:2)
at org.pcap4j.packet.factory.PacketFactories.getFactory(SourceFile:2)
at org.pcap4j.packet.IpV4Packet$IpV4Header.<init>(SourceFile:6)
at org.pcap4j.packet.IpV4Packet.<init>(SourceFile:2)
at org.pcap4j.packet.IpV4Packet.newPacket(SourceFile:2)
at org.pcap4j.packet.factory.StaticEtherTypePacketFactory.newInstance(SourceFile:10)
at org.pcap4j.packet.factory.StaticEtherTypePacketFactory.newInstance(SourceFile:1)
at org.pcap4j.packet.IpSelector.newPacket(SourceFile:8)
As a workaround for this it is working ok if i add this rule :
-keep class org.pcap4j.packet.**
But with above rule all classes are kept by shrinker and not optimized
My question is how to write more strict rule to shrink pcap4j in maximum and keep functionality without throw exception
I have tried too with below rules but still crashing :
-keepclassmembernames class org.pcap4j.packet.**
-keepclassmembers class org.pcap4j.packet.**
-keepnames class org.pcap4j.packet.**
So another workaround is to keep this 2 classes in this case and everything will work OK :
-keep class org.pcap4j.packet.IpV4Packet
-keep class org.pcap4j.packet.IpV4Rfc1349Tos
But i am asking for a "general" rule, because the app may use other classes like those above in this case.
Thank you