Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android.os.TransactionTooLargeException: data parcel size NOUGAT ERROR

I am making an api call using RETROFIT, I got the JSON response from the server which is hardly 30kb in size. While the JSON parses the response into a complex Object, it is throwing this error.

java.lang.RuntimeException: android.os.TransactionTooLargeException: data parcel size 1098852 bytes
    at android.app.servertransaction.PendingTransactionActions$StopInfo.run(PendingTransactionActions.java:161)
    at android.os.Handler.handleCallback(Handler.java:883)
    at android.os.Handler.dispatchMessage(Handler.java:100)
    at android.os.Looper.loop(Looper.java:214)
    at android.app.ActivityThread.main(ActivityThread.java:7356)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
 Caused by: android.os.TransactionTooLargeException: data parcel size 1098852 bytes
    at android.os.BinderProxy.transactNative(Native Method)
    at android.os.BinderProxy.transact(BinderProxy.java:510)
    at android.app.IActivityTaskManager$Stub$Proxy.activityStopped(IActivityTaskManager.java:4524)
    at android.app.servertransaction.PendingTransactionActions$StopInfo.run(PendingTransactionActions.java:145)
    at android.os.Handler.handleCallback(Handler.java:883) 
    at android.os.Handler.dispatchMessage(Handler.java:100) 
    at android.os.Looper.loop(Looper.java:214) 
    at android.app.ActivityThread.main(ActivityThread.java:7356) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

If I try to store the response in an Object class, and then get values via LinkedHashMap, I am able to fetch the data. But, it will be a tedious process.

Can anyone please help me to figure out what the issue here is and how to find a solution ?

According to my research this only happens to android devices with version >= Nougat. Below that, it works like a piece of cake.

I have also tried some of the solutions mentioned in: --> onSaveInstanceState.clear() - but this does not work. you can find the post here

like image 602
WanneBeeNerd Avatar asked Sep 15 '19 05:09

WanneBeeNerd


1 Answers

This is the typical error when you put a large amount of data into Bundle of Android.

I would suggest you do it right. The large data has to persistent to disk (either database or files) and you only pass the reference of this data to other places to consume it.

Here you may find 30kb is small, but the actual configuration of size limit for Bundle may be various from different devices/vendors configurations.

The Bundle was meant to keep simple and small data only, don't over-abuse it.

like image 58
toantran Avatar answered Nov 10 '22 08:11

toantran