Nozbe / WatermelonDB

🍉 Reactive & asynchronous database for powerful React and React Native apps ⚡️
https://watermelondb.dev
MIT License
10.49k stars 589 forks source link

@nozbe/watermelondb Error: Row too big to fit into CursorWindow requiredPos=4, totalRows=5 #1721

Open HanHuynh91 opened 9 months ago

HanHuynh91 commented 9 months ago

Query Select throw error Error: Row too big to fit into CursorWindow requiredPos=4, totalRows=5 in watermelondb in react native app

joaosodres commented 5 months ago

Same problem here, how did you solve it?

henrypadua commented 5 months ago

Hello @joaosodres and @joaosodres, follow the solution below:

Go to android/app/src/main/java and in your MainActivity.kt or MainApplication.java on method onCreate and add the import and code below

For Kotlin:

// The import must be use on the top togheter others imports
import android.database.CursorWindow

try {
      val field = CursorWindow::class.java.getDeclaredField("sCursorWindowSize")
      field.isAccessible = true
      field.set(null, 100 * 1024 * 1024) //the 100MB is the new size
    } catch (e: Exception) {
      if (DEBUG_MODE) {
        e.printStackTrace()
      }
    }

example image

For Java:

// The import must be use on the top togheter others imports
import android.database.CursorWindow;
import java.lang.reflect.Field;

try {
  Field field = CursorWindow.class.getDeclaredField("sCursorWindowSize");
  field.setAccessible(true);
  field.set(null, 100 * 1024 * 1024); // 100MB is the new size
} catch (Exception e) {
  if (BuildConfig.DEBUG) {
    e.printStackTrace();
  }
}

example image

radex commented 5 months ago

Would highly encourage anyone to contribute these snippets by @henrypadua to the official docs under Android troubleshooting

joaosodres commented 5 months ago

Unfortunately I've already done that and it didn't work