Android2.1源码编译,VirtualBox虚拟机,jdk1.5

Android2.1源码编译,VirtualBox虚拟机,jdk1.5

 

在同事和网友的帮助下,实现了一把在Virtualbox 虚拟中中编译Android源码,过程主要如下:

前提:事先下载好了 android2.1源码和jdk1.5,通过共享到虚拟机;

1,通过virtualbox打到主机与虚拟机共享 手动挂载 a,在虚拟机分配数据空间,指向主机,另外取名(最好不用默认的名称,建议修改,LinuxShared) b,将需要共享的文件放入主机的文件夹内(即上面指向的文件夹,该文件夹内有android2.1源码,jdk5,等) c,sudo mount -t vboxsf LinuxShared /home/zero/shared (zero是linux用户名对应的文件夹目录,shared是zero文件夹下的子目录) 该命令只在当前操作中有效,下次重启模拟器还需要执行该命令才能数据共享; 自动挂载 a,可以在/etc/fstab中添加一项 linuxShared /home/zero/shared vboxsf rw,gid=100,uid=1000,auto 0 0 这样就能够自动挂载了。 (我试过没用,不知道写错了哪里) 卸载的话使用下面的命令: sudo umount -f /home/zero/shared 2,Linux下安装jdk a,编译Android源码需要JDK1.5版(主要是需要其中的javadoc),1.6版是不兼容的。JDK1.5已经停止支持, 其最终的版本是JDK 5.0 Update 22。 从Sun官网上下载:http://java.sun.com/javase/downloads/5u22/jdk 选择平台Linux,勾选同意许可协议: 下载时选择jdk-1.5.0_22-linux-i586.bin 这里我在主机中下载好了,直接从 shared文件夹中拷贝出来, 目录 /home/zero/java/jdk-1.5.0_22-linux-i586.bin b,执行安装,需要有权限 赋予权限 才能够安装 默认都是没有执行权限的,可以通过 $ls -l 命令查询到相关信息,所以首先第一步是要将安装文件赋予可执行权限, 可以通过命令 $ sudo chmod u+x /home/zero/java/jdk-6u20-linux-i586.bin (jdk存放目录)来实现。 $ cd /zero/java/ 进入安装文件所在目录,然后执行命令 $ ./jdk-1_5_0_22-linux-i586.bin 来安装。 c,一直回车,直至输入yes,确定安装,安装之后 在 /home/zero/java目录下有新生成一个目录,意味着安装成功。 d,再配置环境变量 sudo vim /etc/environment或者 (试过没用) sudo vi /etc/environment或者 sudo gedit /etc/environment都是文字编辑环境变量工具 PATH="...... :/home/zero/java/jdk1.5.0_22/bin"(:之前是之前已有内容,添加新的用:隔开) CLASSPATH=".:/home/zero/java/jdk1.5.0_22/lib" JAVA_HOME="/home/zero/java/jdk1.5.0_22" 因为ubuntu可能还会有默认的jdk,如openjdk;所以,为了使默认使用的是我们安装的jdk,还需执行如下命令: update-alternatives --install /usr/bin/java java /home/zero/java/jdk1.5.0_22/bin/java 300 update-alternatives --install /usr/bin/javac javac /home/zero/java/jdk1.5.0_22/bin/javac 300 这2行命令告诉系统jvm的存在,然后可以通过 sudo update-alternatives --config java sudo update-alternatives --config javac 来切换java跟javac的版本 e,java -version 查看版本号,如果能成功查看则ok 3. sdk的编译 a,安装sdk2.1之前需要下载一些工具包来编译adk, 而在进行下面的代码之前,必须有root权限 Ubuntu安装好后,默认root用户是没有密码的,但是默认关闭了root用户的登录,所以无法登陆 安装的时候设置的用户是唯一可以执行sudo命令的用户 如果非要用root用户登录,需要用安装的时候创建的用户登录进去以后,执行命令 sudo passwd root 设置密码以后,就可以使用 su root 来切换到root用户了 # apt-get install git-core gnupg flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build- essential zip curl libncurses5-dev zlib1g-dev (数字 1) # apt-get install valgrind # apt-get install lib32readline5-dev (该软件包我当时没找到,但libreadline5-dev可以找到) b,然后进入到sdk(eclair源码)主目录 执行 . ./build/envsetup.sh 两个点之间有一个空格 tapas 之后会出现4个问句,分别选 1, 1, utc100, eng mm 建议下面的操作在之前就做(我就先检查 gcc --version ,如果是4.4的就改) 在mm的过程可能会出现变异错误的问题,导致改原因的可能是由于android编译要求是gcc4.3 ,如果是gcc 4.4 的话就可能出编译错误 恰好ubuntu10中自带的就是gcc4.4,因此我们需要调整gcc4.3的版本,方法如下:(gcc --version) sudo apt-get install gcc-4.3 g++-4.3 sudo apt-get install g++-multlib g++-4.3-multilib (64bit系统需要) 然后修改链接 cd /usr/bin/ ls -l 可以看到gcc只是个链接而已,指向4.4 修改下 指向4.3 sudo ln -snf gcc-4.3 gcc sudo ln -snf g++-4.3 g++ sudo ln -snf cpp-4.3 cpp (不知道是不是必须的) sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.3 40 sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.4 30 (可不要) 把gcc4.3 4.4都加进去,然后我们可以通过 sudo update-alternatives --config gcc 来切换gcc的版本了 然后编译的时候需要重新执行 . ./build/envsetup.sh tapas (这里跟着它走就好了,有默认选项的,1 1 utc100 eng) mm

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、付费专栏及课程。

余额充值