My app gets ANR error only on android 11 devices. Input dispatching timed out means that main thread got stuck in a loop but based on my logcat trace what i understand is that there is a problem with file.exists() line.
Here is my logcat trace
at libcore.io.Linux.access (Native method)
at libcore.io.ForwardingOs.access (ForwardingOs.java:72)
at libcore.io.BlockGuardOs.access (BlockGuardOs.java:73)
at libcore.io.ForwardingOs.access (ForwardingOs.java:72)
at android.app.ActivityThread$AndroidOs.access (ActivityThread.java:7937)
at java.io.UnixFileSystem.checkAccess (UnixFileSystem.java:281)
at java.io.File.exists (File.java:815)
at com.****************.FileUtils.fileIsExists (FileUtils.java:17)
and here my FileUtlis.class
public class FileUtils {
public static boolean fileIsExists(String path) {
if (path == null || path.trim().length() <= 0) {
return false;
}
try {
File f = new File(path);
if (!f.exists()) {
return false;
}
} catch (Exception e) {
return false;
}
return true;
}
}