Android源代码下载及编译开发(2)

下面为两种解决办法,任何一种都可以

一、

curl "http://php.webtutor.pl/en/wp-content/uploads/2011/09/repo" >~/bin/repo

二、

打开 gedit /etc/hosts

添加如下内容:

74.125.237.1 dl-ssl.google.com

@Ubuntu:~$ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 22889 100 22889 0 0 20152 0 0:00:01 0:00:01 --:--:-- 24221
@ubuntu:~$

chmod a+x ~/bin/repo

5、

Initializing a Repo client

$ mkdir WORKING_DIRECTORY
$ cd WORKING_DIRECTORY

$ repo init -u https://Android.googlesource.com/platform/manifest

遇到如下问题:

@ubuntu:~/WORKING_DIRECTORY$ repo init -u https://android.googlesource.com/platform/manifest
gpg: key 920F5C65: "Repo Maintainer <repo@android.kernel.org>" not changed
gpg: key 338871A4: public key "Conley Owens <cco3@android.com>" imported
gpg: Total number processed: 2
gpg: imported: 1 (RSA: 1)
gpg: unchanged: 1


fatal: Cannot get https://gerrit.googlesource.com/git-repo/clone.bundle
fatal: error [Errno 101] Network is unreachable

或者:

* [new tag] v1.9.5 -> v1.9.5
* [new tag] v1.9.6 -> v1.9.6
Get https://android.googlesource.com/platform/manifest
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- 0:00:06 --:--:-- 0
curl: (22) The requested URL returned error: 404
Server does not provide clone.bundle; ignoring.
remote: Counting objects: 92, done
remote: Finding sources: 100% (92/92)
remote: Total 816 (delta 96), reused 816 (delta 96)
Receiving objects: 100% (816/816), 708.29 KiB | 247 KiB/s, done.
Resolving deltas: 100% (96/96), done.
From https://android.googlesource.com/platform/manifest
* [new branch] android-1.6_r1 -> origin/android-1.6_r1

解决方法,官网说明,和网上统一口径,如下:

1, 先按官网的步骤一步步执行
2,当遇到上述问题后,用浏览器登录https://android.googlesource.com/new-password,并用gmail帐号登录;
3, 点击网页上的“允许访问”,得到类似的结果:

machine android.googlesource.com login git-<userName>.gmail.com password <password>
machine android-review.googlesource.com login git-<userName>.gmail.com password <password>
将上边的两行追加到~/.netrc文件结尾。(如果你的linux系统中从来没有建立过此文件,就在home目录下建立.netrc文件,将上面的信息加到新建的文件中去),
4,下载地址的URI更改为https://android.googlesource.com/a/platform/manifest(中间加上了“/a”)。

因为访问基本是匿名的,为了防止连接过多,对同一IP地址的连接数做了一定的限制。用gmail帐号进行认证。
在公司网络内或者用虚拟机下载的话,会经常遇到这问题。

如果遇到下面问题

@ubuntu:~/WORKING_DIRECTORY$
@ubuntu:~/WORKING_DIRECTORY$ repo init -u https://android.googlesource.com/a/platform/manifest --config

Your Name [jianguo liao]: jianguo liao
Your Email [liaojianguo19840726@gmail.com]: liaojianguo19840726@gmail.com

Your identity is: jianguo liao <liaojianguo19840726@gmail.com>
is this correct [y/N]? y

repo has been initialized in /home/jianguoliao/WORKING_DIRECTORY

解决

@ubuntu:~/WORKING_DIRECTORY$ repo init -u https://android.googlesource.com/platform/manifest

Your identity is: jianguo liao <liaojianguo19840726@gmail.com>
If you want to change this, please re-run 'repo init' with --config-name

或者:注意没有/a哦

@ubuntu:~/WORKING_DIRECTORY$ repo init -u https://android.googlesource.com/platform/manifest --config

Your Name [jianguo liao]: jianguo liao
Your Email [liaojianguo19840726@gmail.com]: liaojianguo19840726@gmail.com

