I’m using FlurryAnalytics-5.5.0.jar. When I initialize Flurry, I receive some errors:
FlurryAgent.setLogEnabled(true);
FlurryAgent.setLogEvents(true);
FlurryAgent.setLogLevel(android.util.Log.ERROR);
FlurryAgent.init(this, FLURRY_ID);
Errors:
Could not find class 'com.flurry.sdk.br', referenced from method
com.flurry.sdk.bq.a
and
There is a problem with the Google Play Services library, which is
required for Android Advertising ID support. The Google Play Services
library should be integrated in any app shipping in the Play Store
that uses analytics or advertising.
Can you please advise?
This problem arises because Google Play Services are not property configured. Check that any play-services core dependency is not missing in your project configuration.
In my case, I solved it by adding the following dependency to build.gradle config file (app level):
compile 'com.google.android.gms:play-services-base:8.4.0'
The exact logcat error lines are the following
E/FlurryAgent: GOOGLE PLAY SERVICES EXCEPTION: com.google.android.gms.common.GooglePlayServicesUtil
E/FlurryAgent: There is a problem with the Google Play Services library, which is required for Android Advertising ID support. The Google Play Services library should be integrated in any app shipping in the Play Store that uses analytics or advertising.
and the GooglePlaySercicesUtil class is found in the play-services-base library.
Hope this helps.
See links this and this for more information.
If you're using Proguard, the Flurry guide page tells it is necessary to add the following lines to you proguard config file:
-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.**
Also take a look at this answer.
Related
I am trying to add custom Proguard rules for my app, but I am not sure into which file I should add those custom rules. I know of three files
1)Android/sdk/tools/proguard/proguard-android.txt
2)Android/sdk/tools/proguard/proguard-project.txt
3)Project --> app --> proguard-rules.pro
First of all you will use the
3)Project --> app --> proguard-rules.pro
and
few generic custom rules which are safe to apply on app and wouldn't
hinder the functioning of it
depends on the code in your app but if you will set minifyEnabled to true(which is recommended) this could lead to a lot of issues which can be solved through proguard rules file.
This is my proguard file for one of my projects where I'm using Fabric, httpApacheClient, shareActionProvider and some other libraries that needs specific rules for proguard.
# This will ignore warnings for missing translations and some other wanrinings
-ignorewarnings
# Keeping line numbers for easy error tracking :
-keepattributes SourceFile,LineNumberTable
# Support ShareActionProvider will not work without this line :
-keep class android.support.v7.widget.ShareActionProvider { *; }
# Flurry Crashlytics
-keep class com.flurry.** { *; }
-dontwarn com.flurry.**
-keepattributes *Annotation*,EnclosingMethod
-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.**
# 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;
}
-keepattributes InnerClasses, EnclosingMethod
-keep class com.ironsource.mobilcore.**{ *; }
-dontwarn org.apache.http.**
-dontwarn android.net.http.AndroidHttpClient
-dontwarn android.app.Notification
-keep class com.dianxinos.DXStatService.stat.TokenManager {
public static java.lang.String getToken(android.content.Context);
}
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.app.Activity
-keep public class * extends android.content.ContentProvider
And almost you will find related proguard settings in the documentation of any external library you use.
in
3)Project --> app --> proguard-rules.pro
There are not generic proguard rules. All those generic ones already included with SDK, It depends on what features and libraries are you using in your project. Also there is no safeway of doing it. You have to apply rules and test app -> fix any issues then repeat same process.
I created an app using butterknife to implement onclick, ontouch,etc function, it works fine when I test it on my android devices, and it also works good when I install the debug-apk in the android deivces. However, when I generated an signed apk and try to run it in my android device, the "onclick" and "ontouch" are not working.I generated the apk using Android studio. Anyone knows the reason why this happens?
Copied from http://jakewharton.github.io/butterknife/
Use these rules in proguard-rules.pro file
-keep class butterknife.** { *; }
-dontwarn butterknife.internal.**
-keep class **$$ViewBinder { *; }
-keepclasseswithmembernames class * {
#butterknife.* <fields>;
}
-keepclasseswithmembernames class * {
#butterknife.* <methods>;
}
Add
-keepnames class * { #butterknife.Bind *;}
to the proguard file
I'm unable to build my package with Proguard enabled after updating Google Play Services library. My project minSdkVersion is 9. I am using following version of services lib:
android:versionCode="4323030"
android:versionName="4.3.23 (1069729-030)" >
The library states minSdk also 9.
And getting error:
Unexpected error while performing partial evaluation:
Class = [com/google/android/gms/common/GooglePlayServicesUtil]
Method = [showErrorDialogFragment(ILandroid/app/Activity;ILandroid/content/DialogInterface$OnCancelListener;)Z]
Exception = [java.lang.IllegalArgumentException] (Can't find any super classes of [com/google/android/gms/common/ErrorDialogFragment] (not even immediate super class [android/app/DialogFragment]))
java.lang.IllegalArgumentException: Can't find any super classes of [com/google/android/gms/common/ErrorDialogFragment] (not even immediate super class [android/app/DialogFragment])
Following related to gms is found in my proguard file:
-dontwarn com.google.android.gms.**
-keep class com.google.android.gms.** { *; }
-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;
}
DialogFragment was added in API level 11. Is this a failure with the services library or am I missing something?
Thanks.
You should build against API level 11 that contains the missing class. The library itself probably has a fallback mode for older APIs, but ProGuard still needs to process the entire application, including the newer code.
I developed android app and I used admob sdk 6.2.1 for showing ads, and when I tested the app on my real device and on the emulator,ads are shown.
but when I apply pro guard to my app and test it on my device(I tested it on another devices also) ads are not shown up, any help please!
Add this to your proguard:
-keep class com.google.ads.** # Don't proguard AdMob classes
-dontwarn com.google.ads.** # Temporary workaround for v6.2.1. It gives a warning that you can ignore
EDIT 2020:
For some time now, the Google Mobile Ads SDK has distributed its own proguard rules that get manifest merged into your app, so you don't need to add anything yourselves. The merged rules also keep around methods from third-party mediation adapters that are needed to make mediation work.
From the docs:
To safely use ProGuard with Google Mobile Ads, add the following to your ProGuard config:
-keep public class com.google.android.gms.ads.** {
public *;
}
-keep public class com.google.ads.** {
public *;
}
This will prevent all public methods on public classes from being obfuscated.
If you use AdMob Mediation with other ad networks, you should keep public methods from public classes for each SDK and adapter library as well.
Proguard Rules for Admob in Android
-keep public class com.google.android.gms.ads.**{
public *;
}
# For old ads classes
-keep public class com.google.ads.**{
public *;
}
# For mediation
-keepattributes *Annotation*
# Other required classes for Google Play Services
# Read more at http://developer.android.com/google/play-services/setup.html
-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;
}
I am developing an app that uses google maps. The app works fine up until I Export the signed app package .After the code has been obfuscated the maps are no longer loaded. I am pretty new to ProGuard,I've tried modifying proguard.cfg but soo far nothing has worked.
Here are some of the different things that i've tried:
-libraryjars C:/Program Files/Android/android-sdk/add-ons/addon-google_apis-google_inc_-10/libs/maps.jar
-keep class android.location.** { *; }
-keepnames class com.google.android.maps.** {*;}
-keep public class com.google.android.maps.** {*;}
-dontwarn com.google.android.maps.GeoPoint
-dontwarn com.google.android.maps.MapActivity
-dontwarn com.google.android.maps.MapView
-dontwarn com.google.android.maps.MapController
-dontwarn com.google.android.maps.Overlay
Thanks
Edit: For Google Maps For Android V2 Specifically:
Just in case anyone sees this and has a similar issue - I was getting a Parcelable RuntimeException when I tried to view a second map (as in, Activity A had a map instance, then moving to Activity B, another instance with different params), pointing to what i was assuming was an obfuscated class name in the google package.
after i added
-keep class com.google.android.gms.maps.** { *; }
-keep interface com.google.android.gms.maps.** { *; }
to my proguard-project.txt everything seemed to keep working as normal
It is most likely issue with the Maps API Key. You should generate the Key with the signature used while exporting the app and use it in your map view.
Its unlikely that Obfuscation using ProGuard will affect the map rendering.
It might help:
-optimizations !code/simplification/variable
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Fragment
-keep public class * extends android.support.v4.app.Fragment
# The Maps API uses custom Parcelables.
# Use this rule (which is slightly broader than the standard recommended one)
# to avoid obfuscating them.
-keepclassmembers class * implements android.os.Parcelable {
static *** CREATOR;
}
# The Maps API uses serialization.
-keepclassmembers class * implements java.io.Serializable {
static final long serialVersionUID;
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();
}
Source:
https://github.com/googlemaps/android-samples/blob/master/ApiDemos/app/proguard-rules.pro
I've had a similar issue using the Google Maps Roads API - it didn't work in obfuscated code. Turns out, the API library uses reflection under the hood, so the solution was to add
-keep class com.google.maps.** { *; }
to proguard-rules.pro.
(Adding this answer here specifically, because this question came up as the most related when I was searching for a solution to my issue, and finding the answer here would've saved me a couple hours of further searching.)
this is better
-keep class * implements com.google.android.gms.maps { *; }
-keep class com.google.android.gms.maps.** { *; }
-keep interface com.google.android.gms.maps.** { *; }