Ubuntu虚拟机 android 4.3 源码下载时无法访问googlesource的解决方法

时间:2022-12-29 09:05:02

Ubuntu虚拟机android 4.3源码下载时,无法连接到googlesource网站。curl和 repo init一直失败。
curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
repo init -u https://android.googlesource.com/platform/manifest


但是在windows host上,却可以访问googlesource网站。解决方法是,在Ubuntu虚拟机下,
执行如下命令(把nslookup根据URL解析出的IP地址查出来):


brice@android:~$ nslookup www.googlesource.com
    Server:127.0.0.1
    Address:127.0.0.1#53
    Non-authoritative answer:
    www.googlesource.com
    Name:googlecode.l.googleusercontent.com
    Address: 74.125.128.82


brice@android:~$ nslookup android.googlesource.com
    Server:127.0.0.1
    Address:127.0.0.1#53
    Non-authoritative answer:
    android.googlesource.com
    Name:googlecode.l.googleusercontent.com
    Address: 74.125.128.82


brice@android:~$ nslookup cache.pack.google.com
    Server:127.0.0.1
    Address:127.0.0.1#53
    Non-authoritative answer:
    cache.pack.google.com
    Name:redirector.c.youtube.com
    Address: 37.61.54.158


把nslookup的结果保存到/etc/hosts中,如下所示:
$ sudo gedit /etc/hosts
    127.0.0.1localhost
    127.0.1.1android

    74.125.128.82 www.googlesource.com
    74.125.128.82 android.googlesource.com
    46.82.174.68 cache.pack.google.com

    # The following lines are desirable for IPv6 capable hosts
    ::1     localhost ip6-localhost ip6-loopback
    fe00::0 ip6-localnet
    ff00::0 ip6-mcastprefix
    ff02::1 ip6-allnodes
    ff02::2 ip6-allrouters
    ff02::3 ip6-allhosts


然后再按照官方或者民间的方法,即可成功下载。