Ubuntu Touch環境搭建


最近搞了一下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走)。

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 at https://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, including our 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#ccache in 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 to set up the tools PPA.

Then you need to install phablet-tools:

  • $ sudo apt-get install phablet-tools

This will also install the repo tool, used to sync the Android repositories. Learn more about the repo tool. If you already have a repo tool in your $PATH from 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 $ which repo. 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 -c switch, 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 -v switch:

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

The phablet-dev-bootstrap command will automatically use the repo tool 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).

搭建你的編譯環境

我們將使用Android基礎組件(基於Android AOSP)來編譯。

我們只會用到Android中的C/C++代碼,所以你會發現你的編譯環境會比傳統的Android編譯環境要小。

你可以使用Ubuntu 12.04LTS到13.04的64位桌面版來開發Ubuntu Touch。(博主使用Mint 14.04,基於Ubuntu 14.04)

我們可以安裝ccache(ccache會加快Android編譯速度),但不是必需的。(http://source.android.com/source/initializing.html#ccache Android配置向導會指導你如何安裝)

我們還需要這些安裝包來編譯主機上的編譯工具:

$ 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

在Utopic(Ubuntu 14.10)(或者其他)中,還需要安裝g---4.8

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

在Ubuntu 14.04穩定前你還需要安裝PPA工具(只需要把“Add PPAs (pre Trusty only)”那一步執行就ok了。)

然后安裝phablet-tools:

$ sudo apt-get install phablet-tools

這會安裝repo工具,repo用於同步Android的repositories。 點擊了解repo工具。如果你已經有了repo工具且已經在之前的Android開發中把執行路徑加入到$PATH中了,請把repo刪除,或保證在$PATH中repo的路徑在系統的repo command的路徑(如/bin/repo)之后。你可以使用$ which repo驗證repo路徑是否正確。如果正確,會返回/usr/bin/repo。

(這段還沒弄清楚什么意思,因為我還沒編譯過,應該保證是/usr/bin/repo就可以了。到時候回來補充)

然后使用repo和git(只需要安裝git,不需要實際執行,repo會調用git工具),從以下網址獲取Android源碼。這一步對於Android Rom開發者應該很熟悉。

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

(此鏈接會另寫一篇文章,下載源碼的工作都在這個鏈接中)

使用之前步驟已經安裝了的phablet-dev-bootstrap,就可以一個個項目地下載所有的Android代碼(大概可有640多個)。這個工具使用Python將repo封裝了起來。在所有的代碼被repo和git管理之前,這個工具也可以用於下載bzr repositories(和repo相似的一個管理工具)的工程。不過只用於獲取開發用的源碼的話,已經不需要這個功能了。

接下來讓代碼跑起來:

phablet-dev-bootstrap [target_directory]

如果發生某些錯誤導致sync中途停止了,你可以使用-c參數繼續同步:

phablet-dev-bootstrap -c [target_directory]

如果你只是編譯一個已經被支持的設備的燒錄文件,你可以使用-v參數:

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

phablet-dev-bootstrap命令會使用repo工具自動下載manifest(項目列表)然后下載所有的git項目和需要的數據。注意這個步驟要很長的時間,而且需要至少15GB(加上2-3GB的二進制文件輸出)的空間。

 

版權所有,轉載請注明出處:

http://www.cnblogs.com/sickworm/p/3985296.html 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM