无法使用来自 Firebase 的 Glide 库加载个人资料图片

Unable to load Profile Picture using Glide Library from Firebase

我正在尝试加载在 firebase 中上传的个人资料图片。我正在使用 Glide 库将图像加载到使用 this 库的圆形图像视图中。

我已经尝试了这两种方法,即使用 Firebase UI 和使用 getDownlodUrl() 方法获取 uri。

我能够成功下载 URL 但是 glide 给我一个我无法理解的错误。

我尝试用谷歌搜索错误,但无济于事。请大家帮忙看看哪里错了

这是日志:

2019-07-06 19:32:37.149 21919-23194/com.avalonglobalresearch.creatives      D/skia: --- Failed to create image decoder with message 'unimplemented'
2019-07-06 19:32:37.156 21919-23194/com.avalonglobalresearch.creatives    I/chatty: uid=10160(com.avalonglobalresearch.creatives) glide-source-th identical 6 lines
2019-07-06 19:32:37.157 21919-23194/com.avalonglobalresearch.creatives D/skia: --- Failed to create image decoder with message 'unimplemented'
2019-07-06 19:32:37.186 21919-21919/com.avalonglobalresearch.creatives W/Glide: Load failed for gs://creatives-4ebde.appspot.com/ with size [406x378]
class com.bumptech.glide.load.engine.GlideException: Failed to load resource
There were 4 causes:
java.io.IOException(java.lang.RuntimeException: setDataSource failed: status = 0x80000000)
java.io.IOException(java.lang.RuntimeException: setDataSource failed: status = 0x80000000)
java.io.IOException(java.lang.RuntimeException: setDataSource failed: status = 0x80000000)
java.io.IOException(java.lang.RuntimeException: setDataSource failed: status = 0x80000000)
 call GlideException#logRootCauses(String) for more detail
  Cause (1 of 6): class com.bumptech.glide.load.engine.GlideException: Failed LoadPath{DirectByteBuffer->Object->Drawable}, DATA_DISK_CACHE, com.firebase.ui.storage.images.FirebaseImageLoader$FirebaseStorageKey@bf00ba2
    Cause (1 of 3): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{DirectByteBuffer->GifDrawable->Drawable}
    Cause (2 of 3): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{DirectByteBuffer->Bitmap->Drawable}
    Cause (3 of 3): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{DirectByteBuffer->BitmapDrawable->Drawable}
  Cause (2 of 6): class com.bumptech.glide.load.engine.GlideException: Failed LoadPath{FileInputStream->Object->Drawable}, DATA_DISK_CACHE, com.firebase.ui.storage.images.FirebaseImageLoader$FirebaseStorageKey@bf00ba2
    Cause (1 of 3): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{FileInputStream->GifDrawable->Drawable}
    Cause (2 of 3): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{FileInputStream->Bitmap->Drawable}
    Cause (3 of 3): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{FileInputStream->BitmapDrawable->Drawable}
  Cause (3 of 6): class com.bumptech.glide.load.engine.GlideException: Failed LoadPath{ParcelFileDescriptor->Object->Drawable}, DATA_DISK_CACHE, com.firebase.ui.storage.images.FirebaseImageLoader$FirebaseStorageKey@bf00ba2
There were 2 causes:
java.io.IOException(java.lang.RuntimeException: setDataSource failed: status = 0x80000000)
java.io.IOException(java.lang.RuntimeException: setDataSource failed: status = 0x80000000)
 call GlideException#logRootCauses(String) for more detail
    Cause (1 of 2): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{ParcelFileDescriptor->Bitmap->Drawable}
There was 1 cause:
java.io.IOException(java.lang.RuntimeException: setDataSource failed: status = 0x80000000)
 call GlideException#logRootCauses(String) for more detail
      Cause (1 of 1): class java.io.IOException: java.lang.RuntimeException: setDataSource failed: status = 0x80000000
    Cause (2 of 2): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{ParcelFileDescriptor->BitmapDrawable->Drawable}
