【学习笔记】Win10源码编译安装Battery-Historian环境

感谢各位大牛的博客作为指导,在经历两天的踩坑填坑过程,终于在自己电脑准备好battery-historian环境。

在这里记录操作过程的步骤以及遇到的问题。

 

Battery Historian是谷歌推出的一款专门分析bugreport的开源工具,地址:https://github.com/google/battery-historian

这里介绍在Win10下使用源码编译安装Battery Historian;在这之前需要先安装GO、Git、Python2.7、Java环境,具体步骤以及踩过的坑记录如下:

1、安装GO环境

Battery Historian是GO语言编写的,因此需要GO环境;

官网:https://golang.google.cn/

下载后点击下一步完成安装,安装完成后自动配置好环境变量,验证:

go version

按照github上说明配置GOPATH和GOBIN:配置GOPATH为GO的工程目录:

go env

2、安装Git

官网下载:https://git-scm.com/download/win

点击下一步完成安装:

启动测试:

3、安装Python2.7环境

由于historian.py脚本是python2写的,所以需要安装python2.7环境;(注意:仅支持Python2.7)

(目前电脑同时安装了Python2和Python3,选择使用哪个版本时需要修改一下环境变量配置)

官网下载:https://www.python.org/

下载后下一步完成安装默认配置好环境变量;

4、安装Java环境

参考笔记 JDK安装

5、下载battery historian code

官网有下载说明:https://github.com/google/battery-historian

输入以下命令,自动下载到GOPATH目录下:

go get -d -u github.com/google/battery-historian/...

下载完成后会有两个文件夹:

问题1:如果golang文件夹下载失败,手动下载:

下载链接:https://codeload.github.com/golang/protobuf/zip/master

问题2:如果google文件夹下载失败,手动下载:

下载链接:https://github.com/google/battery-historian

问题3:执行报错找不到google.golang.org/protobuf/proto,手动创建下载:

(1)在GOPATH/src目录下,新建google.golang.org文件夹,在google.golang.org目录下执行如下命令:

git clone https://e.coding.net/robinqiwei/googleprotobuf.git protobuf

(2)或者下载: https://github.com/protocolbuffers/protobuf/releases

6、编译

cd 到目录下 GOPATH/src/github.com/google/battery-historian

执行 如下命令编译:

go run setup.go

正常完成的结果如下:

问题4:如果下载失败后,在setup.go中找到下载地址,然后手动下载:

(1)【closure-compiler】http://dl.google.com/closure-compiler/compiler-20170409.zip

(2)【closure-library】https://github.com/google/closure-library

(3)【flot-axislabels】https://github.com/markrcote/flot-axislabels.git

下载完成后放到如下的目录文件中:

问题5:执行do run setup.go后报错如下,版本兼容的问题:

重新下载【closure-library】之前的版本后解决:https://github.com/google/closure-library/releases/tag/v20161201

7、启动battery-historian

(1)在git bah切换到如下目录,并输入以下命令启动:

//目录
GOPATH/src/github.com/google/battery-historian
//启动命令
go run cmd/battery-historian/battery-historian.go

(2)浏览器打开以下链接:

http://localhost:9999/

问题6:浏览器没有Submit按钮

(1)报错:缺少historian-optimized.js文件

把historian-optimized.js文件放到GOPATH/src/github.com/google/battery-historian/compiled目录

(2)报错:加载js文件失败

在     https://www.bootcdn.cn/     复制对应标签,替换GOPATH\src\github.com\google\battery-historian\templates下的base.html中的标签;

(3)jsapi报错,应该是不能翻墙的问题,选择了离线版Battery Historian

终极解决办法:搭建本地离线版Battery Historian

根据base.html的配置,需要访问https://www.google.com等资源,有部分资源由于墙的原因无法访问。

创建离线版就是在本地提供这些资源,在GitHub上找到资源:https://github.com/gusha915/no-ssr-battery-historian

a.用上图下载的base.html文件替换原GOPATH\src\github.com\google\battery-historian\templates的base.html文件;

b.将上图下载的cdn目录放到battery-historian\third_party文件夹下;

c.重新编译:cd 到目录下 GOPATH/src/github.com/google/battery-historian,执行 go run setup.go

//目录
GOPATH/src/github.com/google/battery-historian
//重新编译
go run setup.go

d.启动battery-historian即可:

//目录
GOPATH/src/github.com/google/battery-historian
//启动命令
go run cmd/battery-historian/battery-historian.go

e.打开浏览器,上传bugreport文件验证已有submit按钮;

 

 

  • 6
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
Battery Historian是一个用于分析Android设备电池使用情况的工具,下面是搭建方法: 1. 安装并配置Python环境Battery Historian是基于Python开发的,首先需要安装Python环境。可以从Python官方网站下载最新版本的Python并进行安装,在安装过程中记得勾选"Add Python to PATH"选项。完成安装后,打开命令提示符窗口,输入"python --version"来确认Python是否安装成功,并且能够显示相应的版本号。 2. 下载Battery Historian代码:在Battery Historian的GitHub仓库中,找到并下载最新版本的代码。可以直接在浏览器中访问"https://github.com/google/battery-historian",然后点击"Clone or download"按钮进行下载下载完成后,将代码解压到合适的目录中。 3. 安装必要的依赖库:在命令提示符窗口中切换到Battery Historian代码所在的目录,并使用pip install命令来安装必要的依赖库。例如,可以执行"pip install -r requirements.txt"命令来安装所有需要的依赖库。 4. 运行Battery Historian:在命令提示符窗口中切换到Battery Historian代码所在的目录,并执行"python historian.py"命令来启动Battery Historian。启动成功后,命令提示符窗口会显示"Running on"的信息,表示Battery Historian已成功运行。此时,可以在浏览器中输入"http://localhost:9999"来访问Battery Historian的Web界面,并开始分析Android设备的电池使用情况。 以上就是使用Battery Historian的搭建方法。需要注意的是,Battery Historian只能分析Android设备的电池使用情况,因此在使用之前,需要将Android设备连接到电脑上,并确保设备已开启开发者选项,并开启USB调试模式。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值