Firebase Google causes java.lang.StackOverflowError

The size of the data you are attempting to store with setValue() is probably too large, most likely caused by the bitmap data.

Data can be passed between Android components using Parcels, but the amount of data is limited to 1MB. The TransactionTooLargeException occurred because some component, either one of yours or one of the Firebase components handling your requests, attempted to send a parcel that contained more than 1MB of data. The reports you see of garbage collection running repeatedly is another indication that your processing is requesting large amounts of memory.

Does this new question mean you are no longer seeking help with your other question? If so, cancel the bounty.

The TVSet.compressImage() method in the code posted for your other question shows that you are Base64 encoding a full size image and storing the result. This is part of the data you are hoping to store in your database. This is not the best use of FirebaseDatabase. Consider using FirebaseStorage to store the images with only the file name or other identifying key stored in your database.


Got this error when saving the Uri of an Image I was saving on Firebase Storage to Firebase Database.

Like @Mwakima mentioned, you cannot save a Uri to Firebase Database.

Solution: Change the type of your uri in the model class to String, get the String from

String uri = taskSnapshot.getDownloadUrl().toString()

When you get the String back from Firebase, pass it to a Uri using

Uri imageUri = Uri.Parse(<your-uri-as-a-string>);


As for me I decided to try and make my instances of the class into primitive type.

I had a variable that was holding the URI of an image saved as a URI.

private String userName;
private String userProfilePic;
private String userEmail;
private Uri userUid;
private int userFollowersCount = 0;
private int userFollowingCount = 0;
private int age;
private String userStatus;
private String userLikedPostsUID;
private String userSharedPostsUID;

I got the Transaction too large error. But after changing userUid into a String it worked like a charm.

So try to save your instances into a primitive form. Like in your example. Try to change 'TvEvent tvEvent' to store only the UID of the tvEvent in a String form.