Ion crashes NoClassDefFoundError and IllegalArgumentException

314 Views Asked by At

I am getting these crashes in my app using Ion ImageLoader to load images in the app

the first issue i really dont what is causing this

 java.lang.NoClassDefFoundError: com.koushikdutta.ion.IonRequestBuilder$6
    at com.koushikdutta.ion.IonRequestBuilder.execute(IonRequestBuilder.java:610)
    at com.koushikdutta.ion.BitmapFetcher.execute(BitmapFetcher.java:134)
    at com.koushikdutta.ion.IonDrawable.draw(IonDrawable.java:494)
    at android.widget.ImageView.onDraw(ImageView.java:858)

the second issue is when i try to get a Circle ImageView

 java.lang.IllegalArgumentException: Cannot draw recycled bitmaps
    at android.view.GLES20Canvas.drawBitmap(GLES20Canvas.java:789)
    at android.view.GLES20RecordingCanvas.drawBitmap(GLES20RecordingCanvas.java:118)
    at com.koushikdutta.ion.IonDrawable.draw(IonDrawable.java:673)
    at android.widget.ImageView.onDraw(ImageView.java:990)
    at android.view.View.draw(View.java:14313)

here is the code I am using to Circle ImageView

 public class CircleTransform implements Transform {

    @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 */;

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

        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,
                BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP);
        paint.setShader(shader);
        paint.setAntiAlias(true);

        float r = size / 2f/* 2f */;
        canvas.drawCircle(r, r, r, paint);

        squaredBitmap.recycle();
        return bitmap;
    }

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

the Library works fine and easy to use but I want to solve these crashes I am using the latest version of Ion

0

There are 0 best solutions below