Sagar Trehan
Sagar Trehan

Reputation: 2446

Android app gives error "BatteryStatsImpl: reading network stats"

Right now I am downloading the images from URL and showing them in List View. I have reffered Lazy List library on github for this.

My application is working fine.But after some time I got following error in logcat:

03-05 12:18:42.955: A/NetworkStats(12320): problem reading network stats
03-05 12:18:42.955: A/NetworkStats(12320): java.lang.IllegalStateException: problem parsing idx 1
03-05 12:18:42.955: A/NetworkStats(12320):  at com.android.internal.net.NetworkStatsFactory.readNetworkStatsDetail(NetworkStatsFactory.java:300)
03-05 12:18:42.955: A/NetworkStats(12320):  at com.android.server.NetworkManagementService.getNetworkStatsUidDetail(NetworkManagementService.java:1282)
03-05 12:18:42.955: A/NetworkStats(12320):  at com.android.server.net.NetworkStatsService.performPollLocked(NetworkStatsService.java:831)
03-05 12:18:42.955: A/NetworkStats(12320):  at com.android.server.net.NetworkStatsService.performPoll(NetworkStatsService.java:799)
03-05 12:18:42.955: A/NetworkStats(12320):  at com.android.server.net.NetworkStatsService.access$100(NetworkStatsService.java:128)
03-05 12:18:42.955: A/NetworkStats(12320):  at com.android.server.net.NetworkStatsService$3.onReceive(NetworkStatsService.java:633)
03-05 12:18:42.955: A/NetworkStats(12320):  at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:728)
03-05 12:18:42.955: A/NetworkStats(12320):  at android.os.Handler.handleCallback(Handler.java:605)
03-05 12:18:42.955: A/NetworkStats(12320):  at android.os.Handler.dispatchMessage(Handler.java:92)
03-05 12:18:42.955: A/NetworkStats(12320):  at android.os.Looper.loop(Looper.java:137)
03-05 12:18:42.955: A/NetworkStats(12320):  at android.os.HandlerThread.run(HandlerThread.java:60)
03-05 12:18:42.955: A/NetworkStats(12320): Caused by: java.io.FileNotFoundException: /proc/net/xt_qtaguid/stats: open failed: ENOENT (No such file or directory)
03-05 12:18:42.955: A/NetworkStats(12320):  at libcore.io.IoBridge.open(IoBridge.java:406)
03-05 12:18:42.955: A/NetworkStats(12320):  at java.io.FileInputStream.<init>(FileInputStream.java:78)
03-05 12:18:42.955: A/NetworkStats(12320):  at com.android.internal.net.NetworkStatsFactory.readNetworkStatsDetail(NetworkStatsFactory.java:269)
03-05 12:18:42.955: A/NetworkStats(12320):  ... 10 more
03-05 12:18:42.955: A/NetworkStats(12320): Caused by: libcore.io.ErrnoException: open failed: ENOENT (No such file or directory)
03-05 12:18:42.955: A/NetworkStats(12320):  at libcore.io.Posix.open(Native Method)
03-05 12:18:42.955: A/NetworkStats(12320):  at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
03-05 12:18:42.955: A/NetworkStats(12320):  at libcore.io.IoBridge.open(IoBridge.java:390)
03-05 12:18:42.955: A/NetworkStats(12320):  ... 12 more

This error come after every 2-3 min.My application is working fine.

Upvotes: 2

Views: 3354

Answers (2)

Naval
Naval

Reputation: 31

I was facing the same problem. I just changed my emulator to API 28 and the error wasn't there.

Upvotes: 0

Yury
Yury

Reputation: 20936

This is not the problem of your application. I guess that you test your application on a emulator where the support for network statistics was added (API > 12). But emulator relies on an old kernel version (2.6.x), that does not have a module to provide network statistics information. Thus, Android Network Statistics service cannot open file /proc/net/xt_qtaguid/stats where the statistics gathered by kernel module is collected. Therefore, you obtain these weird errors.

Also, you can read this answer.

Upvotes: 3

Related Questions