error: package com.bumptech.glide.request.animation does not exist

error: package com.bumptech.glide.request.animation does not exist

我在应用 gradle 中添加了以下软件包:

implementation 'com.github.bumptech.glide:glide:4.8.0'
annotationProcessor 'com.github.bumptech.glide:glide:4.8.0'

但是当 运行 低于错误时:

错误:包 com.bumptech.glide.request.animation 不存在

有人遇到过这种情况吗?

GladeAnimation 已被 Transition 取代,所以现在

onResourceReady(GlideDrawable drawable, GlideAnimation<? super GlideDrawable> anim) 

你应该使用

onResourceReady(Drawable drawable, Transition<? super Drawable> transition);

您应该检查 official site 中所有不同的迁移更改。

干杯!

对于版本 3,您曾经喜欢这样:

   private void setFeedImage(Uri imageUrl,File file) {
        BitmapImageViewTarget target = new BitmapImageViewTarget(feedImage) {

     @Override
            public void onResourceReady(final Bitmap bitmap,GlideAnimation anim) {
                super.onResourceReady(bitmap,anim);
                feedImage.setImageBitmap(bitmap);

                ByteArrayOutputStream stream = new ByteArrayOutputStream();
                bitmap.compress(Bitmap.CompressFormat.PNG,0,stream);
                byte[] bitmapBytes = stream.toByteArray();

                ParseFile image = new ParseFile("postImage",bitmapBytes);
                post.setPostImage(image);

            }

            @Override
            public void onLoadFailed(Exception e,Drawable errorDrawable) {
                super.onLoadFailed(e,errorDrawable);
                feedImage.setImageDrawable(errorDrawable);
            }

            @Override
            public void onLoadStarted(Drawable placeholder) {
                super.onLoadStarted(placeholder);
                feedImage.setImageDrawable(placeholder);
            }

但对于版本 4,您应该像这样使用而不是顶部代码:

  private void setFeedImage(Uri imageUrl,File file) {
            BitmapImageViewTarget target = new BitmapImageViewTarget(feedImage) {

                @Override
                public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
                    super.onResourceReady(resource, transition);

                    feedImage.setImageBitmap(resource);

                    ByteArrayOutputStream stream = new ByteArrayOutputStream();
                    resource.compress(Bitmap.CompressFormat.PNG,0,stream);
                    byte[] bitmapBytes = stream.toByteArray();

                    ParseFile image = new ParseFile("postImage",bitmapBytes);
                    post.setPostImage(image);
                }

                @Override
                public void onLoadFailed(@Nullable Drawable errorDrawable) {
                    super.onLoadFailed(errorDrawable);
                    feedImage.setImageDrawable(errorDrawable);
                }

                @Override
                public void onLoadStarted(@Nullable Drawable placeholder) {
                    super.onLoadStarted(placeholder);
                    feedImage.setImageDrawable(placeholder);
                }
            };

将您的 gradle 更新为:

实施'com.github.bumptech.glide:glide:3.+' 注解处理器 'com.github.bumptech.glide:glide:4.8.0'