Android app crashes for some users when applying conversion with Picasso

I created an application in which some users (administrators) can log in to the administrator account on my web page and change some content, such as a background image in the application. As an end, I use Parse.com, and the application downloads the background image from there. I use Picasso to load background images in an application. In some actions, I want the background to blur , so I use this Blur Transformation and load the image using the following code:

int apiVersion = android.os.Build.VERSION.SDK_INT;
        if(apiVersion >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) {
            // Blur the image
            final BlurTransformation blurTransformation = new BlurTransformation(this, 20);
            // Load the background image with blur
            Picasso.with(this)
                    .load(backgroundPictureURL)
                    .transform(blurTransformation)
                    .into(backgroundView);
        } else {
            // Load the background image without blur
            Picasso.with(this)
                    .load(backgroundPictureURL)
                    .into(backgroundView);
        }

Parse, , . , :

java.lang.RuntimeException: Transformation blurred crashed with exception.
com.squareup.picasso.BitmapHunter$3.run                                         BitmapHunter.java:434
android.os.Handler.handleCallback                                               Handler.java:739
android.os.Handler.dispatchMessage                                              Handler.java:95
android.os.Looper.loop                                                          Looper.java:135
android.app.ActivityThread.main                                                 ActivityThread.java:5254
java.lang.reflect.Method.invoke                                                 Native Method
java.lang.reflect.Method.invoke                                                 Method.java:372
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run                      ZygoteInit.java:898
com.android.internal.os.ZygoteInit.main                                         ZygoteInit.java:693
Caused by: android.renderscript.RSIllegalArgumentException: Bitmap has an unsupported format for this operation
android.renderscript.Allocation.validateBitmapFormat                            Allocation.java:537
android.renderscript.Allocation.copyTo                                          Allocation.java:1257
se.myapplication.main.CustomUI.BlurTransformation.transform                       BlurTransformation.java:60
com.squareup.picasso.BitmapHunter.applyCustomTransformations                    BitmapHunter.java:429
com.squareup.picasso.BitmapHunter.hunt                                          BitmapHunter.java:238
com.squareup.picasso.BitmapHunter.run                                           BitmapHunter.java:159
java.util.concurrent.Executors$RunnableAdapter.call                             Executors.java:422
java.util.concurrent.FutureTask.run                                             FutureTask.java:237
java.util.concurrent.ThreadPoolExecutor.runWorker                               ThreadPoolExecutor.java:1112
java.util.concurrent.ThreadPoolExecutor$Worker.run                              ThreadPoolExecutor.java:587
java.lang.Thread.run                                                            Thread.java:818
com.squareup.picasso.Utils$PicassoThread.run                                    Utils.java:411

Blur Transformation, , - :

output.copyTo(blurredBitmap);

- jpg, png, - , , , , Android 5.0.1 5.0.2 ( , ).

, ! ?

+4
2

5 6 !

0

:

Caused by: android.renderscript.RSIllegalArgumentException: Bitmap has an unsupported format for this operation

. , , (, *.img, *.jpg, *.png).

, , bmp, "". BMP, .jpg . , , , ( ).

0

Source: https://habr.com/ru/post/1598709/


All Articles