gpt4 book ai didi

android - Firebase 存储 - StorageReference.getFile() 在设备离线时崩溃

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:04:35 27 4
gpt4 key购买 nike

当我尝试使用方法 StorageReference.getFile(File) 从 Firebase 存储下载文件时当设备离线并达到超时时,它会崩溃。 Logcat 在 DynamicModulesC 中显示 NPE:

java.lang.NullPointerException: null reference
at asn.a(:com.google.android.gms.DynamiteModulesC:27)

相同的代码可以正常工作,并且可以在互联网连接可用时下载文件。我已经在装有 Android 4.1 和 6.0 的设备和模拟器上对其进行了测试。 Firebase SDK 版本 9.6.1。这是 firebase SDK 中的错误吗?我错过了什么吗?

代码简单:

FirebaseStorage firebaseStorage = FirebaseStorage.getInstance();
//firebaseStorage.setMaxDownloadRetryTimeMillis(15 * 1000);
StorageReference remoteDir= firebaseStorage.getReference().child("dir-with-files");
File destinationFile= new File("file-in-app-internal-storage");
StorageReference fileRef = remoteDir.child("file-from-firebase");
fileRef.getFile(destinationFile);

完整的崩溃日志:

10-02 10:49:57.577 9429-9464/com.github.lecho.mobilization W/System: ClassLoader referenced unknown path: /system/priv-app/PrebuiltGmsCore/lib/x86_64
10-02 10:49:57.610 9429-9464/com.github.lecho.mobilization I/DynamiteModule: Considering local module com.google.android.gms.firebasestorage:0 and remote module com.google.android.gms.firebasestorage:1
10-02 10:49:57.610 9429-9464/com.github.lecho.mobilization I/DynamiteModule: Selected remote version of com.google.android.gms.firebasestorage, version >= 1
10-02 10:49:57.628 9429-9464/com.github.lecho.mobilization W/System: ClassLoader referenced unknown path: /data/user/0/com.google.android.gms/app_chimera/m/00000002/n/x86_64

10-02 10:50:11.599 9429-9462/com.github.lecho.mobilization W/ExponenentialBackoff: network unavailable, sleeping.
10-02 10:50:11.599 9429-9462/com.github.lecho.mobilization E/StorageUtil: error getting token java.util.concurrent.ExecutionException: com.google.firebase.FirebaseApiNotAvailableException: firebase-auth is not linked, please fall back to unauthenticated mode.
10-02 10:50:12.234 9429-9464/com.github.lecho.mobilization W/ExponenentialBackoff: network unavailable, sleeping.
10-02 10:50:12.234 9429-9464/com.github.lecho.mobilization E/StorageUtil: error getting token java.util.concurrent.ExecutionException: com.google.firebase.FirebaseApiNotAvailableException: firebase-auth is not linked, please fall back to unauthenticated mode.

--------- beginning of crash
10-02 10:50:12.236 9429-9464/com.github.lecho.mobilization E/AndroidRuntime: FATAL EXCEPTION: FirebaseStorage-Download-3
Process: com.github.lecho.mobilization, PID: 9429
java.lang.NullPointerException: null reference
at asn.a(:com.google.android.gms.DynamiteModulesC:27)
at bul.d(:com.google.android.gms.DynamiteModulesC:261)
at buf.onTransact(:com.google.android.gms.DynamiteModulesC:76)
at android.os.Binder.transact(Binder.java:387)
at com.google.android.gms.internal.zzans$zza$zza.aE(Unknown Source)
at com.google.android.gms.internal.zzanv.aE(Unknown Source)
at com.google.firebase.storage.FileDownloadTask.run(Unknown Source)
at com.google.firebase.storage.StorageTask$5.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
10-02 10:50:12.237 1540-1997/system_process W/ActivityManager: Force finishing activity com.github.lecho.mobilization/.ui.MainActivity

[ 10-02 10:50:12.246 1540: 1997 D/ ]
HostConnection::get() New Host Connection established 0x7f39f896fc00, tid 1997

最佳答案

事实证明这是 Google Play 服务中的一个错误。 Firebase 团队已经修复了它。 Google Play 服务 9.8.77 版提供了此修复程序。

现在 StorageReference.getFile(File) 不会在设备离线时使应用程序崩溃。相反,您将收到以下回复:

E/StorageException: StorageException has occurred. 
The operation retry limit has been exceeded.
Code: -13030 HttpResult: -2

关于android - Firebase 存储 - StorageReference.getFile() 在设备离线时崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39839071/

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