我使用-libraryjar作为依赖来混淆我的android库jar,如下所示:
-injars build/libs/mylib.jar
-outjars build/libs/mylib-proguarded.jar
-libraryjars build/intermediates/classes/release/libs/gson-2.3.1.jar
这将gson库与最终混淆的库jar捆绑在一起。
问题:应该使用混淆库jar的Android应用程序,它有自己的gson,我因为有两个gson jar副本而发生冲突。如何从库混淆的jar中排除gson jar。
我的其余proguard配置看起来像这样:
-dontpreverify
-dontwarn android.annotation.SuppressLint
-keepparameternames
-renamesourcefileattribute SourceFile
-keepattributes *Annotation*,Exceptions,InnerClasses,Signature,Deprecated,SourceFile,LineNumberTable,*Annotation*,EnclosingMethod
-keep class sun.misc.Unsafe { *; }
-keep public class * {
public protected *;
}
-keepclassmembernames class * {
java.lang.Class class$(java.lang.String);
java.lang.Class class$(java.lang.String, boolean);
}
-keepclasseswithmembernames,includedescriptorclasses class * {
native <methods>;
}
-keepclassmembers,allowoptimization enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keepclassmembers class * implements java.io.Serializable {
static final long serialVersionUID;
private static final java.io.ObjectStreamField[] serialPersistentFields;
private void writeObject(java.io.ObjectOutputStream);
private void readObject(java.io.ObjectInputStream);
java.lang.Object writeReplace();
java.lang.Object readResolve();
}