There was 1 cause:
java.io.IOException(java.lang.RuntimeException: setDataSource failed: status = 0x80000000)
 call GlideException#logRootCauses(String) for more detail
      Cause (1 of 1): class java.io.IOException: java.lang.RuntimeException: setDataSource failed: status = 0x80000000
  Cause (4 of 6): class com.bumptech.glide.load.engine.GlideException: Failed LoadPath{DirectByteBuffer->Object->Drawable}, REMOTE, com.firebase.ui.storage.images.FirebaseImageLoader$FirebaseStorageKey@bf00ba2
    Cause (1 of 3): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{DirectByteBuffer->GifDrawable->Drawable}
    Cause (2 of 3): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{DirectByteBuffer->Bitmap->Drawable}
    Cause (3 of 3): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{DirectByteBuffer->BitmapDrawable->Drawable}
  Cause (5 of 6): class com.bumptech.glide.load.engine.GlideException: Failed LoadPath{FileInputStream->Object->Drawable}, REMOTE, com.firebase.ui.storage.images.FirebaseImageLoader$FirebaseStorageKey@bf00ba2
 2019-07-06 19:32:37.187 21919-21919/com.avalonglobalresearch.creatives W/Glide:    Cause (1 of 3): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{FileInputStream->GifDrawable->Drawable}
    Cause (2 of 3): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{FileInputStream->Bitmap->Drawable}
    Cause (3 of 3): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{FileInputStream->BitmapDrawable->Drawable}
  Cause (6 of 6): class com.bumptech.glide.load.engine.GlideException: Failed LoadPath{ParcelFileDescriptor->Object->Drawable}, REMOTE, com.firebase.ui.storage.images.FirebaseImageLoader$FirebaseStorageKey@bf00ba2
There were 2 causes:
java.io.IOException(java.lang.RuntimeException: setDataSource failed: status = 0x80000000)
java.io.IOException(java.lang.RuntimeException: setDataSource failed: status = 0x80000000)
 call GlideException#logRootCauses(String) for more detail
    Cause (1 of 2): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{ParcelFileDescriptor->Bitmap->Drawable}
There was 1 cause:
java.io.IOException(java.lang.RuntimeException: setDataSource failed: status = 0x80000000)
 call GlideException#logRootCauses(String) for more detail
      Cause (1 of 1): class java.io.IOException: java.lang.RuntimeException: setDataSource failed: status = 0x80000000
    Cause (2 of 2): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{ParcelFileDescriptor->BitmapDrawable->Drawable}
There was 1 cause:
java.io.IOException(java.lang.RuntimeException: setDataSource failed: status = 0x80000000)
 call GlideException#logRootCauses(String) for more detail
      Cause (1 of 1): class java.io.IOException: java.lang.RuntimeException: setDataSource failed: status = 0x80000000
2019-07-06 19:32:37.190 21919-21919/com.avalonglobalresearch.creatives I/Glide: Root cause (1 of 4)
java.io.IOException: java.lang.RuntimeException: setDataSource failed: status = 0x80000000

这是我的代码:

databaseReference = FirebaseDatabase.getInstance().getReference();
storageReference = FirebaseStorage.getInstance().getReference();

databaseReference.child("users").child(user.getUid()).addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot){
            name2 = (String) dataSnapshot.child("name").getValue();
            bio2 = (String) dataSnapshot.child("bio").getValue();

            //imageUri = (URL) dataSnapshot.child("profilePic").getValue();
            String gender = (String) dataSnapshot.child("gender").getValue();
            String email = (String) dataSnapshot.child("email").getValue();

            Log.d("TAG", "Name: " +name2);
            Log.d("TAG", "Email: " +email);
            Log.d("TAG", "Gender: " +gender);
            Log.d("TAG" , "Profile Pic URI = "+imageUri);
            nameTextView.setText(name2);
            bioTextView.setText(bio2);
            String uid = user.getUid();
            Log.d("TAG" , "UID = " +uid);
            storageReference.child("ProfilePictures").child(uid+".jpg");
            GlideApp.with(getActivity()).load(storageReference).into(test);

            /*storageReference.child("ProfilePictures").child(uid+".jpg").getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
                @Override
                public void onSuccess(Uri uri) {
                    // Got the download URL for 'users/me/profile.png'
                    Log.d("TAG" , "URI = "+uri);

                    GlideApp.with(getActivity()).load(storageReference).into(profilepic);
                    //GlideApp.with(getActivity()).load(storageReference).into(test);
                    //profilepic.setImageURI(uri);
                }
            }).addOnFailureListener(new OnFailureListener() {
                @Override
                public void onFailure(@NonNull Exception exception) {
                    // Handle any errors
                    Toast.makeText(getActivity(), "Error getting Profile Picture", Toast.LENGTH_LONG).show();
                }
            });*/
        }

我已经实现了 Firebase UI 依赖。

PS: 注释代码是我上面提到的第二种方法

尝试

 String imageUrl = (String) dataSnapshot.child("profilePic").getValue();

 GlideApp.with(getActivity()).load(imageUrl).into(test);