大学IT网 - 最懂大学生的IT学习网站! QQ资料交流群:367606806
当前位置:大学IT网 > Android技巧 > Ubuntu Touch环境搭建

Ubuntu Touch环境搭建

关键词:搭建环境UbuntuTouch  阅读(2251) 赞(16)

[摘要]本文是对Ubuntu Touch环境搭建的讲解,对学习Android编程技术有所帮助,与大家分享。

最近搞了一下Nexus 5的MultiRom Manger,体验了一把Ubuntu Touch和Android L,总体感觉还不错,不过Android L的NFC驱动还有问题,Ubuntu Touch优化还不足,画面有点卡,而且无法关背光。于是萌生了参与Ubuntu Touch驱动开发的念头,也算是把工作当成一种兴趣吧。

Ubuntu Touch for Nexus 5是非官方的,官方的只有Nexus 4,7,10。我们从MultiRom Manager可以直接下载到for Nexus 5的最新版本。

鉴于中文博客中并没有相关教程,只能参照 Ubuntu Touch 环境搭建的官方文档:

https://wiki.ubuntu.com/Touch/Building

以下记录我搭建Ubuntu Touch的过程(跟着上面的wiki走)。

2014-9-22:

文档进度:前期翻译

实际进度:源码已经拉下来了,但是sync还有点问题。

Building Ubuntu Touch Android pieces from source

Whether you want to build Ubuntu Touch for the currently supported Nexus devices or want to port it to a new target, you need to set up your working environment to build Android from source. This setup is more or less the same whether you are building AOSP or a project based on it such as CyanogenMod, SEAndroid or Ubuntu Touch.

If you are new to building Android sources you may want to check out this document and others in the Getting Started section on the Google documentation site, as it covers the basics and terminology of AOSP building.While Ubuntu Touch uses some helper scripts as detailed below, if will nonetheless be helpful to understand what is going on under the hood especially if you want to work on this part of the project.

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

For Ubuntu Touch, you can find all the needed Android git repositories athttps://code-review.phablet.ubuntu.com/#/admin/projects/. This is basically a mirror of AOSP 4.4.2_r1, but containing only the needed low level services used by Android (e.g. no Dalvik at all).

For any Android related project on our git server, you'll find a branch named phablet-4.4.2_r1. This branch contains a static known git HEAD and the required changes needed for Ubuntu, includingour custom Android manifest.

从源码编译Ubuntu Touch的Android部分

无论你想编译现在已经支持的Nexus设备,还是想为一个新设备移植Ubuntu Touch,你都需要的搭建编译环境来编译Android源码。该教程大致和你编译AOSP(Android Open Source Project)或者基于AOSP的项目是一样的,如CyanogenMod,SeAndroid或者Ubuntu Touch。

如果你是第一次编译Android源码,你可能需要下面这个文档,和Google文档网站Getting Started章节上的其他相关文档,文档讲解了AOSP编译的基础和一些术语。在下面的环节中Ubuntu Touch会使用一些辅助脚本。如果你打算在项目上做相关开发,通过浏览这些文档你会更明白接下来的每一步是在做什么。

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

你可以在https://code-review.phablet.ubuntu.com/#/admin/projects/找到所有搭建Ubuntu Touch需要的Android git repositories(repo是一个多git项目管理工具,这个东西在天朝不稳定的网络中显得非常难用)。这是一个基于AOSP 4.4.2_r1的镜像,但只包含了低层Android运行所需要的服务(例如没有Dalvik)。

在我们的git服务器上任意一个Android相关的项目,你都会找到一个叫phablet-4.4.2_r1的分支,这个分支包含了一个git HEAD和包括custom Android manifest(Ubuntu Touch的repo的Manifest,包含了所有Ubuntu Touch的基础git项目)等对于Ubuntu需要修改的代码。(这段不太明白想说什么)

Set up your development environment

At this moment we're using the Android code base provided by Android AOSP.

Everything we take from Android is just C/C++, so you'll notice that your Android build environment will be way smaller than when comparing to the traditional Android builds.

For development you can run any 64-bit Desktop version of Ubuntu between 12.04 LTS and 13.04.

It's not strictly necessary, but it's helpful to install ccache.(http://source.android.com/source/initializing.html#ccachein the general Android Setup guide should help with this.)

Additional packages which are used to build the host tools:

  • $ sudo apt-get install git gnupg flex bison gperf build-essential \
      zip bzr 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 schedtool

On Utopic (and maybe other) the 4.8 version of g++ is needed:

  • $ sudo apt-get install g++-4.8-multilib

Before 14.04 Trusty you'll also need toset up the tools PPA.

Then you need to install phablet-tools:

  • $ sudo apt-get install phablet-tools

This will also install therepotool, used to sync the Android repositories.Learn more about the repo tool. If you already have a repo tool in your$PATHfrom previous android development, be sure to remove it or make sure it's after the system repo command in the path. To check that the right repo command is used, you can issue$whichrepo. This should return/usr/bin/repo.

You can check out the source code using the repo and git tools already familiar to Android ROM developers, as described here

https://wiki.ubuntu.com/Touch/AndroidDevel

Alternately, all the Android code can be downloaded using the phablet-dev-bootstrap tool provided by the phablet-tools package installed in the previous step. This tool is a Python wrapper around repo and used to also check out bzr repositories before all code was managed by repo and git. For the purposes of getting the source code for development it is no longer needed.

To get the code setup run:

  • phablet-dev-bootstrap [target_directory]

If for some reason the sync ends midway, you can continue the sync with the-cswitch, so the command would be:

  • phablet-dev-bootstrap -c [target_directory]

Alternatively, if you are just building an image for an already supported device, you can specify the-vswitch:

  • phablet-dev-bootstrap -v [device codenames] [target_directory]

Thephablet-dev-bootstrapcommand will automatically use therepotool with the Ubuntu Touch Preview custom manifest to download all the git repositories and needed data.Be aware that this step takes a long time and requires at least 15GB (plus 2-3GB for the binary output).



相关评论