react-native-gallery-manager icon indicating copy to clipboard operation
react-native-gallery-manager copied to clipboard

Android crash: CursorIndexOutOfBoundsException

Open albullington opened this issue 6 years ago • 0 comments

I'm getting this crash pretty consistently on Android in my pre-launch reports and also on a few production devices. Error handling doesn't seem to help.

android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0
	at android.database.AbstractCursor.checkPosition(AbstractCursor.java:460)
	at android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java:136)
	at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:50)
	at android.database.CursorWrapper.getString(CursorWrapper.java:137)
	at org.pentarex.rngallerymanager.RNGalleryManagerModule.getAlbum(RNGalleryManagerModule.java:170)
	at org.pentarex.rngallerymanager.RNGalleryManagerModule.getAlbums(RNGalleryManagerModule.java:120)

Here is my code:

const { albumNames } = this.state;

GalleryManager.getAlbums().then( ( results ) => {
      const { albums } = results;
      if ( albums && albums.length > 0 ) {
        albums.forEach( ( album ) => {
          const { assetCount, title } = album;

          if ( assetCount > 0 ) {
            albumNames.push( {
              label: title,
              value: title
            } );
          }
        } );
      }

      this.setState( { albumNames } );
    } ).catch( () => {
      this.setState( { albumNames } );
    } );

albullington avatar Oct 30 '19 21:10 albullington