Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Facebook SDK for Android crashes with Nullpointer in Class UserSettingsManager

Facebook SDK crashes randomly, it doesn't give any info regarding what this crash is about; we don't even know the action when this is happening and we are not able to reproduce this.

Gradle setting

implementation 'com.facebook.android:facebook-android-sdk:[4,5)'

We are using facebook sbk to send events to FB analytics

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean org.json.JSONObject.optBoolean(java.lang.String, boolean)' on a null object reference
   at com.facebook.UserSettingsManager$1.run(UserSettingsManager.java:148)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
   at java.lang.Thread.run(Thread.java:764)
like image 325
Hari Avatar asked Jan 29 '19 10:01

Hari


2 Answers

According to this reply from Marc Hayek of the Facebook team, we may upgrade the version to fix the issue.

implementation 'com.facebook.android:facebook-login:4.41.0'

Hope this helps you.

like image 117
Salam Hiyali Avatar answered Sep 25 '22 00:09

Salam Hiyali


After some investigation i realized that the bug has been introduced in sdk 4.40 so i have changed gradle to implementation 'com.facebook.android:facebook-login:4.39.0' and that should remove the bug until a fixed newer FB sdk will be released

like image 36
Luca Rocchi Avatar answered Sep 23 '22 00:09

Luca Rocchi