Your identity is: jianguo liao <liaojianguo19840726@gmail.com>
is this correct [y/N]? y

repo has been initialized in /home/jianguoliao/WORKING_DIRECTORY
@ubuntu:~/WORKING_DIRECTORY$

接着搞:

@ubuntu:~/WORKING_DIRECTORY$ repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1
.repo/manifests/: discarding 88 commits

Your identity is: jianguo liao <liaojianguo19840726@gmail.com>
If you want to change this, please re-run 'repo init' with --config-name

repo has been initialized in /home/jianguoliao/WORKING_DIRECTORY
@ubuntu:~/WORKING_DIRECTORY$

好吧,接下来最后一步了

$ repo sync

网上有朋友建议,写个脚本如下:

#!/bin/bash
echo "======start repo sync======"
repo sync
while [ $? = 1 ]; do
echo "======sync failed, re-sync again======"
sleep 3
repo sync
done

其中还遇到如下问题,经常提示如下信息,网上有朋友建议:

error: Failed connect to android.googlesource.com:443;Connection refused while accessinghttps://android.googlesource.com/a/platform/frameworks/base/info/refs

fatal: HTTP request failed

error: Cannot fetch platform/tools/motodev

error: Cannot fetch platform/frameworks/base

error: Cannot fetch platform/prebuilts/sdk

error: Exited sync due to fetch errors

等错误信息。

解决方法:编辑/etc/hosts文件

$ sudo gedit /etc/hosts

增加下面内容,保存

74.125.71.82

74.125.31.82 android.googlesource.com

203.208.46.172 cache.pack.google.com

59.24.3.173cache.pack.google.com

此外,还需下载编译库等工具,可用下面命令:

sudo apt-get install git-core gnupg flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl python sun-java5-jdk valgrind lib32readline5 wx-common

这里部分工具是专用于AMD64 位环境的有时Java5 可能无法下载,可有以下尝试解决此问题:

第一种尝试:下载java 1.5 的安装bin 包手动安装,最终失败, 具体过程如下:

download java5:

https://launchpadlibrarian.net/24508358/sun-java5_1.5.0-18.orig.tar.gz tar,

chmod a+x, ./xxxx.bin

mkdir /usr/lib/jvm

cp jdk-5.0u18-dlj-linux-i586.bin to /usr/lib/jvm

run jdk-5.0u18-dlj-linux-i586.bin to install java into /usr/lib/jvm/jdk1.5.0_18

add below lines in /etc/enviroment:

JAVA_HOME=/usr/lib/jvm/jdk1.5.0_18

JRE_HOME=/usr/lib/jvm/jdk1.5.0_18/jre

CLASSPATH=.:/usr/lib/jvm/jdk1.5.0_18/lib:/usr/lib/jvm/jdk1.5.0_18/jre/lib

$ java -version

Error occurred during initialization of VM

java/lang/NoClassDefFoundError: java/lang/Object

第二种尝试:非常简单,但是有效:

修改source ,将9.10 的源改成9.04 的源。源在/etc/apt/source.list :

deb jaunty main restricted universe multiverse

deb jaunty-security main restricted universe multiverse

deb jaunty-updates main restricted universe multiverse

deb jaunty-proposed main restricted universe multiverse

deb jaunty-backports main restricted universe multiverse

deb-src jaunty main restricted universe multiverse

deb-src jaunty-security main restricted universe multiverse

deb-src jaunty-updates main restricted universe multiverse

deb-src jaunty-proposed main restricted universe multiverse

deb-src jaunty-backports main restricted universe multiverse

运行:sudo apt-get update 之后,用sudo apt-get install sun-java5-jdk 即可像以往一样安装java 1.5

或按以下源添加JDK:

1.5的:

执行sudo gedit /etc/apt/sources.list,

添加以下内容,将10.04的源改成9.04的源。

deb jaunty multiverse

deb jaunty-updates multiverse

然后sudo apt-get update

再用sudo apt-get install sun-java5-jdk

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/18539.html