【问题标题】:Unable to load Profile Picture using Glide Library from Firebase无法使用 Firebase 中的 Glide 库加载个人资料图片
【发布时间】:2019-11-16 18:58:49
【问题描述】:

我正在尝试加载上传到 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:注释代码是我上面提到的第二种方法。

【问题讨论】:

  • glide 加载的 url 是 gs://creatives-4ebde.appspot.com/ 似乎无效。
  • 在注释代码中,我在日志中获取的 URI 是 https://firebasestorage.googleapis.com/v0/b/creatives-4ebde.appspot.com/o/ProfilePictures%2F5tI5e4Y2NeOQ7yq8DwefvmYJk713.jpg?alt=media&amp;token=ff02fc6c-32b5-4eb6-8cf3-aca3472b7434,这是正确的 uri。还是一样的错误
  • 已添加答案。试试看。无需将其类型转换为URL

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


【解决方案1】:

试试

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-09-01
    • 1970-01-01
    • 2018-12-26
    • 1970-01-01
    • 2021-08-26
    • 2017-09-30
    • 2019-04-08
    相关资源
    最近更新 更多