下载并编译Chrome浏览器For Android

最近因为公司项目,需要对Chrome的某一模块进行修改后,兼容公司的Android设备,现记录下Chrome的源码下载过程,作为笔记。

1. 准备Ubuntu系统,最好是物理机上安装,因为Chrome首次编译耗时较长,对硬件要求较高。我使用的Ubuntu版本为14.04.1。

2. 下载Chrome源码要翻墙,这个可以通过更换hosts解决(修改hosts后,在下载其中的第三方库代码时还是会有问题,这时需要设置代理,后面会讲到),从laod.cn上下载linux可用的hosts文件,替换到/etc/hosts。注意备份原文件。网址如下:

     https://laod.cn/hosts/2017-google-hosts.html

3. 根据谷歌官方安装步骤的操作步骤下载:下述命令仅供参考,具体情况根据链接。


        3.1     git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
        3.2     export PATH="$PATH:/path/to/depot_tools"
        3.3     mkdir ~/chromium && cd ~/chromium
        3.4     fetch --nohooks android
        3.5     cd src
        3.6     If you have an existing Linux checkout, you can add Android support by appending target_os = ['android'] to your .gclient file (in the directory above src):
                    [ echo "target_os = [ 'android' ]" >> ../.gclient ]
                gclient sync
        3.7     build/install-build-deps-android.sh

         在3.7安装依赖package是可能会报错,此时需要更换apt源,可参考另一篇文章修改apt源
        3.8     gclient runhooks

4.  在执行fetch --nohooks android时,一般在最后会有如下third-party无法下载。
            src/third-party/pdfium
            src/third-party/skia
            src/third-party/swiftshader
            src/third-party/webrtc
            src/third-party/android_tools/ndk
     解决方法:
     通过http/https代理:
               4.1  sudo apt-get install python-gevent python-pip
                       sudo pip install shadowsocks
                4.2  创建shadow.json:
                        {
                            "server":"xxxxxx",
                            "server_port":xxxx,
                            "local_port":10808,
                            "password":"xxxx",
                            "timeout":600,
                            "method":"aes-256-cfb"
                        }
        local_port为自定义,加密方法根据实际情况填写。
                4.3 sslocal -c /path/to/shadowsocks.json
                       或开机自启动:
                        vim /etc/rc.local
                        sudo sslocal -c /path/to/shadowsocks.json
               4.4 新开一个终端:
                        sudo apt-get install privoxy
                        vim /etc/privoxy/config
                            761行: listen-address 127.0.0.1:8118
                            1336行: forward-socks5 / 127.0.0.1:10808 .
                                注意不要漏掉最后的"."
                        sudo service privoxy restart
                        export http_proxy='http://127.0.0.1:8118'
                        export https_proxy='https://127.0.0.1:8118'
                        git config --global http.proxy 'socks5://127.0.0.1:10808'
                        git config --global https.proxy 'socks5://127.0.0.1:10808'

                        (git取消代理) git config --global --unset http.proxy
                5.  在src/目录执行gclient sync即可

更新代码步骤:根据经验总结的步骤,如遇到奇怪问题,建议按照下载步骤重新下载。
    1.  如上述设置代理后执行gclient sync,此步骤会更新所有依赖。
    2.  cd src;git fetch origin

猜你喜欢

转载自blog.csdn.net/u011089570/article/details/78292395
今日推荐