2

I used to collect ANR info by reading and analysing /data/anr/traces.txt programmatically. It works very well before Android N.

On Android N, "/data/anr/traces.txt" is NOT accessible.

    File anrFile = new File("/data/anr/traces.txt");
    if (anrFile.exists()) {
        boolean read = anrFile.canRead();  //always FALSE
    }

My question:

  1. How can my app access traces.txt on Android N ?

  2. How can my app get its ANR info on Android N ?

Stefan Zobel
  • 3,182
  • 7
  • 28
  • 38
RoFF
  • 529
  • 5
  • 27

1 Answers1

1

I'm not sure if this is an Android N specific issue as it appears to be more generic. The directory /data/anr or the files in this directory are often readable only by the root user. And thus, when devices is not rooted, we can't get ANR from the files.

However, from the Android documentation (bug-report adb documentation), you can receive the bugreports using this adb command line:

adb bugreport E:\Reports\MyBugReports

The final argument is the path where you want the bugreport to be copied on your local computer.

AymericM
  • 1,645
  • 13
  • 13
  • I think I did understood your question: I have explained why the file is not readable and gave you an alternative. On older Android (depends on manufacturer) it has been possible to read/access the files, but it's becoming more and more restricted with newer Android versions. I do understand that you don't like the answer, but I don't see it wrong! ;) – AymericM May 02 '18 at 19:03