Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android facebook sdk internal utility java.lang.AssertionError

I have been using version 4.27.0 of facebook sdk for android. I have been getting a crash only for android 8+ devices. The stack trace is as follows:

Fatal Exception: java.lang.AssertionError: No NameTypeIndex match for SHORT_DAYLIGHT
       at android.icu.impl.TimeZoneNamesImpl$ZNames.getNameTypeIndex(TimeZoneNamesImpl.java:724)
       at android.icu.impl.TimeZoneNamesImpl$ZNames.getName(TimeZoneNamesImpl.java:790)
       at android.icu.impl.TimeZoneNamesImpl.getTimeZoneDisplayName(TimeZoneNamesImpl.java:183)
       at android.icu.text.TimeZoneNames.getDisplayName(TimeZoneNames.java:261)
       at java.util.TimeZone.getDisplayName(TimeZone.java:405)
       at java.util.TimeZone.getDisplayName(TimeZone.java:370)
       at com.facebook.internal.Utility.refreshTimezone(Utility.java:1066)
       at com.facebook.internal.Utility.refreshPeriodicExtendedDeviceInfo(Utility.java:1056)
       at com.facebook.internal.Utility.setAppEventExtendedDeviceInfoParameters(Utility.java:707)
       at com.facebook.internal.AppEventsLoggerUtility.getJSONObjectForGraphAPICall(AppEventsLoggerUtility.java:68)
       at com.facebook.FacebookSdk.publishInstallAndWaitForResponse(FacebookSdk.java:568)
       at com.facebook.FacebookSdk$4.run(FacebookSdk.java:547)
       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)

I have searched for this over the web but couldn't get anything useful. Please provide some pointers here.

like image 449
Swapnil Avatar asked Jul 21 '18 05:07

Swapnil


2 Answers

Yes, Even I am facing this kind of issue in my app while using volley library, Coming in devices having Android 8.0.1 version.

Fatal Exception: java.lang.AssertionError No NameTypeIndex match for SHORT_STANDARD

android.icu.impl.TimeZoneNamesImpl$ZNames.getNameTypeIndex 
(TimeZoneNamesImpl.java:724)
android.icu.impl.TimeZoneNamesImpl$ZNames.getName 
(TimeZoneNamesImpl.java:790)
android.icu.impl.TimeZoneNamesImpl.getTimeZoneDisplayName 
(TimeZoneNamesImpl.java:183)
android.icu.text.TimeZoneNames.getDisplayName (TimeZoneNames.java:261)
java.text.SimpleDateFormat.subFormat (SimpleDateFormat.java:1296)
java.text.SimpleDateFormat.format (SimpleDateFormat.java:1004)
java.text.SimpleDateFormat.format (SimpleDateFormat.java:974)
java.text.DateFormat.format (DateFormat.java:341)
com.android.volley.toolbox.HttpHeaderParser.formatEpochAsRfc1123 
(HttpHeaderParser.java:152)
com.android.volley.toolbox.BasicNetwork.getCacheHeaders 
(BasicNetwork.java:256)
com.android.volley.toolbox.BasicNetwork.performRequest 
(BasicNetwork.java:130)
com.android.volley.NetworkDispatcher.processRequest 
(NetworkDispatcher.java:120)
com.android.volley.NetworkDispatcher.run (NetworkDispatcher.java:87)

When I raised this issue on volley github, after checking they responded that this is device framework issue, means manufacture customized os bug. I feel we both are facing the same issue, as the lines where the bug actually starts is "android.icu.text.TimeZoneNames.getDisplayName(TimeZoneNames.java:261)" is same in both of our stacktraces. This is more of ICU package issue that is embedded in the framework. I found one personally forked Git class of a google developer which is a class of IBM icu, where the line number 722 " throw new AssertionError("No NameTypeIndex match for " + type);" is actually throwing the error in both of our cases. Let's hope Google comes up with the fixes or any workaround for the same. I may be wrong in my observation, do your own research.

like image 38
akashzincle Avatar answered Sep 17 '22 12:09

akashzincle


I am facing this issue too, upgrade the Facebook SDK to the latest (Facebook Android SDK 4.35), they have added a workaround for this issue:

 private static void refreshTimezone() {
    try {
        TimeZone tz = TimeZone.getDefault();
        deviceTimezoneAbbreviation = tz.getDisplayName(
                tz.inDaylightTime(new Date()),
                TimeZone.SHORT
        );
        deviceTimeZoneName = tz.getID();
    } catch (AssertionError e) {
      // Workaround for a bug in Android that can cause crashes on Android 8.0 and 8.1
    } catch (Exception e) {
    }
}
like image 148
Noam a Avatar answered Sep 19 '22 12:09

Noam a