简体   繁体   中英

crash app when upload the image from gallery to firebase storage

when the app is crashing , it says :

"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.minisign-uZwwNJVtsjlOVpgpqIRyHQ==/base.apk)at com.google.firebase.storage.internal.Util.getCurrentAuthToken(com.google.firebase:firebase-storage@@16.0.4:148)"

I have tried many things but didn't solve it . My code :

final StorageReference fileReference=storageReference.child(imageuri.getLastPathSegment()+"."+getfileExtension(imageuri));
            uploadTask=fileReference.putFile(imageuri).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
                @Override
                public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
                    // Get a URL to the uploaded content
                    //Uri downloadUrl = taskSnapshot.getUploadSessionUri();
                    //pd.dismiss();
                    Toast.makeText(SettingsActivity.this, "Image Uploaded!!", Toast.LENGTH_SHORT).show();
                }
            })
            .addOnFailureListener(new OnFailureListener() {
                @Override
                public void onFailure(@NonNull Exception exception) {
                    Toast.makeText(SettingsActivity.this,"Failed!",Toast.LENGTH_SHORT).show();
                    //pd.dismiss();
                }
            });
           }

and for my gradle :

{implementation 'com.google.firebase:firebase-analytics:17.2.2'
implementation 'com.google.firebase:firebase-storage:16.0.4'

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

implementation 'com.google.firebase:firebase-auth:19.2.0'

implementation 'com.google.firebase:firebase-database:19.2.0'}

尝试在 build.gradle 文件中添加 firebase sdk 库

implementation 'com.google.firebase:firebase-core:17.0.0'

Always make sure you are using the latest versions of all the libraries, as shown in the release notes . You are also very behind on the version of Firebase-UI . The latest is 6.2.0.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM