Till - gotohuman.com
Till - gotohuman.com

Reputation: 6075

Facebook SDK 4.7.0 logs ClassNotFoundException for AppEventsLogger

I integrated the FB SDK in my Android app via Gradle for log-in and tracking events. Log-in works fine, but the logcat keeps showing me an exception every 15 seconds once I try to log an app event:

D/com.facebook.appevents.AppEventsLogger: Got unexpected exception: java.lang.ClassNotFoundException: com.facebook.a.b

It gets thrown in PersistedEvents' readAndClearStore() method

Here's my code for logging the event:

AppEventsLogger logger = AppEventsLogger.newLogger(this);
    Bundle parameters = new Bundle();
    parameters.putString(AppEventsConstants.EVENT_PARAM_CURRENCY, "EUR");
    parameters.putString(AppEventsConstants.EVENT_PARAM_CONTENT_TYPE, "product");
    parameters.putString(AppEventsConstants.EVENT_PARAM_CONTENT_ID, id);

    logger.logEvent(AppEventsConstants.EVENT_NAME_VIEWED_CONTENT,
            1.99,
            parameters);

I mean com.facebook.a.b looks like a proguard issue to me. But in the FB SDK docs they clearly state that you do not need to enter any proguard rules for it to work. This error also shows when I don't minify my app and also if I download the sdk from github and include it as a module.

Upvotes: 24

Views: 1640

Answers (2)

Sheeni Saxena
Sheeni Saxena

Reputation: 1

Use in gradle instead of sdk:4.11.0:

compile('com.facebook.android:facebook-android-sdk:3.23.0') {
    exclude module: 'bolts-android'
}

I am also not able to login with fb sdk: 4.11.0 as this version of fb sdk does provide an exception of Facebook class. With the higher version of fb sdk, new classes are replacing old ones.

Even in new verison 23 up, ActionBaractivity is depricating so need to use AppCompatActivity.

Upvotes: 0

JpCrow
JpCrow

Reputation: 5077

i have a similar issue a few days ago with the logger in the Facebook SDK(v4.11.0):

D/com.facebook.a.a(PID): Got unexpected exception: java.io.WriteAbortedException: Read an exception; java.io.NotSerializableException: org.json.JSONObject

And in their documentation they said the following:

You don't have to perform any additional steps to use ProGuard for the Facebook Android SDK. For instructions on Proguard, see Android Tools Project Site, Running ProGuard.

After looking what was causing to not log any of my events in release environment i added the following rule to my proguard file and then magically started working well:

-keep class com.facebook.** { *; }

We already open a ticket to the facebook developers team in order to have more information about this. https://developers.facebook.com/bugs/250752828645777/

Upvotes: 1

Related Questions