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

时间:2019-07-06 14:24:22

标签: java android firebase firebase-storage android-glide

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

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

我能够成功获取下载URL,但是滑动显示我无法理解的错误。

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

这是日志:

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:注释的代码是我上面提到的第二种方法。

1 个答案:

答案 0 :(得分:1)

尝试

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

 GlideApp.with(getActivity()).load(imageUrl).into(test);
相关问题