![](/img/trans.png)
[英]Firebase recyclerview shows no values in release mode but it works perfectly in debug mode
[英]Downloading files from Firebase | App works in debug but not release mode
我正在嘗試下載名為 1.pdf、2.pdf 的 Firebase 存儲目錄中的所有文件......代碼在調試模式下工作,但在發布中不起作用。 我一整天都被困在這個問題上。 我認為它可能是從另一個班級開始的,但老實說我不知道。
從 Firebase 獲取文件的代碼:
for (int i = 1; i < 10000; i++) {
StorageReference ref = storageRef.child("FirstTimeForms/" + i + ".pdf");
File localFile = File.createTempFile("Form", ".pdf");
FileDownloadTask dm = ref.getFile(localFile);
int fileSize = Integer.parseInt(String.valueOf(localFile.length()/1024));
if(fileSize > 0){
fileManager.copyFile(localFile, new File("/sdcard/Download/Forms/" + i + ".pdf"));
}else{
return;
}
}
將從緩存下載的文件復制到 SD 的代碼
FileChannel inChannel = new FileInputStream(src).getChannel();
FileChannel outChannel = new FileOutputStream(dst).getChannel();
try
{
inChannel.transferTo(0, inChannel.size(), outChannel);
}
finally
{
if (inChannel != null)
inChannel.close();
if (outChannel != null)
outChannel.close();
}
在您的 proguard-rules.pro 中添加這些
-keep class com.firebase.** { *; }
-keepattributes *Annotation*
-keepattributes Signature
-keep class YOUR_PACKAGE_NAME.YourActivity { *; }
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.