Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

Could not parse aggregated battery stats: Official image source code creates the same error #191

Open
antgustech opened this issue Sep 27, 2019 · 3 comments

Comments

@antgustech
Copy link

antgustech commented Sep 27, 2019

As other people have reported I also get errors when analyzing Android 10 bugreports. Note: Could not parse aggregated battery stats.

I then pulled and ran googles latest image 3.1, and it does indeed work with Android 10 bugreports. So after this, I tried extracting all the files from the image and running it myself. These are commands I use (I use Ubuntu):

//Create new container
 docker create  --name="bh" -p 80:80 --expose=80 gcr.io/android-battery-historian/stable:3.1

 //Copy all files from container to current local folder
 docker cp bh:/gopure/src/github.com/google/battery-historian $PWD

I then ran setup.go and then battery-historian.go. The application launched but I still get the same error, "Could not parse aggregated battery stats."

With the same source I have also tried building my own docker image with the following dockerfile:

 #Use latest golang:alpine version which is smaller than regular golang.
FROM golang:1.12.5-alpine3.9

#Get the battery historian code from local code commit repo
WORKDIR /go/src/codecommit/battery-historian
COPY . /go/src/codecommit/battery-historian

#Install Java, git and python and cleanup after in the same layer.
RUN apk update && \
    apk add openjdk8-jre git python2 && \
    rm -rf /var/cache/apk/*

#Install dependencies recursively and remove the third_party directory after it has been used for compiling.
RUN go get ./... &&  \
    go run setup.go

#Open default port
EXPOSE 80

#Run the start file for battery historian in a container.
CMD go run cmd/battery-historian/battery-historian.go --port 80

But when I use this image, I still get the same error as before.

What are I and Google doing differently?

@jiangbin0814
Copy link

first of all,if u export it as txt,it might cause this problem, maybe u can try export it as zip and then take the bugreport from it, it works for me,and ihope it will work for u too

@JosielManzonni
Copy link

JosielManzonni commented Dec 23, 2019

As other people have reported I also get errors when analyzing Android 10 bugreports. Note: Could not parse aggregated battery stats.

I then pulled and ran googles latest image 3.1, and it does indeed work with Android 10 bugreports. So after this, I tried extracting all the files from the image and running it myself. These are commands I use (I use Ubuntu):

//Create new container
 docker create  --name="bh" -p 80:80 --expose=80 gcr.io/android-battery-historian/stable:3.1

 //Copy all files from container to current local folder
 docker cp bh:/gopure/src/github.com/google/battery-historian $PWD

I then ran setup.go and then battery-historian.go. The application launched but I still get the same error, "Could not parse aggregated battery stats."

With the same source I have also tried building my own docker image with the following dockerfile:

 #Use latest golang:alpine version which is smaller than regular golang.
FROM golang:1.12.5-alpine3.9

#Get the battery historian code from local code commit repo
WORKDIR /go/src/codecommit/battery-historian
COPY . /go/src/codecommit/battery-historian

#Install Java, git and python and cleanup after in the same layer.
RUN apk update && \
    apk add openjdk8-jre git python2 && \
    rm -rf /var/cache/apk/*

#Install dependencies recursively and remove the third_party directory after it has been used for compiling.
RUN go get ./... &&  \
    go run setup.go

#Open default port
EXPOSE 80

#Run the start file for battery historian in a container.
CMD go run cmd/battery-historian/battery-historian.go --port 80

But when I use this image, I still get the same error as before.

What are I and Google doing differently?

Someone fix it properly ? All recent issues is about it. I have the same problem here, I got docker 3.0 cp from container to local and run then I got the error, but running from docker it work, does not make sense.

@nomis
Copy link

nomis commented May 6, 2021

This is the change in the Google v3.1 docker image that gets rid of that error:

diff --git a/checkinparse/checkin_parse.go b/checkinparse/checkin_parse.go
index d8d6fcb..89fa14f 100644
--- a/checkinparse/checkin_parse.go
+++ b/checkinparse/checkin_parse.go
@@ -589,10 +589,7 @@ func ParseBatteryStats(pc checkinutil.Counter, cr *checkinutil.BatteryReport, pk
 		// Parse csv lines according to
 		// frameworks/base/core/java/android/os/BatteryStats.java.
 		parsed, warn, csErrs := parseSection(pc, reportVersion, rawUID, section, remaining, stats, system, apkSeen, &allAppComputedPowerMah)
-		e := false
-		if e, warnings, errs = saveWarningsAndErrors(warnings, warn, errs, csErrs...); e {
-			return nil, warnings, errs
-		}
+		_, warnings, errs = saveWarningsAndErrors(warnings, warn, errs, csErrs...)
 		if !parsed {
 			warnings = append(warnings, fmt.Sprintf("unknown data category %s", section))
 		}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants