简体   繁体   中英

android - getting nullpointerexception for no specific reason

I am working on an android project and as far as I know, I don't make any specific mistakes in my code that would lead to an exception.

I get these two error lines everytime I run my project, but the rest of my code runs without any issues.

The NullPointerException doesn't have a concrete occurance location , which confuses me.

I have already searched for similar issues. A possible solution was adding the READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE as uses-permission in my Android Manifest file, but to no avail.

2020-02-28 XX:XX:XX.333 14615-14651/com.example.package_name E/Perf: Fail to get file list com.example.package_name
2020-02-28 XX:XX:XX.333 14615-14651/com.example.package_name E/Perf: getFolderSize() : Exception_1 = java.lang.NullPointerException: Attempt to get length of null array

错误是由我的 OnePlus 抛出的,在 android 模拟器上没有显示错误

This incident happened to me also when using a physical device of Xiaomi Mi A2, but with a virtual device, the issue dissapears. That means that your code is fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM