这是我的proguard配置(我从android工具文件夹复制它并添加了一些行
-optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/*
-optimizationpasses 5
-allowaccessmodification
-dontpreverify
# The remainder of this file is identical to the non-optimized version
# of the Proguard configuration file (except that the other file has
# flags to turn off optimization).
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-verbose
-keepattributes *Annotation*
-keep public class com.google.vending.licensing.ILicensingService
-keep public class com.android.vending.licensing.ILicensingService
# For native methods, see http://proguard.sourceforge.net/manual/examples.html#native
-keepclasseswithmembernames class * {
native <methods>;
}
# keep setters in Views so that animations can still work.
# see http://proguard.sourceforge.net/manual/examples.html#beans
-keepclassmembers public class * extends android.view.View {
void set*(***);
*** get*();
}
# We want to keep methods in Activity that could be used in the XML attribute onClick
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}
# For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
-keepclassmembers class **.R$* {
public static <fields>;
}
# The support library contains references to newer platform versions.
# Don't warn about those in case this app is linking against an older
# platform version. We know about them, and they are safe.
-dontwarn android.support.**
######################
# added by me
########################
# guava
-keepclasseswithmembers class com.google.common.base.internal.Finalizer{
<methods>;
}
-dontwarn sun.misc.Unsafe
-dontwarn com.google.common.collect.MinMaxPriorityQueue
#
#Action Bar Sherlock
-keep class android.support.v4.app.** { *; }
-keep interface android.support.v4.app.** { *; }
-keep class com.actionbarsherlock.** { *; }
-keep interface com.actionbarsherlock.** { *; }
#-dontobfuscate
#-libraryjars libs/FlurryAgent.jar
我想在我的应用程序中使用Flurry,但是当我尝试使用FlurryAgen.jar模糊我的应用程序时,proguard无法说出这样的错误:
Warning: com.flurry.android.ay: can't find referenced class com.google.ads.AdListener
当我尝试不对来源进行模糊处理时,proguard也失败了。
如何使用proguard? 以及如何使proguard不混淆我的来源?
更新 我还提到FlurryAgent.jar似乎已经混淆了 - http://korniltsev.ru/p/jBU0f1c.png。可能我们可以忽略整个罐子的缩小?
答案 0 :(得分:46)
最后我设法这样做:
-keep class com.flurry.** { *; }
-dontwarn com.flurry.**
答案 1 :(得分:10)
Korniltsev的回答对我有用,但新的flurry SDK(3.2.2)建议添加以下内容:
-keep class com.flurry.** { *; }
-dontwarn com.flurry.**
-keepattributes *Annotation*,EnclosingMethod
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
可能会有一些需要新行的极端情况,所以我最终选择了自述文件。
答案 2 :(得分:5)
我不确定Flurry是如何与AdListener进行专门交互的,但Google的类名称正在被混淆。
尝试将行-keep public class com.google.ads.AdListener
添加到proguard文件中。如果Flurry使用其他com.google.ads类,您可能需要添加一些类别例外,但该行应解决您的即时警告。
<强>更新强> 问题是公共类方法名称正在为各种广告库进行模糊处理。因此,您可能需要包含其他proguard设置以包含这些方法:
-keep public class com.google.ads.** { public protected *; }
-keep public class com.inmobi.androidsdk.** { public protected *; }
-keep public class com.millenialmedia.android.** { public protected *; }
-keep public class com.mobclix.android.sdk.** { public protected *; }
-keep public class com.jumptap.adtag.** { public protected *; }
与Flurry一起工作并自己编程,确保在上传到您选择的应用市场之前彻底测试apk。
答案 3 :(得分:3)
Flurry(现在由雅虎拥有)官方推荐的proguard文件可在此处获取:
https://developer.yahoo.com/flurry/docs/publisher/code/android/
-keep class com.flurry.** { *; }
-dontwarn com.flurry.**
-keepattributes *Annotation*,EnclosingMethod,Signature
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
# Google Play Services library
-keep class * extends java.util.ListResourceBundle {
protected Object[][] getContents();
}
-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
public static final *** NULL;
}
-keepnames @com.google.android.gms.common.annotation.KeepName class * keepclassmembernames class * {
@com.google.android.gms.common.annotation.KeepName *;
}
-keepnames class * implements android.os.Parcelable {
public static final ** CREATOR;
}
#If you are using the Google Mobile Ads SDK, add the following:
# Preserve GMS ads classes
-keep class com.google.android.gms.ads.** { *;
}
-dontwarn com.google.android.gms.ads.**
#If you are using the InMobi SDK, add the following:
# Preserve InMobi Ads classes
-keep class com.inmobi.** { *;
}
-dontwarn com.inmobi.**
#If you are using the Millennial Media SDK, add the following:
# Preserve Millennial Ads classes
-keep class com.millennialmedia.** { *;
}
-dontwarn com.millennialmedia.**
答案 4 :(得分:0)
Flurry不再需要您修改proguard配置,请参见https://developer.yahoo.com/flurry/docs/integrateflurry/android/
注意:如果要添加Flurry依赖项的AAR格式,则无需修改AndroidManifest文件或ProGuard配置。