虚拟机上下载Android源码

本文详细记录了在Ubuntu系统中搭建Android开发环境的过程,包括系统配置要求、JDK安装、所需软件包安装等步骤,并特别针对不同Ubuntu版本提供了具体指导。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


我是在虚拟机上安装的ubuntu系统,32位的,现在正在下载源码的过程中,还不知道会有什么麻烦等着呢

参考地址http://source.android.com/source/requirements.html

Hardware requirements


Your development workstation should meet or exceed these hardware requirements:

  • A 64-bit environment is required for Gingerbread (2.3.x) and newer versions, including the master branch. You can compile older versions on 32-bit systems.
  • At least 100GB of free disk space for a checkout, 150GB for a single build, and 200GB or more for multiple builds. If you employ ccache, you will need even more space.

  • If you are running Linux in a virtual machine, you need at least 16GB of RAM/swap.

上面这段话提到在虚拟机上安装系统的时候至少要有16GB,之前我安装的时候推荐的是20GB,不过看网上有提到不会使用linux系统的应该分配50GB


继续参考官方网站http://source.android.com/source/initializing.html

安装JDK

因为我下的ubuntu系统是最新版的(16版本的)

按照要求如下打开终端(ctrl+alt+t),执行下面的命令

For Ubuntu >= 15.04

Run the following:

$ sudo apt-get update
$ sudo apt-get install openjdk-8-jdk
其它的不用管,然后到下一步

Update the default Java version - optional

Optionally, for the Ubuntu versions above update the default Java version by running:

$ sudo update-alternatives --config java
$ sudo update-alternatives --config javac

执行后如下图所示,其实不用执行的,而且上面也写到optional



接下来是 Installing required packages

这个就有点奇怪了

Installing required packages (Ubuntu 14.04)

You will need a 64-bit version of Ubuntu. Ubuntu 14.04 is recommended.

$ sudo apt-get install git-core gnupg flex bison gperf build-essential \
  zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 \
  lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev ccache \
  libgl1-mesa-dev libxml2-utils xsltproc unzip

Note: To use SELinux tools for policy analysis, also install the python-networkx package.

Note: If you are using LDAP and want to run ART host tests, also install the libnss-sss:i386 package.

Installing required packages (Ubuntu 12.04)

You may use Ubuntu 12.04 to build older versions of Android. Version 12.04 is not supported on master or recent releases.

$ sudo apt-get install git gnupg flex bison gperf build-essential \
  zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev \
  libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 \
  libgl1-mesa-dev g++-multilib mingw32 tofrodos \
  python-markdown libxml2-utils xsltproc zlib1g-dev:i386
$ sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so

Installing required packages (Ubuntu 10.04 -- 11.10)

Building on Ubuntu 10.04-11.10 is no longer supported, but may be useful for building older releases of AOSP.

$ sudo apt-get install git gnupg flex bison gperf build-essential \
  zip curl zlib1g-dev libc6-dev lib32ncurses5-dev ia32-libs \
  x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev \
  libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown \
  libxml2-utils xsltproc

On Ubuntu 10.10:

$ sudo ln -s /usr/lib32/mesa/libGL.so.1 /usr/lib32/mesa/libGL.so

On Ubuntu 11.10:

$ sudo apt-get install libx11-dev:i386
针对的都是其它版本的,就是没有16的,然后14版本上还有一句话写到:需要一个64位的ubuntu......我就直接忽视了,看后面有没有什么错误在解决这个吧,不太清楚


下面的Configuring USB Access就先不管了


接下来参考http://source.android.com/source/downloading.html

安装Repo,用于下载Android源码

执行下面的命令

$ mkdir ~/bin
$ PATH=~/bin:$PATH

解释:在当前目录下创建bin目录,然后将bin路径添加到$PATH中,这个就相当于windows中在环境变量后面添加路径一样


然后

Download the Repo tool and ensure that it is executable:

$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
解释:下载Repo并保存在bin/repo下,下一句是给所有人加上可执行权限


接下来执行

$ mkdir WORKING_DIRECTORY
$ cd WORKING_DIRECTORY
创建该目录,并进入

写入git的用户名和邮箱(将双引号中的字符改为对应的内容),没有使用过git的可以在Windows上装一个,注册一下就可以了

$ git config --global user.name "Your Name"
$ git config --global user.email "you@example.com"
下面一步是初始化仓库

$ repo init -u https://android.googlesource.com/platform/manifest
这步开始,出现如下错误

  1. fatal: Cannot get https://gerrit.googlesource.com/git-repo/clone.bundle  
  2. fatal: error [Errno 101] Network is unreachable
这个网上是各种说法啊,结果一个都没有解决

因为上面的语句是在新建的WORKING_DIRECTORY下执行的,我试了半天,一不小心在bin目录下试了一下,结果成功了

当时在实验这个博客(http://blog.youkuaiyun.com/ldld1717/article/details/52462869)中的下面地址

repo init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest
//其中repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest是清华提供的镜像源
//repo init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest是中国科技技术大学的镜像源
// 如果提示无法连接到 gerrit.googlesource.com,可以编辑 ~/bin/repo文件,把 REPO_URL 一行替换成下面的:
//REPO_URL = 'https://gerrit-googlesource.lug.ustc.edu.cn/git-repo'
 
  • 1

不过我立马就关闭了终端,然后继续使用上面的命令在WORKING_DIRECTORY下执行,果然是失败了,和上面的错误一样,我忘记验证如果不改地址,在bin下会不会成功,而且也不知道是不是先到bin下初始化,然后再去WORKING_DIRECTORY下执行$repo sync,,,

我只是匆忙的在bin下执行了下面语句,Android源码就开始下载了

$ repo sync
上面说的让后来者去验证吧。


在ubuntu中操作vi见http://blog.youkuaiyun.com/molu_chase/article/details/53575058

Android虚拟机Dalvik完整源码,宝贵资源,欢迎下载! This directory contains the Dalvik virtual machine and core class library, as well as related tools, libraries, and tests. A note about the licenses and header comments --------------------------------------------- Much of the code under this directory originally came from the Apache Harmony project, and as such contains the standard Apache header comment. Some of the code was written originally for the Android project, and as such contains the standard Android header comment. Some files contain code from both projects. In these cases, the header comment is a combination of the other two, and the portions of the code from Harmony are identified as indicated in the comment. Here is the combined header comment: /* * Copyright (C) The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ---------- * * Portions of the code surrounded by "// BEGIN Harmony code" and * "// END Harmony code" are copyrighted and licensed separately, as * follows: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ Native SH call bridge --------------------- Native SH call bridge is written by Shin-ichiro KAWASAKI and Contributed to Android by Hitachi, Ltd. and Renesas Solutions Corp.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值