AndroidUtilCode android 11 zip打包异常

nfzehxib  于 6个月前  发布在  Android
关注(0)|答案(1)|浏览(93)

描述 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

截图

相关问题