Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

获取存储卡信息异常 #1709

Open
KevinLoveGitHub opened this issue Oct 24, 2022 · 2 comments
Open

获取存储卡信息异常 #1709

KevinLoveGitHub opened this issue Oct 24, 2022 · 2 comments
Assignees
Labels

Comments

@KevinLoveGitHub
Copy link

描述 Bug

某些Android设备上会出现SDCardUtils.getSDCardInfo()后报错

  • AndroidUtilCode 的版本:utilcodex:1.31.1
  • 出现 Bug 的设备型号:非品牌手机,OEM设备
  • 设备的 Android 版本:API 22

相关代码

SDCardUtils.getSDCardInfo()

异常堆栈

java.lang.IllegalArgumentException: Invalid path: /mnt/usb_storage/USB_DISK0
    at android.os.StatFs.doStat(StatFs.java:46)
    at android.os.StatFs.<init>(StatFs.java:39)
    at com.blankj.utilcode.util.FileUtils.getFsTotalSize(FileUtils.java:1415)
    at com.blankj.utilcode.util.UtilsBridge.getFsTotalSize(UtilsBridge.java:305)
    at com.blankj.utilcode.util.SDCardUtils$SDCardInfo.<init>(SDCardUtils.java:177)
    at com.blankj.utilcode.util.SDCardUtils.getSDCardInfo(SDCardUtils.java:94)
    at UsbPathGetter.getWholePaths(UsbPathGetter.java:54)
@lancewoo
Copy link

我们碰到相似的问题,原因是外置SD卡坏掉了,在调用到getSDCardInfo的时候就会抛这个异常。建议把IllegalArgumentException抓一下吧。我这用的版本是1.30.6.

2023-02-17 09:19:36.588  2865  2865 E AndroidRuntime: Caused by: java.lang.IllegalArgumentException: Invalid path: /storage/sdcard1
2023-02-17 09:19:36.588  2865  2865 E AndroidRuntime: 	at android.os.StatFs.doStat(StatFs.java:51)
2023-02-17 09:19:36.588  2865  2865 E AndroidRuntime: 	at android.os.StatFs.<init>(StatFs.java:41)
2023-02-17 09:19:36.588  2865  2865 E AndroidRuntime: 	at com.blankj.utilcode.util.FileUtils.getFsTotalSize(FileUtils.java:1415)
2023-02-17 09:19:36.588  2865  2865 E AndroidRuntime: 	at com.blankj.utilcode.util.UtilsBridge.getFsTotalSize(UtilsBridge.java:305)
2023-02-17 09:19:36.588  2865  2865 E AndroidRuntime: 	at com.blankj.utilcode.util.SDCardUtils$SDCardInfo.<init>(SDCardUtils.java:177)
2023-02-17 09:19:36.588  2865  2865 E AndroidRuntime: 	at com.blankj.utilcode.util.SDCardUtils.getSDCardInfo(SDCardUtils.java:68)
2023-02-17 09:19:36.588  2865  2865 E AndroidRuntime: 	at com.blankj.utilcode.util.SDCardUtils.getMountedSDCardPath(SDCardUtils.java:116)

2023-02-17 09:19:36.588  2865  2865 E AndroidRuntime: 	at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1155)
2023-02-17 09:19:36.588  2865  2865 E AndroidRuntime: 	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5939)
2023-02-17 09:19:36.588  2865  2865 E AndroidRuntime: 	... 8 more
2023-02-17 09:19:36.588  2865  2865 E AndroidRuntime: Caused by: android.system.ErrnoException: statvfs failed: ENOENT (No such file or directory)
2023-02-17 09:19:36.588  2865  2865 E AndroidRuntime: 	at libcore.io.Linux.statvfs(Native Method)
2023-02-17 09:19:36.588  2865  2865 E AndroidRuntime: 	at libcore.io.BlockGuardOs.statvfs(BlockGuardOs.java:333)
2023-02-17 09:19:36.588  2865  2865 E AndroidRuntime: 	at android.system.Os.statvfs(Os.java:570)
2023-02-17 09:19:36.588  2865  2865 E AndroidRuntime: 	at android.os.StatFs.doStat(StatFs.java:49)
2023-02-17 09:19:36.588  2865  2865 E AndroidRuntime: 	... 19 more

@lancewoo
Copy link

lancewoo commented Mar 16, 2023

Please accept this pull request as soon as possible.

@Blankj

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants