Facebook SDK 4.7.0 logs ClassNotFoundException for AppEventsLogger
Asked Answered
S

2

24

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.

Samarium answered 17/10, 2015 at 15:5 Comment(5)
are these logs comming from an release app? Or is it debug?Kynan
But does it work if you escape proguard for the fb sdk? -keep class com.facebook.** { *; }Martini
Where are you specifying the minification option? How have you disabled it? Apparently it is not working. The missing class is being used by AppEventsLogger when it tries to log events (if any) every 15 seconds.Subtemperate
Just to add this here: At some point it started working without me having changed anything, so I didn't investigate any further. Strange issue. By looking at the upvotes, seems to trouble others as well.. :/Samarium
Update the latest facebooksdk to your android application (Latest Version of Facebook Sdk is (4.16.1)Bog
B
1

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/

Billman answered 9/5, 2016 at 1:8 Comment(0)
E
0

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.

Endurable answered 22/11, 2016 at 12:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.