Android Calendar Crashes java.lang.NumberFormatException

#1

Hello, Ive been using the Calendar API for some time now. But recently I noticed some crashes in my app.

Im sure I have permissions to use calendars.
This is my import import {Calendar as NativeCalendar, Permissions} from "expo";

And this is what i use to make sure I have permissions

    askForCalendarPermissions = async () => {
        const calendarPermissions = await Permissions.askAsync(Permissions.CALENDAR);

        return calendarPermissions.status === 'granted';
    };

The crash occurs when i call:
const eventCalendars = await NativeCalendar.getCalendarsAsync(NativeCalendar.EntityTypes.EVENT);

I get no bug report from XDE but in Google Play Console I get this error (on multiple devices)
It has occurred on Android 8.0 and Android 7.0

java.lang.NumberFormatException: 
  at java.lang.Integer.parseInt (Integer.java:597)
  at java.lang.Integer.parseInt (Integer.java:643)
  at abi27_0_0.host.exp.exponent.modules.api.CalendarModule.calendarAllowedAttendeeTypesFromDBString (CalendarModule.java:1147)
  at abi27_0_0.host.exp.exponent.modules.api.CalendarModule.serializeEventCalendar (CalendarModule.java:1353)
  at abi27_0_0.host.exp.exponent.modules.api.CalendarModule.serializeEventCalendars (CalendarModule.java:1332)
  at abi27_0_0.host.exp.exponent.modules.api.CalendarModule.findCalendars (CalendarModule.java:318)
  at abi27_0_0.host.exp.exponent.modules.api.CalendarModule.access$000 (CalendarModule.java:41)
  at abi27_0_0.host.exp.exponent.modules.api.CalendarModule$1.run (CalendarModule.java:70)
  at android.os.AsyncTask$SerialExecutor$1.run (AsyncTask.java:245)
  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)

Please fix this bug!

#2

Hi-

I made a Snack that is basically your code.
It seems to work on my Android phone.
https://snack.expo.io/S1Vt9RPxQ

Does this work for you?

#3

Nope It crashes.

Whats wierd is that i got promted twice about permissons. Its the same in my app.
Maybe its unrelated but still weird.

Im also aware that this bug doesn’t affect all android devices, since Ive tried it on multiple devices.

#4

What device do you have? It sounds like a bug.
Can you file a Github issue here?

#5

Here is the github issue for reference https://github.com/expo/expo/issues/1853

#6

Thanks for filing an issue! It’s much appreciated.

closed #7

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.