感谢各位大牛的博客作为指导,在经历两天的踩坑填坑过程,终于在自己电脑准备好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环境;
下载后点击下一步完成安装,安装完成后自动配置好环境变量,验证:
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,选择使用哪个版本时需要修改一下环境变量配置)
下载后下一步完成安装默认配置好环境变量;
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)浏览器打开以下链接:
问题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按钮;