NewUser1213
NewUser1213

Reputation: 1271

Error reading CPU usage: /proc/stat (permission denied)

Attached is my error message that comes up in Android Studio after running the application. I am able to build and run the program on a device without any issues. I was not getting this error until I started targeting API level 26 as per Google's new app requirements. Any suggestions on how to fix the error? Also, will this error cause issues in the future if not addressed?

Error Message

Thanks!

Upvotes: 2

Views: 15474

Answers (2)

Yasiru Nayanajith
Yasiru Nayanajith

Reputation: 1737

Accessing /proc/stat not possible with the API Levels 26 or higher. Google has restricted this to non-system apps. From API Level 26 only system apps can access /proc/stat

More information https://issuetracker.google.com/issues/37140047

Upvotes: 9

CopsOnRoad
CopsOnRoad

Reputation: 267474

That means you were targeting API < 23 before and you were having app permissions during the install time. Beginning with API 23 (Android 6.0), you have to ask the dangerous permissions at runtime.

This is the reason why your app was running successfully before and the moment you changed it to 26, you started getting errors. You have to ask permissions at runtime using ActivityCompat.requestPermissions(...)

Upvotes: 1

Related Questions