Mac 安装使用Battery Historian遇到的问题

Mac 安装使用Battery Historian遇到的问题

一、下载Docker

Docker Mac下载地址 下载完安装,然后打开按照提示更新(下载完之后一定要打开按照提示做,不然在terminal使用时无法使用)

二、Go源码安装-Mac

  1. 官网下载源码(Source 里带.src.tar.gz的包)
  2. 解压到==$HOME==目录: 在home目录下执行:tar -zxvf “下载下来的tar.gz目录”
  3. cd go/src
  4. ./all.bash ==出现错误❌ ==
    ##### Building Go bootstrap tool.
    cmd/dist
    ERROR: Cannot find /Users/sarah/go1.4/bin/go.
    Set $GOROOT_BOOTSTRAP to a working Go tree >= Go 1.4.

默认去编译1.4版本,要告诉go boostrap tool,有一个(>=1.4)新版本,让它能编译你想要安装的go最新版本,修改环境变量GOROOT_BOOSTRAP=/Users/sarah/.gvm/gos/go1.8 但还是不可以出现了同样的问题
8. 改换brew install go ==出现:没有支持我系统的版本==

You are using OS X 10.12.
We do not provide support for this pre-release version.
You may encounter build failures or other breakages.
Please create pull-requests instead of filing issues.

尝试安装一个指定的版本brew install go1.8出现:

  Error: /usr/local is not writable. You should change the ownership
and permissions of /usr/local back to your user account:
  sudo chown -R $(whoami) /usr/local
Error: No available formula with the name "go1.8"
==> Searching for similarly named formulae...
Error: No similarly named formulae found.

成功的方法:

  1. 回到官网推荐的方法:官网地址,点击install the go tools里面有多种安装方法可以使用第一种或者Mac OS X package installer直接下载pkg安装完配置PATH
  2. 按照步骤使用第一种,下载最新版tar.gz包解压到/usr/local:tar -C /usr/local -xzf go1.8.1.src.tar.gz
  3. /usr/local/go/bin添加到环境变量
    export PATH=$PATH:/usr/local/go/bin
    坑1: 在配置环境变量之后需要重启,不然下次使用还是没有配置好,然而我重启之后再打开还是不可以
    坑2:在.bash_profile设置PATH和GOPATH(自己建立workspace具体见)http://golang.org/doc/code.html#Organization
export PATH=/usr/local/go/bin:${PATH}
export GOPATH=/Users/sarah/androidTest/goWorkSpace

但是没次关闭terminal下次还是不能直接使用go,每次都要source .bash_profile
12. 下载Battery Historian代码: go get -d -u github.com/google/battery-historian/... 这个会自动下载到上面自己配置的GOPATH中,也就自己建立的workspace

三、 运行Battery Historian代码:

$ cd $GOPATH/src/github.com/google/battery-historian

# Compile Javascript files using the Closure compiler,这个过程会去下载Closure
$ go run setup.go

# Run Historian on your machine (make sure $PATH contains $GOBIN)
$ go run cmd/battery-historian/battery-historian.go [--port <default:9999>]
  1. 执行go run setup.go
    Downloading Closure library...
    failed to run command "git clone https://github.com/google/closure-l ibrary /Users/sarah/androidTest/goWorkSpace/src/github.com/google/ battery-historian/third_party/closure-library":
    exit status 128
   Cloning into '/Users/sarah/androidTest/goWorkSpace/src/github.com/   google/ battery-historian/third_party/closure-library'...
    error: RPC failed; result=56, HTTP code = 200
    fatal: The remote end hung up unexpectedly
    fatal: early EOF
    fatal: index-pack failed
    Downloading Closure compiler...
    Downloading 3rd-party JS files...
    Generating JS runfiles...
    Couldn't generate runfile: failed to run command "python /Users/sarah/ androidTest/goWorkSpace/src/github.com/google/battery-historian/ third_party/closure-library/closure/bin/build/depswriter.py --root=/ Users/sarah/androidTest/goWorkSpace/src/github.com/google/battery- historian/third_party/closure-library/closure/goog -- root_with_prefix=js ../../../../js":
  exit status 2
  python: can't open file '/Users/sarah/androidTest/goWorkSpace/src/    github.com/google/battery-historian/third_party/closure-library/closure/    bin/build/depswriter.py': [Errno 2] No such file or directory

在下载一个git项目closure-library时出现错误,自己clone下该项目再执行run go

  1. 要一直运行Battery Historian

    cd $GOPATH/src/github.com/google/battery-historian
    go run cmd/battery-historian/battery-historian.go [--port <default:9999>]
    

    运行成功后打开的链接http://localhost:9999/,选择bugreport.txt或者zip包

  2. 要从运行Android 7.0及更高版本的开发设备获取错误报告:$ adb bugreport bugreport.zip
    对于6.0及更低的设备:$ adb bugreport > bugreport.txt
    ==出现的问题:==在生成错误报告的时候出现不支持低于Android7.0的,原因升级SDK到25,里面的工具也会相应升级,改回旧版的adb

~~~
adb bugreport > xxx.log
Failed to get bugreportz version, which is only available on devices running Android 7.0 or later.
Trying a plain-text bug report instead.
~~~

解决方法:
下载旧版adbhttp://www.androiddevtools.cn/下载一个比较旧版本的adb(我下的是20),打开android SDK $ open ~/Library/Android/sdk/platform-tools将platform中的adb替换下载的adb(不用替换整个platform-tools)

阅读更多

更多精彩内容