Search code examples
androidproguardflurry

Can't get Ad, Flurry 5.3 with ProGuard


My app can't get flurry ad when build app for release in google play with ProGuard. If i run app without ProGuard everything work fine. I enable Log and flurry SDK write next information:

02-20 16:31:09.765    8953-8953/? D/FlurryAdServingApp﹕ fetchAndDisplay: Banner
02-20 16:31:14.885    8953-8953/? D/FlurryAdServingApp﹕ Failed 20
02-20 16:31:17.960    8953-9041/? W/System.err﹕ java.lang.ClassCastException: com.flurry.sdk.it cannot be cast to com.flurry.android.impl.ads.protocol.v13.AdUnit
02-20 16:31:17.960    8953-9041/? W/System.err﹕ at com.flurry.sdk.ci$4.a(Unknown Source)
02-20 16:31:17.960    8953-9041/? W/System.err﹕ at com.flurry.sdk.ci$4.a(Unknown Source)
02-20 16:31:17.960    8953-9041/? W/System.err﹕ at com.flurry.sdk.gg.o(Unknown Source)
02-20 16:31:17.960    8953-9041/? W/System.err﹕ at com.flurry.sdk.gg.d(Unknown Source)
02-20 16:31:17.960    8953-9041/? W/System.err﹕ at com.flurry.sdk.gg$1.a(Unknown Source)
02-20 16:31:17.960    8953-9041/? W/System.err﹕ at com.flurry.sdk.gh.o(Unknown Source)
02-20 16:31:17.960    8953-9041/? W/System.err﹕ at com.flurry.sdk.gh.a(Unknown Source)
02-20 16:31:17.960    8953-9041/? W/System.err﹕ at com.flurry.sdk.gg.a(Unknown Source)
02-20 16:31:17.960    8953-9041/? W/System.err﹕ at com.flurry.sdk.hk.run(Unknown Source)

I'm not understand why his write Unknown Source if in proguard-project.txt i write next:

-keep class com.flurry.** { *; }
-dontwarn com.flurry.**
-keepattributes *Annotation*,EnclosingMethod
-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.**

Please, help me.


Solution

  • I had the exact same error message, "W/System.err﹕ java.lang.ClassCastException: com.flurry.sdk.it cannot be cast to com.flurry.android.impl.ads.protocol.v13.AdUnit".

    I reached out to Flurry support, [email protected], and 2 business days later (today), they answered saying:

    Thank you for contacting Flurry support. In your proguard config, could you please change the 3rd line from:

    -keepattributes *Annotation*,EnclosingMethod
    

    to

    -keepattributes *Annotation*,EnclosingMethod,Signature
    

    Note the addition of "Signature". Please try this new configuration and let us know if it works.

    I made the adjustment to Proguard and the Flurry ads appear to be working now. Summarized, my Proguard configuration for Flurry is below:

    #Flurry
    -keep class com.flurry.** { *; }
    -dontwarn com.flurry.**
    -keepattributes *Annotation*,EnclosingMethod,Signature
    -keepclasseswithmembers class * {
        public <init>(android.content.Context, android.util.AttributeSet, int);
    }
    # Preserve Flurry mediation classes for DFP/AdMob Ads
    -keep public class com.google.ads.mediation.flurry.**
    

    For reference, I'm using FlurryAds-5.3.0.jar, FlurryAnalytics-5.3.0.jar, and flurryAndroidDFPandAdMobMediationAdapter-5.0.0.r1.jar