React native app crashes due to some out of memory error how to fix this

2.3k Views Asked by At

Because of the below error app crashes , i couldn't figure out what is the exact problem and what is the cause

java.lang.RuntimeException: 
      at com.facebook.react.bridge.JavaMethodWrapper.invoke (JavaMethodWrapper.java:383)
      at com.facebook.react.bridge.JavaModuleWrapper.invoke (JavaModuleWrapper.java:160)
      at com.facebook.react.bridge.queue.NativeRunnable.run (Native Method)
      at android.os.Handler.handleCallback (Handler.java:751)
      at android.os.Handler.dispatchMessage (Handler.java:95)
      at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage (MessageQueueThreadHandler.java:29)
      at android.os.Looper.loop (Looper.java:154)
      at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run (MessageQueueThreadImpl.java:192)
      at java.lang.Thread.run (Thread.java:762)
    Caused by: java.lang.reflect.InvocationTargetException: 
      at java.lang.reflect.Method.invoke (Native Method)
      at com.facebook.react.bridge.JavaMethodWrapper.invoke (JavaMethodWrapper.java:372)
    Caused by: java.lang.OutOfMemoryError: 
      at java.lang.AbstractStringBuilder.<init> (AbstractStringBuilder.java:64)
      at java.lang.StringBuilder.<init> (StringBuilder.java:98)
      at libcore.net.UriCodec.decode (UriCodec.java:273)
      at android.net.Uri.decode (Uri.java:1946)
      at android.net.Uri$AbstractPart.getDecoded (Uri.java:1976)
      at android.net.Uri$StringUri.getSchemeSpecificPart (Uri.java:560)
      at cl.json.ShareFile.isBase64File (ShareFile.java:66)
      at cl.json.ShareFile.isFile (ShareFile.java:61)
      at cl.json.social.ShareIntent.open (ShareIntent.java:74)
      at cl.json.social.GenericShare.open (GenericShare.java:18)
      at cl.json.RNShareModule.open (RNShareModule.java:94)
1

There are 1 best solutions below

0
On

My understanding is that there are two ways to analyze this:

  1. Integrate a tool like Crashlytics in your app and let it help you
  2. Try to figure out which part of your code caused this. This is possible if the crash occurs when you do something specific in the app which causes the crash. If it happens arbitrarily, this approach won't work. If, however, the crash happens when you render a specific component, or when you execute a specific function, then you can try commenting out parts of the code, and by trial-and-error, pinpoint the problematic code.

I used both approaches. The first one is easier, but it requires one-time integration work.

If you use expo, you should use Sentry instead of Crashlytics.