简体   繁体   中英

Exception when using Glide Library

I'm trying to display a local pic with Glide:

protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
    final ImageView imageView = (ImageView) findViewById(R.id.backdrop);
    if (resultCode == RESULT_OK) {
        if (intent != null) {
            String picName = RutaActivity.getPicName(MyApplication.TAKE_PDV_PIC);
            String newPicPath = ImageUtils.saveLargePic((Activity) ctx, picName);
            Log.e("pic", newPicPath);
            Glide.with(ctx)
                    .load(newPicPath)
                    .asBitmap()
                    .toBytes()
                    .centerCrop()
                    .into(imageView);
        }
    }
}

I have checked the newPicPath, and path is OK but I got this exception... Message is not very explicit...Any idea?

 java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=10, result=-1, data=Intent { act=inline-data dat=content://media/external/images/media/206 (has extras) }} to activity {com.myapp.mobile/com.myapp.mobile.AddActivity}: java.lang.IllegalArgumentException: Unhandled class: class [B, try .as*(Class).transcode(ResourceTranscoder)
        at android.app.ActivityThread.deliverResults(ActivityThread.java:3187)
        at android.app.ActivityThread.handleSendResult(ActivityThread.java:3230)
        at android.app.ActivityThread.access$1200(ActivityThread.java:134)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1266)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:137)
        at android.app.ActivityThread.main(ActivityThread.java:4867)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:511)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1007)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:774)
        at dalvik.system.NativeStart.main(Native Method)
 Caused by: java.lang.IllegalArgumentException: Unhandled class: class [B, try .as*(Class).transcode(ResourceTranscoder)
        at com.bumptech.glide.request.target.ImageViewTargetFactory.buildTarget(ImageViewTargetFactory.java:24)
        at com.bumptech.glide.Glide.buildImageViewTarget(Glide.java:297)
        at com.bumptech.glide.GenericRequestBuilder.into(GenericRequestBuilder.java:697)
        at com.bumptech.glide.BitmapRequestBuilder.into(BitmapRequestBuilder.java:498)
        at com.myapp.mobile.AddActivity.onActivityResult(AddActivity.java:134)
        at android.app.Activity.dispatchActivityResult(Activity.java:5231)
        at android.app.ActivityThread.deliverResults(ActivityThread.java:3183)

I've just delete

toBytes()

and done!

No big deal! I prefer posting answer for those who will have the problem rather that delete post!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM