当应用崩溃时,它说:
"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)"
我尝试了很多事情,但是没有解决。 我的代码:
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();
}
});
}
为了我的荣幸:
{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'}
答案 0 :(得分:0)
尝试在build.gradle文件中添加firebase sdk library。
implementation 'com.google.firebase:firebase-core:17.0.0'
答案 1 :(得分:0)
始终确保使用所有库的最新版本,如release notes中所示。您在Firebase-UI的版本上也很落后。最新的是6.2.0。