Ubuntu12.10 编译Android 4.2

前端之家收集整理的这篇文章主要介绍了Ubuntu12.10 编译Android 4.2前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

1. 简介

本文描述在X86 64位机(cpu i5)建立Android 4.2编译环境。

2. 安装Ubuntu12.10

http://releases.ubuntu.com/quantal/上下载PC (Intel x86) desktop image,然后进行安装即可。

2.1 安装vim

sudo apt-get install vim

2.2 设置root密码及root登录

sudo passwd root

设置可使用root用户登录

vim /etc/lightdm/lightdm.conf

在最后增加一行:

greeter-show-manual-login=true

保存文件,重启系统则可用root登录

2.3 安装ssh服务器

sudoapt-get install openssh-server

重启系统则生效。

2.4 安装并配置samba

sudo apt-get install samba

用以下smb.conf替换/etc/samba/smb.conf,并把原来的做一个备份,此配置将使系统每个用户都以自己的根目录访问samba。

# smb.conf is the main Samba configuration file. You find a full commented
# version at /usr/share/doc/packages/samba/examples/smb.conf.SUSE if the
# samba-doc package is installed.
# Date: 2007-09-22
[global]
	workgroup = WORKGROUP
	printing = cups
	printcap name = cups
	printcap cache time = 750
	cups options = raw
	include = /etc/samba/dhcp.conf
	logon path = \\%L\profiles\.msprofile
	logon home = \\%L\%U\.9xprofile
	logon drive = P:
#	usershare allow guests = Yes
	domain logons = Yes
	domain master = Yes
	local master = Yes
	os level = 65
	preferred master = Yes
	null passwords = yes
	security = share
	guest ok = yes
	usershare max shares = 100
	security = user
	encrypt passwords = yes
	smb password file = /etc/samba/smbpasswd
#	root = jerry

#[tim]
#	comment = tim 
#	inherit acls = Yes
#	path = /home/tim
#	read only = No
[homes]
        comment = Home Directories
        browseable = no
        writable = yes
        valid users = %S

2.5 创建Linux及samba用户

相关命令如下所示:

// Create Linux user and root directory
#adduser tim 

// Create samba user
#mbpasswd -a tim

// start samba service
#service smbd restart

3. 建立Android4.2编译环境

Android编译环境需求如下:

•Python 2.6 -- 2.7:可从python.org下载,Ubuntu12.10中已经包含Python2.7;

•GNU Make 3.81 -- 3.82:可从gnu.org下载,Ubuntu12.10中已经包含3.81;

•JDK 6:Android2.3以上的版本,可Java SE 6 Downloads上下载jdk-6u45-linux-x64.bin,然后进行安装;

•Git 1.7或以上版本:可从 git-scm.com上下载。

3.1安装必要的编译工具包

$ 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

安装上面的会导致桌面菜单栏不见了,下面的就没有问题。

$ 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-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

经过测试发现,只要执行了: apt-get install libgl1-mesa-glx:i386,它将删除以下三个模块,从面导致Ubuntu桌面不见了。

The following packages will be REMOVED:
  libgl1-mesa-dri ubuntu-desktop xorg


3.2 安装JDK6

1) 下载jdk-6u45-linux-x64.bin

2) 安装JDK6

chmod a+x jdk-6u45-linux-x64.bin
sudo mv jdk-6u38-linux-x64.bin /usr/java
cd /usr/java
sudo ./jdk-6u45-linux-x64.bin

3) 修改配置文件/root/.bashrc(对所有用户有效)
export JAVA_HOME=/usr/java/jdk1.6.0_45
export PATH=$PATH:$JAVA_HOME:$JAVA_HOME/bin:$JAVA_HOME/jre/bin
重启系统,使用java --version确认java版本是否为:1.6.0_45


4. 安装SDK和NDK

4.1 安装SDK

1) 下载SDK(如:android-sdk_r22.0.5-linux.tgz)从http://developer.android.com/sdk/index.html

2) copy SDK到/usr/android/

3) tar xvf android-sdk-r22.0.5-linux.tgz

4) 修改配置文件/root/.bashrc

export SDK_HOME=/usr/android/android-sdk-linux
export PATH=$PATH:$SDK_HOME/tools:$SDK_HOME/platform-tools


5) 更新SDK:tools/android update sdk --no-ui 或tools/android sdk(有界面进行选择)

4.2 安装NDK

1)下载NDK(如:android-ndk-r9-linux-x86_64.tar.bz2) 从以下地址:

http://developer.android.com/tools/sdk/ndk/index.html

2) copy NDK到/usr/android/

3) tar xvf android-ndk-r9-linux-x86_64.tar.bz2

4) 修改配置文件/root/.bashrc

export PATH=$PATH:/usr/android/android-ndk-r9



参考:http://source.android.com/source/initializing.html

猜你在找的Ubuntu相关文章