Blankj / Blankj/AndroidUtilCode

android 11 zip打包异常

Đang mở
#1,744 1 bình luận 0 reaction 1 người được giao Được @Blankj nhận Xem trên GitHub
bug
Ngôn ngữ chính
Java
Star
33.6k
Fork
10.6k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

## 描述 Bug

使用ZipUtils.zipFile打zip包时,实际成功了,但是仍然会抛出异常。
使用FileUtils.copy()方法也会出现该现象

- AndroidUtilCode 的版本:1.31.0
- 出现 Bug 的设备型号:
- 设备的 Android 版本:android 11

## 相关代码

try {
// selectPath 是选中的U盘目录
val zipFileName =
selectPath + File.separator + "${Constant.LOCAL_MAC}_${
TimeUtils.date2String(
Date(),
"yyyyMMddHHmmss"
)
}_log" + ".zip"
//LOG_PATH下有多个log文件,
ZipUtils.zipFile(LOG_PATH, zipFileName)

} catch (e: IOException) {
LogUtils.w("导出U盘日志->失败->${e}")
e.printStackTrace()

}

## 异常堆栈

java.io.IOException: close failed: EPERM (Operation not permitted)
2023-02-23 16:28:43.052 System.err W at libcore.io.IoBridge.closeAndSignalBlockedThreads(IoBridge.java:254)
2023-02-23 16:28:43.052 System.err W at java.io.FileOutputStream.close(FileOutputStream.java:431)
2023-02-23 16:28:43.052 System.err W at java.util.zip.DeflaterOutputStream.close(DeflaterOutputStream.java:242)
2023-02-23 16:28:43.052 System.err W at java.util.zip.ZipOutputStream.close(ZipOutputStream.java:379)
2023-02-23 16:28:43.052 System.err W at com.blankj.utilcode.util.ZipUtils.zipFile(ZipUtils.java:186)
2023-02-23 16:28:43.052 System.err W at com.blankj.utilcode.util.ZipUtils.zipFile(ZipUtils.java:133)
2023-02-23 16:28:43.052 System.err W at com.troila.clouddesk.rebuild.business.setting.fragment.ExportLogViewModel$zipLogFile$1.invokeSuspend(ExportLogViewModel.kt:34)
2023-02-23 16:28:43.053 System.err W at com.troila.clouddesk.rebuild.business.setting.fragment.ExportLogViewModel$zipLogFile$1.invoke(Unknown Source:8)
2023-02-23 16:28:43.053 System.err W at com.troila.clouddesk.rebuild.business.setting.fragment.ExportLogViewModel$zipLogFile$1.invoke(Unknown Source:4)
2023-02-23 16:28:43.053 System.err W at com.troila.clouddesk.rebuild.core.mvvm.BaseViewModel$launchOnIO$1.invokeSuspend(BaseViewModel.kt:45)
2023-02-23 16:28:43.053 System.err W at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
2023-02-23 16:28:43.053 System.err W at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
2023-02-23 16:28:43.053 System.err W at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
2023-02-23 16:28:43.053 System.err W at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
2023-02-23 16:28:43.053 System.err W at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
2023-02-23 16:28:43.053 System.err W at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
2023-02-23 16:28:43.054 System.err W Caused by: android.system.ErrnoException: close failed: EPERM (Operation not permitted)
2023-02-23 16:28:43.054 System.err W at libcore.io.Linux.close(Native Method)
2023-02-23 16:28:43.054 System.err W at libcore.io.ForwardingOs.close(ForwardingOs.java:88)
2023-02-23 16:28:43.054 System.err W at libcore.io.BlockGuardOs.close(BlockGuardOs.java:110)
2023-02-23 16:28:43.054 System.err W at libcore.io.ForwardingOs.close(ForwardingOs.java:88)
2023-02-23 16:28:43.054 System.err W at libcore.io.IoBridge.closeAndSignalBlockedThreads(IoBridge.java:252)
2023-02-23 16:28:43.054 System.err W ... 15 more

## 截图
![image](https://user-images.githubusercontent.com/26990001/220856370-cb2805e5-dae1-41d5-bfc7-dd66ad39cab7.png)

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.