【问题标题】:crash app when upload the image from gallery to firebase storage将图像从图库上传到 Firebase 存储时应用程序崩溃
【发布时间】:2020-06-01 13:51:08
【问题描述】:

当应用程序崩溃时,它会说:

"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();
                }
            });
           }

对于我的 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'}

【问题讨论】:

    标签: android firebase firebase-storage


    【解决方案1】:

    始终确保您使用的是所有库的最新版本,如 release notes 所示。你在Firebase-UI 的版本上也很落后。最新的是 6.2.0。

    【讨论】:

      【解决方案2】:

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

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

      【讨论】:

        猜你喜欢
        • 2019-04-07
        • 1970-01-01
        • 2016-09-23
        • 2023-02-02
        • 2022-09-30
        • 1970-01-01
        • 2016-11-20
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多