IllegalStateException в com.squareup.picasso.BitmapHunterAndroid

Форум для тех, кто программирует под Android
Ответить Пред. темаСлед. тема
Гость
 IllegalStateException в com.squareup.picasso.BitmapHunter

Сообщение Гость »


В Android Vitals появляется отчет об исключении без точного отслеживания:

Код: Выделить всё

Exception java.lang.IllegalStateException: Transformation circle mutated input Bitmap but failed to recycle the original.
at com.squareup.picasso.BitmapHunter$6.run (BitmapHunter.java:490)
at android.os.Handler.handleCallback (Handler.java:942)
at android.os.Handler.dispatchMessage (Handler.java:99)
at android.os.Looper.loopOnce (Looper.java:226)
at android.os.Looper.loop (Looper.java:313)
at android.app.ActivityThread.main (ActivityThread.java:8762)
at java.lang.reflect.Method.invoke
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:604)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1067)


I roughly understand which part of the code is causing the error, here it is:

Код: Выделить всё

    public static class CircleTransform implements Transformation {
@Override
public Bitmap transform(Bitmap source) {

int size = Math.min(source.getWidth(), source.getHeight());

int x = (source.getWidth() - size) / 2;
int y = (source.getHeight() - size) / 2;

Bitmap squaredBitmap = Bitmap.createBitmap(source, x, y, size, size);
if (squaredBitmap != source) {
source.recycle();
}

Bitmap bitmap = Bitmap.createBitmap(size, size, source.getConfig());

Canvas canvas = new Canvas(bitmap);
Paint paint = new Paint();
BitmapShader shader = new BitmapShader(squaredBitmap,
Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
paint.setShader(shader);
paint.setAntiAlias(true);

float r = size / 2f;

canvas.drawCircle(r, r, r, paint);

squaredBitmap.recycle();
return bitmap;
}

@Override
public String key() {
return "circle";
}
}


On test devices it is not possible to catch this exception; it occurs only for some users.
If anyone has any ideas on how to fix this exception I would be grateful.


Источник: https://stackoverflow.com/questions/781 ... tmaphunter
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение
  • IllegalStateException в com.squareup.picasso.BitmapHunter
    Гость » » в форуме JAVA
    0 Ответы
    19 Просмотры
    Последнее сообщение Гость
  • Не удалось найти com.squareup.moshi:moshi-kotlin-reflect:1.15.1
    Anonymous » » в форуме Android
    0 Ответы
    20 Просмотры
    Последнее сообщение Anonymous
  • Ошибка «Невозможно устранить com.squareup.okhttp3:mockwebserver:unknown» после обновления до Spring Boot 3.4.0
    Anonymous » » в форуме JAVA
    0 Ответы
    13 Просмотры
    Последнее сообщение Anonymous
  • Ошибка «Невозможно устранить com.squareup.okhttp3:mockwebserver:unknown» после обновления до Spring Boot 3.4.0
    Anonymous » » в форуме JAVA
    0 Ответы
    26 Просмотры
    Последнее сообщение Anonymous
  • Почему зависимости qksms от Squareup okhttp вызывают ошибки?
    Anonymous » » в форуме JAVA
    0 Ответы
    12 Просмотры
    Последнее сообщение Anonymous

Вернуться в «Android»