问题
I'm trying to obfuscate google play services jar with proguard. I tried two versions of the proguard config file.
First one contains
-keep class ** { public protected *; }
And the jar stays not obfuscated. It looks ok.
Second one contains
-keep class com.** { public protected *; }
And proguard deletes everithing. I get an error:
Error: The output jar is empty. Did you specify the proper '-keep' options?
Why is it empty, as the main google play services package is com.google.android.gms?
回答1:
The following ProGuard configuration shrinks the Google Play Services jar, without optimization or obfuscation, keeping only the ads-related API:
-injars android-sdk/extras/google/google_play_services/libproject/google-play-services_lib/libs/google-play-services.jar
-outjars google-play-services-ads.jar
-libraryjars android-sdk/extras/android/support/v4/android-support-v4.jar
-libraryjars android-sdk/platforms/android-20/android.jar
-verbose
-forceprocessing
-dontoptimize
-dontobfuscate
-dontwarn com.google.**.R
-dontwarn com.google.**.R$*
-dontnote
-keep public class com.google.ads.** {
public protected *;
}
-keep public class com.google.android.gms.ads.** {
public protected *;
}
-keep class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
java.lang.String NULL;
}
It reduces the original jar from 2819 classes to 409 classes (2.7M to 476K). I haven't tested the result yet. If any removed classes are accessed by reflection, they need to be kept in the configuration as well.
来源:https://stackoverflow.com/questions/26036617/proguard-google-play-services-jar