gpt4 book ai didi

java - 将裁剪后的照片保存到 FirebaseStorage 时应用崩溃

转载 作者:行者123 更新时间:2023-11-29 18:31:07 25 4
gpt4 key购买 nike

我想在 firebase 存储中保存一张使用 github 中的 CropImage 库裁剪的照片。一切正常,直到我按下裁剪按钮。这就是我从 Crop Image Activity 获取和存储图像的方式;

@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);

if(requestCode == GALLERY_PICK && resultCode == RESULT_OK) {

Uri imageUri = data.getData();

CropImage.activity(imageUri)
.setAspectRatio(1, 1)
.start(this);

}

if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {

CropImage.ActivityResult result = CropImage.getActivityResult(data);

if (resultCode == RESULT_OK) {

Uri resultUri = result.getUri();

StorageReference filepath = mImageStorage.child("profile_images").child("profile_image.jpg");

filepath.putFile(resultUri).addOnCompleteListener(new OnCompleteListener<UploadTask.TaskSnapshot>() {
@Override
public void onComplete(@NonNull Task<UploadTask.TaskSnapshot> task) {

if(task.isSuccessful()) {

Toast.makeText(SettingsActivity.this, "Working", Toast.LENGTH_SHORT).show();

} else {

Toast.makeText(SettingsActivity.this, "Error in uploading", Toast.LENGTH_SHORT).show();

}

}
});

} else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {

Exception error = result.getError();

}
}

当我点击“裁剪”按钮时,应用程序崩溃并且我在 LogCat 中看到此错误:

    2019-05-20 23:51:53.228 13563-13616/com.example.lapitchat E/StorageException: StorageException has occurred.
An unknown error occurred, please check the HTTP result code and inner exception for server response.
Code: -13000 HttpResult: 0
2019-05-20 23:51:53.230 13563-13616/com.example.lapitchat E/AndroidRuntime: FATAL EXCEPTION: FirebaseStorage-Upload-1
Process: com.example.lapitchat, PID: 13563
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.lapitchat-0t0XSYn85YiAd1vWQMGk4g==/split_lib_dependencies_apk.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.UploadTask.sendWithRetry(com.google.firebase:firebase-storage@@16.0.4:457)
at com.google.firebase.storage.UploadTask.beginResumableUpload(com.google.firebase:firebase-storage@@16.0.4:257)
at com.google.firebase.storage.UploadTask.run(com.google.firebase:firebase-storage@@16.0.4:198)
at com.google.firebase.storage.StorageTask.lambda$getRunnable$7(com.google.firebase:firebase-storage@@16.0.4:1106)
at com.google.firebase.storage.StorageTask$$Lambda$12.run(Unknown Source:2)
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:764)
2019-05-20 23:51:53.228 13563-13616/com.example.lapitchat E/StorageException: StorageException has occurred.
An unknown error occurred, please check the HTTP result code and inner exception for server response.
Code: -13000 HttpResult: 0

这是我的 build.gradle 文件:

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.firebase:firebase-auth:17.0.0'
implementation 'de.hdodenhof:circleimageview:3.0.0'
implementation 'com.google.firebase:firebase-database:17.0.0'
implementation 'com.google.firebase:firebase-storage:16.0.4'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
api 'com.theartofdev.edmodo:android-image-cropper:2.4.+'

我使用的是 image-cropper:2.4.+,因为当我使用它的最新版本时,Github 页面中的示例不起作用。我能做些什么?是版本问题吗?

最佳答案

这可能是由于您的 firebase-storage 依赖版本与您的 firebase-auth 和 firebase-database 依赖版本不同所致。

您能否尝试将您的 firebase-storage 上的版本更新到 17.0.0,看看是否能解决您的问题?

关于java - 将裁剪后的照片保存到 FirebaseStorage 时应用崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56228134/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com