我正在尝试创建一个用于注册关于盗窃车辆的投诉的应用,其中所有者必须提交车辆文档图像。图像被选中并显示在图像按钮中,但是当我按提交将图像上传到存储设备时,我的应用程序崩溃了。谁能帮我这个忙。
我用于选择图片和上传图片的代码。
private void uploadImage() {
final StorageReference ref = mStorageRef.child("images/"+id);
ref.putFile(filePath).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
Toast.makeText(getApplicationContext(), "Uploaded", Toast.LENGTH_SHORT).show();
ref.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
String url=uri.toString();
dem2=rootRef.child("Downloadurl");
dem2.child(id).setValue(url);
}
});
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Toast.makeText(getApplicationContext(), "Failed", Toast.LENGTH_SHORT).show();
}
});
}
这是在调用“上传”方法时发生的logcat错误
2019-11-16 22:43:14.064 1382-1492 /? E / ANDR-PERF-JNI:焦磷酸 初始化2019-11-16 22:43:14.295 1382-2052 /? E / PackageManager: testDefaultGrantsWithRemoteExceptions:android.content.pm.PackageManager $ NameNotFoundException: com.google.android.permission.gts 2019-11-16 22:43:15.125 28736-28736 /? E / ACRA:跳过ANR检测器进行处理: com.instagram.android:mqtt 2019-11-16 22:43:26.214 1382-1478 /? E / BatteryStatsService:调制解调器信息无效:ModemActivityInfo { mTimestamp = 257068175 mSleepTimeMs = 179685038 mIdleTimeMs = -179684977 mTxTimeMs [] = [271,474,86,85,1285] mRxTimeMs = 23029 mEnergyUsed = 0} 2019-11-16 22:43:29.708 528-528 /? E / HWComposer: presentAndGetReleaseFences:显示失败0:未验证(7) 2019-11-16 22:43:31.074 28683-28797 / com.example.rtgt_login E / StorageException:发生StorageException。 发生未知错误,请检查HTTP结果代码和服务器响应的内部异常。 代码:-13000 Http结果:0
崩溃开始2019-11-16 22:43:31.079 28683-28797 / com.example.rtgt_login E / AndroidRuntime:致命异常: FirebaseStorage-Upload-1 流程:com.example.rtgt_login,PID:28683 java.lang.NoSuchMethodError:没有虚拟方法getToken(Z)Lcom / google / android / gms / tasks / Task;在班上 Lcom / google / firebase / FirebaseApp;或其超类(声明为 “ com.google.firebase.FirebaseApp”出现在 /data/app/com.example.rtgt_login-GAD2_wYHG9BB_vFom1GNPg==/base.apk) 位于com.google.firebase.storage.internal.Util.getCurrentAuthToken(com.google.firebase:firebase-storage @@ 16.0.4:148) 在com.google.firebase.storage.internal.ExponentialBackoffSender.sendWithExponentialBackoff(com.google.firebase:firebase-storage @@ 16.0.4:65) 在com.google.firebase.storage.internal.ExponentialBackoffSender.sendWithExponentialBackoff(com.google.firebase:firebase-storage @@ 16.0.4:57) com.google.firebase.storage.UploadTask.sendWithRetry(com.google.firebase:firebase-storage @@ 16.0.4:457) 在com.google.firebase.storage.UploadTask.beginResumableUpload(com.google.firebase:firebase-storage @@ 16.0.4:257) com.google.firebase.storage.UploadTask.run(com.google.firebase:firebase-storage @@ 16.0.4:198) com.google.firebase.storage.StorageTask.lambda $ getRunnable $ 7(com.google.firebase:firebase-storage @@ 16.0.4:1106) 在com.google.firebase.storage.StorageTask $$ Lambda $ 12.run(未知 资料来源:2) 在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) 在java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:636) 在java.lang.Thread.run(Thread.java:764)2019-11-16 22:43:31.112 1382-5720 /? E / ActivityTrigger:activityResumeTrigger:不 whiteListedcom.example.rtgt_login / com.example.rtgt_login.Complaint / 1 2019-11-16 22:43:31.136 1382-1475 /? E / PackageManager: testDefaultGrantsWithRemoteExceptions:android.content.pm.PackageManager $ NameNotFoundException: com.google.android.permission.gts 2019-11-16 22:43:31.164 1382-2052 /? E / PackageManager: testDefaultGrantsWithRemoteExceptions:android.content.pm.PackageManager $ NameNotFoundException: com.google.android.permission.gts 2019-11-16 22:43:31.165 1382-1939 /? E / PackageManager: testDefaultGrantsWithRemoteExceptions:android.content.pm.PackageManager $ NameNotFoundException: com.google.android.permission.gts 2019-11-16 22:43:31.170 1382-11857 /? E / PackageManager: testDefaultGrantsWithRemoteExceptions:android.content.pm.PackageManager $ NameNotFoundException: com.google.android.permission.gts 2019-11-16 22:43:31.170 1382-11857 /? E / PackageManager: testDefaultGrantsWithRemoteExceptions:android.content.pm.PackageManager $ NameNotFoundException: com.google.android.permission.gts