Reputation: 1725
My code was working perfectly, but today i was getting this exception, can anyone help?Log is attached Thanks
10-03 13:33:50.141 15352-17764/com.shahzain.ada E/StorageException: StorageException has occurred.
An unknown error occurred, please check the HTTP result code and inner exception for server response.
Code: -13000 HttpResult: 200
10-03 13:33:50.141 15352-17764/com.shahzain.ada E/StorageException: the maximum allowed buffer size was exceeded.
java.lang.IndexOutOfBoundsException: the maximum allowed buffer size was exceeded.
at com.google.firebase.storage.StorageReference$5.doInBackground(Unknown Source)
at com.google.firebase.storage.StreamDownloadTask.run(Unknown Source)
at com.google.firebase.storage.StorageTask$8.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
10-03 13:33:50.141 15352-17764/com.shahzain.ada E/StorageException: StorageException has occurred.
An unknown error occurred, please check the HTTP result code and inner exception for server response.
Code: -13000 HttpResult: 200
10-03 13:33:50.141 15352-17764/com.shahzian.ada E/StorageException: the maximum allowed buffer size was exceeded.
java.lang.IndexOutOfBoundsException: the maximum allowed buffer size was exceeded.
at com.google.firebase.storage.StorageReference$5.doInBackground(Unknown Source)
at com.google.firebase.storage.StreamDownloadTask.run(Unknown Source)
at com.google.firebase.storage.StorageTask$8.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
here is code, which is for downloading content from firebase storage
final long ONE_MEGABYTE = 1024 * 1024;
islandRef.getBytes(ONE_MEGABYTE).addOnSuccessListener(new OnSuccessListener<byte[]>() {
@Override
public void onSuccess(byte[] bytes) {
// Data for "images/island.jpg" is returns, use this as needed
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
// Handle any errors
}
});
Upvotes: 2
Views: 3136
Reputation: 69
I think the best solution is use another download method. Because it must load the entire contents of your file into memory. If you request a file larger than your app's available memory, your app will crash.
You should use download Data via URL:
storageRef.child("users/me/profile.png").
getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
// Got the download URL for 'users/me/profile.png'
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
// Handle any errors
}
});
And in your imageview
, you use Glide
to show it:
Glide.with(MainActivity.this)
.load(mFirebaseUser.getPhotoUrl())
.into(mYourImageView);`
Upvotes: -2
Reputation: 1
Please check that google play services are up to date.If not update it. If it is up to date clear the cache memory of google play services.
Upvotes: -1
Reputation: 1725
I have fixed above problem by exceeding size in code first size was 1mb , later I increased it to 5mb.
final long ONE_MEGABYTE = 1024 * 1024;
change this to larger size like
final long ONE_MEGABYTE = 1024 * 1024 *5;
Upvotes: 14