尝试加载图像时出现错误

时间:2020-04-26 09:34:07

标签: android firebase-storage

我正在尝试通过使用以下代码将图像加载到我的应用程序中,但是该应用程序始终崩溃,并且我的logcat中始终出现此错误。

在我制作的其他应用中运行时,相同的代码可以正常工作,没有错误,

使用im

 final StorageReference mImageRef =
            FirebaseStorage.getInstance().getReference("Profile_image/thumbs/" + image + ".jpg");
    final long ONE_MEGABYTE = 1024 * 1024;

    mImageRef.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
        @Override
        public void onSuccess(Uri uri) {

            mImageRef.getBytes(ONE_MEGABYTE).addOnSuccessListener(new OnSuccessListener<byte[]>() {
                @Override
                public void onSuccess(byte[] bytes) {

                    Bitmap bm = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
                    DisplayMetrics dm = new DisplayMetrics();
                    getWindowManager().getDefaultDisplay().getMetrics(dm);

                    profilepic.setMinimumHeight(dm.heightPixels);
                    profilepic.setMinimumWidth(dm.widthPixels);
                    profilepic.setImageBitmap(bm);



                }
            }).addOnFailureListener(new OnFailureListener() {
                @Override
                public void onFailure(@NonNull Exception exception) {
                    // Handle any errors

                    Toast.makeText(Item.this, "Error with image" , Toast.LENGTH_LONG).show();

                }
            });

        }
    });

错误:

2020-04-26 14:59:14.861 17771-17919/com.example.customerapp E/AndroidRuntime: FATAL EXCEPTION: FirebaseStorage-Command-1
    Process: com.example.customerapp, PID: 17771
    java.lang.NoSuchMethodError: No virtual method getToken(Z)Lcom/google/android/gms/tasks/Task; in class Lcom/google/firebase/FirebaseApp; or its super classes (declaration of 'com.google.firebase.FirebaseApp' appears in /data/app/com.example.customerapp-b-ICT4vuPHXo0gOG7RNCVA==/base.apk)
        at com.google.firebase.storage.internal.Util.getCurrentAuthToken(com.google.firebase:firebase-storage@@16.0.4:148)
        at com.google.firebase.storage.internal.ExponentialBackoffSender.sendWithExponentialBackoff(com.google.firebase:firebase-storage@@16.0.4:65)
        at com.google.firebase.storage.internal.ExponentialBackoffSender.sendWithExponentialBackoff(com.google.firebase:firebase-storage@@16.0.4:57)
        at com.google.firebase.storage.GetDownloadUrlTask.run(com.google.firebase:firebase-storage@@16.0.4:71)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:919)

这些是我所拥有的依赖项

implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.firebase:firebase-auth:19.3.0'
implementation 'com.google.firebase:firebase-database:19.2.1'
implementation 'com.google.firebase:firebase-analytics:17.4.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

implementation 'com.firebaseui:firebase-ui-auth:4.1.0'


implementation 'com.google.firebase:firebase-storage:16.0.4'
implementation 'androidx.recyclerview:recyclerview:1.1.0'


implementation 'com.firebaseui:firebase-ui-database:4.3.2'


implementation 'de.hdodenhof:circleimageview:3.0.1'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.+'
implementation 'com.squareup.picasso:picasso:2.5.2'

implementation 'id.zelory:compressor:2.1.0'

//noinspection GradleCompatible
implementation "com.android.support:support-compat:28.0.0"
implementation 'androidx.cardview:cardview:1.0.0'


implementation 'com.github.bumptech.glide:glide:4.11.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'

0 个答案:

没有答案