Wednesday, August 13, 2014

Solution/Precaution to avoid android.os.TransactionTooLargeException

Exception: :mad:

 java.lang.RuntimeException: android.os.TransactionTooLargeException  
 at android.accounts.AccountManager.addAccountExplicitly(  

Reason: ;))

The Binder transaction failed because it was too large.
During a remote procedure call, the arguments and the return value of the call are transferred as Parcel objects stored in the Binder transaction buffer. If the arguments or the return value are too large to fit in the transaction buffer, then the call will fail and TransactionTooLargeException will be thrown.

Possibility Cases: :-w 

There are two possible outcomes when a remote procedure call throws TransactionTooLargeException.

  • Either the client was unable to send its request to the service (most likely if the arguments were too large to fit in the transaction buffer).
  • The service was unable to send its response back to the client (most likely if the return value was too large to fit in the transaction buffer).
It is not possible to tell which of these outcomes actually occurred. The client should assume that a partial failure occurred.

Assumption: :-?

While adding account to AccountManager. Adds an account directly to the AccountManager with the help of service call.
When there is a huge amount of data getting exchanged between a service and an application, we will get android.os.TransactionTooLargeException.

Solution/Precaution to avoid android.os.TransactionTooLargeException *-:)

We don't have direct solution but we can take precaution to avoid exception.
  1. Try to keep all transactions relatively small.
  2. Do not exchange huge data (roughly not greater than 512KB) between services and application because the Binder transaction buffer has a limited fixed size, currently 1Mb, which is shared by all transactions in progress for the process. 

Thanks for reading :) 
Whether this post is helpful?

Have something to add to this post? If you have any other quick thoughts/hints that you think people will find useful? Share it in the comments and feedback are welcome...

No comments :

Post a Comment