Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Bitmpafun crashes at BitmapFactory.decodeFileDescriptor

Tags:

android

bitmap

I am using Bitmapfun application of android for loading bitmaps effectively.But sometimes a crash is occured at BitmapFactory.decodeFileDescriptor(). Log cat and function is given below.Crash occurs at the return statement. Please help me.Thanks in advance.

 public static Bitmap decodeSampledBitmapFromDescriptor(
        FileDescriptor fileDescriptor, int reqWidth, int reqHeight, ImageCache cache) {

    // First decode with inJustDecodeBounds=true to check dimensions
    final BitmapFactory.Options options = new BitmapFactory.Options();
    options.inJustDecodeBounds = true;
    BitmapFactory.decodeFileDescriptor(fileDescriptor, null, options);

    // Calculate inSampleSize
    options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight);

    // Decode bitmap with inSampleSize set
    options.inJustDecodeBounds = false;

    // If we're running on Honeycomb or newer, try to use inBitmap
    if (Utils.hasHoneycomb()) {
        addInBitmapOptions(options, cache);
    }

    return BitmapFactory.decodeFileDescriptor(fileDescriptor, null, options);
}

Logcat

  06-25 14:20:56.055: E/AndroidRuntime(5978): FATAL EXCEPTION: AsyncTask #3
06-25 14:20:56.055: E/AndroidRuntime(5978): java.lang.RuntimeException: An error occured while executing doInBackground()
06-25 14:20:56.055: E/AndroidRuntime(5978):     at com.vbk.vobok.util.AsyncTask$3.done(AsyncTask.java:325)
06-25 14:20:56.055: E/AndroidRuntime(5978):     at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
06-25 14:20:56.055: E/AndroidRuntime(5978):     at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
06-25 14:20:56.055: E/AndroidRuntime(5978):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
06-25 14:20:56.055: E/AndroidRuntime(5978):     at java.util.concurrent.FutureTask.run(FutureTask.java:137)
06-25 14:20:56.055: E/AndroidRuntime(5978):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
06-25 14:20:56.055: E/AndroidRuntime(5978):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
06-25 14:20:56.055: E/AndroidRuntime(5978):     at java.lang.Thread.run(Thread.java:856)
06-25 14:20:56.055: E/AndroidRuntime(5978): Caused by: java.lang.IllegalArgumentException: Problem decoding into existing bitmap
06-25 14:20:56.055: E/AndroidRuntime(5978):     at android.graphics.BitmapFactory.decodeFileDescriptor(BitmapFactory.java:664)
06-25 14:20:56.055: E/AndroidRuntime(5978):     at com.vbk.vobok.util.ImageResizer.decodeSampledBitmapFromDescriptor(ImageResizer.java:196)
06-25 14:20:56.055: E/AndroidRuntime(5978):     at com.vbk.vobok.util.ImageFetcher.processBitmap(ImageFetcher.java:242)
06-25 14:20:56.055: E/AndroidRuntime(5978):     at com.vbk.vobok.util.ImageFetcher.processBitmap(ImageFetcher.java:255)
06-25 14:20:56.055: E/AndroidRuntime(5978):     at com.vbk.vobok.util.ImageWorker$BitmapWorkerTask.doInBackground(ImageWorker.java:326)
06-25 14:20:56.055: E/AndroidRuntime(5978):     at com.vbk.vobok.util.ImageWorker$BitmapWorkerTask.doInBackground(ImageWorker.java:1)
06-25 14:20:56.055: E/AndroidRuntime(5978):     at com.vbk.vobok.util.AsyncTask$2.call(AsyncTask.java:313)
06-25 14:20:56.055: E/AndroidRuntime(5978):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
06-25 14:20:56.055: E/AndroidRuntime(5978):     ... 4 more
like image 517
user1767260 Avatar asked Jun 25 '13 08:06

user1767260


1 Answers

I had faced the same issue, where in I deleted the method addInBitmapOptions at ImageResizer.java,and the bug was fixed.

like image 80
user2914737 Avatar answered Sep 27 '22 16:09

user2914737