Ubuntu下Android源码修改、编译及运行、launcher定制

合集下载

ubuntu安装及android源码编译环境搭建

ubuntu安装及android源码编译环境搭建

ubuntu安装及android源码编译环境搭建为了能够编译和运行 Android 源码,我们需要在 Ubuntu 系统中搭建相应的开发环境。

下面是 Ubuntu 安装及 Android 源码编译环境搭建的详细步骤:一、Ubuntu 系统的安装2.将ISO文件写入USB或DVD中,制作启动盘。

3.在计算机上将系统引导到USB活动盘或DVD上,并启动系统。

4. 在启动菜单中选择安装 Ubuntu,按照提示完成安装过程。

二、系统更新和软件安装1.安装后,运行系统更新以获取最新的软件包和安全修复程序。

可以在终端中运行以下命令:```sudo apt updatesudo apt upgrade```2.安装开发工具和编译器。

可以在终端中运行以下命令:```sudo apt install build-essentialsudo apt install openjdk-8-jdksudo apt install pythonsudo apt install gitsudo apt install curlsudo apt install gnupg```1. 配置 Git 个人信息,可以在终端中运行以下命令:```git config --global "Your Name"``````chmod a+x ~/bin/repo```3. 配置 PATH 环境变量,这样在终端中就可以使用 Repo 了。

打开`~/.bashrc` 文件,并在末尾添加以下内容:```export PATH=~/bin:$PATH```4.执行以下命令使配置生效:```source ~/.bashrc```1. 创建一个空文件夹作为 Android 源码存放的目录,并在终端中进入该目录。

```repo init -u <URL> -b <branch>````````````repo sync```5.开始编译。

在Ubuntu上下载、编译和安装Android最新源代码

在Ubuntu上下载、编译和安装Android最新源代码

在Ubuntu上下载、编译和安装Android最新源代码在Ubuntu上下载、编译和安装Android最新源代码官⽹内容:Initializing a Build EnvironmentThe "Getting Started" section describes how to set up your local work environment, how to use Repo to get the Android files, and how to build the files on your machine. To build the Android source files, you will need to use Linux or Mac OS. Building undernot currently supported.Note: The source download is approximately 6GB in size. You will need 25GB free to complete a single build, and up to 80GB (or more) for a full set of builds.For an overview of the entire code-review and code-update process, see Life of a Patch.Setting up a Linux build environmentThe Android build is routinely tested in house on recent versions of Ubuntu LTS (10.04), but most distributions should have the required build tools available. Reports of successes or failures on other distributions are welcome.Note: It is also possible to build Android in a virtual machine. If you are running Linux in a virtual machine, you will need at least 16GB of RAM/swap and 30GB or more of disk space in order to build the Android tree.In general you will need:Python 2.4 -- 2.7, which you can download from .JDK 6 if you wish to build Gingerbread or newer; JDK 5 for Froyo or older. You can download both from .Git 1.7 or newer. You can find it at .Detailed instructions for Ubuntu 10.04+ follow.Installing the JDKThe Sun JDK is no longer in Ubuntu's main package repository. In order to download it, you need to add the appropriate repository and indicate to the system which JDK should be used.Java 6: for Gingerbread and newer$ sudo add-apt-repository "deb / lucid partner"$ sudo apt-get update$ sudo apt-get install sun-java6-jdkJava 5: for Froyo and older$ sudo add-apt-repository "deb /ubuntu hardy main multiverse"$ sudo add-apt-repository "deb /ubuntu hardy-updates main multiverse"$ sudo apt-get update$ sudo apt-get install sun-java5-jdkInstalling required packages64-bit (recommended)$ sudo apt-get install git-core 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 libxm On newer versions of Ubuntu such as 11.10 you may need to do the following:$ sudo ln -s /usr/lib/i386-linux-gnu/libX11.so.6 /usr/lib/i386-linux-gnu/libX11.so32-bit (experimental)$ sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev libc6-dev libncurses5-dev x11proto-core-dev libx11-dev libreadline6-dev libgl1-mesa-dev tofrodos python-markdown libxml2-utilsConfiguring USB AccessUnder GNU/linux systems (and specifically under Ubuntu systems), regular users can't directly access USB devices by default. The system needs to be configured to allow such access.The recommended approach is to create a file /etc/udev/rules.d/51-android.rules (as the root user) and to copy the following lines in it.must be replaced by the actual username of the user who is authorized to access the phones over USB.# adb protocol on passion (Nexus One)SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e12", MODE="0600", OWNER="<username>"# fastboot protocol on passion (Nexus One)SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", ATTR{idProduct}=="0fff", MODE="0600", OWNER="<username>"# adb protocol on crespo/crespo4g (Nexus S)SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e22", MODE="0600", OWNER="<username>"# fastboot protocol on crespo/crespo4g (Nexus S)SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e20", MODE="0600", OWNER="<username>"# adb protocol on maguro (Galaxy Nexus)SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", MODE="0600", OWNER="<username>"# fastboot protocol on maguro (Galaxy Nexus)SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e30", MODE="0600", OWNER="<username>"Those new rules take effect the next time a device is plugged in. It might therefore be necessary to unplug the device and plug it back into the computer.This is known to work on both Ubuntu Hardy Heron (8.04.x LTS) and Lucid Lynx (10.04.x LTS). Other versions of Ubuntu or other variants of GNU/linux might require different configurations.Setting up a Mac OS X build environmentTo build the Android files in a Mac OS environment, you need an Intel/x86 machine running MacOS 10.6 (Snow Leopard).Android must be built on a case-sensitive file system because the sources contain files that differ only in case. We recommend that you build Android on a partition that has been formatted with the journaled file system HFS+. HFS+ is required to successfully OS applications such as the Android Emulator for OS X.Creating a case sensitive disk imageIf you want to avoid partitioning/formatting your hard drive, you can use a case-sensitive disk image instead. To create the image, launch Disk Utility and select "New Image". A size of 25GB is the minimum to complete the build, larger numbers are more future-Using sparse images saves space while allowing to grow later as the need arises. Be sure to select "case sensitive, journaled" as the volume format.You can also create it from a shell with the following command:# hdiutil create -type SPARSE -fs 'Case-sensitive Journaled HFS+' -size 40g ~/android.dmgThis will create a .dmg (or possibly a .dmg.sparsefile) file which, once mounted, acts as a drive with the required formatting for Android development. For a disk image named "android.dmg" stored in your home directory, you can add the following toyour ~/.bash_profile to mount the image when you execute "mountAndroid":# mount the android file imagefunction mountAndroid { hdiutil attach ~/android.dmg -mountpoint /Volumes/android; }Once mounted, you'll do all your work in the "android" volume. You can eject it (unmount it) just like you would with an external drive.Installing required packagesInstall XCode from the Apple developer site. We recommend version 3.1.4 or newer, i.e. gcc 4.2. Version 4.x could cause difficulties. If you are not already registered as an Apple developer, you will have to create an Apple ID in order to download.Install MacPorts from .Note: Make sure that /opt/local/bin appears in your path BEFORE /usr/bin. If not, addexport PATH=/opt/local/bin:$PATHto your ~/.bash_profile.Get make, git, and GPG packages from MacPorts:$ POSIXLY_CORRECT=1 sudo port install gmake libsdl git-core gnupgIf using Mac OS 10.4, also install bison:$ POSIXLY_CORRECT=1 sudo port install bisonReverting from make 3.82There is a bug in gmake 3.82 that prevents android from building. You can install version 3.81 using MacPorts by taking the following steps:Edit /opt/local/etc/macports/sources.conf and add a line that saysfile:///Users/Shared/dportsabove the rsync line. Then create this directory:$ mkdir /Users/Shared/dportsIn the new dports directory, run$ svn co --revision 50980 /repository/macports/trunk/dports/devel/gmake/ devel/gmake/Create a port index for your new local repository:$ portindex /Users/Shared/dportsFinally, install the old version of gmake with$*************************Setting a file descriptor limitOn MacOS the default limit on the number of simultaneous file descriptors open is too low and a highly parallel build process may exceed this limit.To increase the cap, add the following lines to your ~/.bash_profile:# set the number of open files to be 1024ulimit -S -n 1024Downloading the Source TreeInstalling RepoRepo is a tool that makes it easier to work with Git in the context of Android. For more information about Repo, see Version Control.To install, initialize, and configure Repo, follow these steps:Make sure you have a bin/ directory in your home directory, and that it is included in your path:$ mkdir ~/bin$ PATH=~/bin:$PATHDownload the Repo script and ensure it is executable:$ curl https:///dl/googlesource/git-repo/repo > ~/bin/repo$ chmod a+x ~/bin/repoThe SHA-1 checksum for repo is e1fd3bef059d152edf4d0522590725d317bc637fInitializing a Repo clientAfter installing Repo, set up your client to access the android source repository:Create an empty directory to hold your working files. If you're using MacOS, this has to be on a case-sensitive filesystem. Give it any name you like:$ mkdir WORKING_DIRECTORY$ cd WORKING_DIRECTORYRun repo init to bring down the latest version of Repo with all its most recent bug fixes. You must specify a URL for the manifest, which specifies where the various repositories included in the Android source will be placed within your working directory.$ repo init -u https:///platform/manifestTo check out a branch other than "master", specify it with -b:$ repo init -u https:///platform/manifest -b android-4.0.1_r1When prompted, please configure Repo with your real name and email address. To use the Gerrit code-review tool, you will need an email address that is connected with a registered Google account. Make sure this is a live address at which you can receive mes The name that you provide here will show up in attributions for your code submissions.A successful initialization will end with a message stating that Repo is initialized in your working directory. Your client directory should now contain a .repo directory where files such as the manifest will be kept.Getting the filesTo pull down files to your working directory from the repositories as specified in the default manifest, run$ repo syncThe Android source files will be located in your working directory under their project names. The initial sync operation will take an hour or more to complete. For more about repo sync and other Repo commands, see Version Control.Verifying Git TagsLoad the following public key into your GnuPG key database. The key is used to sign annotated tags that represent releases.$ gpg --importCopy and paste the key(s) below, then enter EOF (Ctrl-D) to end the input and process the keys.-----BEGIN PGP PUBLIC KEY BLOCK-----Version: GnuPG v1.4.2.2 (GNU/Linux)mQGiBEnnWD4RBACt9/h4v9xnnGDou13y3dvOx6/t43LPPIxeJ8eX9WB+8LLuROSVlFhpHawsVAcFlmi7f7jdSRF+OvtZL9ShPKdLfwBJMNkU66/TZmPewS4m782ndtw7lFhpHawsVAcFlmi7f7jdSRF+OvtZL9ShPKdLfwBJMNkU66/TZmPewS4m782ndtw78tR1cXb197Ob8kOfQB3A9yk2XZ4ei4ZC3i6wVdqHLRxABdncwu5hOF9KXwCgkxMDu4PVgChaAJzTYJ1EG+UYBIUEAJmfearb0qRAN7dEoff0FeXsEaUA6U90sEoVks0ZwNj96SA8BL+a1OoEUUfpMhiHyLuQSftxisJxTh+2QclzDviDyaTrkANjdYY7p2cq/HMdOY7LJlHaqtXmZxXjjtw5Uc2QG8UY8aziU3IE9nTjSwCXeJnuyvoizl9/I1S5jU5SA/9WwIps4SC84ielIXiGWEqq6i6/sk4I9q1YemZF2XVVKnmI1F4iCMtNKsR4MGSa1gA8s4iQbsKNWPgp7M3a51JCVCu6l/8zTpA+uUGapw4tWCp4o0dpIvDPBEa9b/aF/ygcR8mh5hgUfpF9IpXdknOsbKCvM9lSSfRciETykZc4wrRCVGhlIEFuZHJvaWQgT3BlbiBTb3VyY2UgUHJvamVjdCA8aW5pdGlhbC1jb250cmlidXRpb25AYW5kcm9pZC5jb20+iGAEExECACAFAknnWD4CGwMGCwkIBwMCBBUCCAMEFgIDAQIeAQIXgAAKCRDorT+BmrEOeNr+AJ42Xy6tEW7r3KzrJxnRX8mij9z8tgCdFfQYiHpYngkI2t09Ed+9Bm4gmEO5Ag0ESedYRBAIAKVW1JcMBWvV/0Bo9WiByJ9WJ5swMN36/vAlQN4mWRhfzDOk/Rosdb0csAO/l8Kz0gKQPOfObtyYjvI8JMC3rmi+LIvSUT9806UphisyEmmHv6U8gUb/xHLIanXGxwhYzjgeuAXVCsv+EvoPIHbY4L/KvP5x+oCJIDbkC2b1TvVk9PryzmE4BPIQL/NtgR1oLWm/uWR9zRUFtBnE411aMAN3qnAHBBMZzKMXLWBGWE0znfRrnczI5p49i2YZJAjyX1P2WzmScK49CV82dzLo71MnrF6fj+Udtb5+OgTg7Cow+8PRaTkJEW5Y2JIZpnRUq0CYxAmHYX79EMKHDSThf/8AAwUIAJPWsB/MpK+KMs/s3r6nJrnYLTfdZhtmQXimpoDMJg1zxmL8UfNUKiQZ6esoAWtDgpqt7Y7sKZ8laHRARonte394hidZzM5nb6hQvpPjt2OlPRsyqVxw4c/KsjADtAuKW9/d8phbN8bTyOJo856qg4oOEzKG9eeF7oaZTYBy33BTL0408sEBxiMior6b8LrZrAhkqDjAvUXRwm/fFKgpsOysxC6xi553CxBUCH2omNV6Ka1LNMwzSp9ILz8jEGqmUtkBszwoG1S8fXgE0Lq3cdDM/GJ4QXP/p6LiwNF99faDMTV3+2SAOGvytOX6KjKVzKOSsfJQhN0DlsIw8hqJc0WISQQYEQIACQUCSedYRAIbDAAKCRDorT+BmrEOeCUOAJ9qmR0lEXzeoxcdoafxqf6gZlJZlACgkWF7wi2YLW3Oa+jv2QSTlrx4KLM==Wi5D-----END PGP PUBLIC KEY BLOCK-----After importing the keys, you can verify any tag with$ git tag -v TAG_NAMEBuilding the SystemThe basic sequence of build commands is as follows:InitializeInitialize the environment with the envsetup.sh script. Note that replacing "source" with a single dot saves a few characters, and the short form is more commonly used in documentation.$ source build/envsetup.shor$ . build/envsetup.shChoose a TargetChoose which target to build with lunch. The exact configuration can be passed as an argument, e.g.$ lunch full-engThe example above refers to a complete build for the emulator, with all debugging enabled.If run with no arguments lunch will prompt you to choose a target from the menu.All build targets take the form BUILD-BUILDTYPE, where the BUILD is a codename referring to the particular feature combination:Build name Device Notesfull emulator fully configured with all languages, apps, input methodsfull_maguro maguro full build running on Galaxy Nexus GSM/HSPA+ ("maguro")full_panda panda full build running on PandaBoard ("panda")and the BUILDTYPE is one of the following:Buildtype Useuser limited access; suited for productionuserdebug like "user" but with root access and debuggability; preferred for debuggingeng development configuration with additional debugging toolsFor more information about building for and running on actual hardware, see Building for devicesBuild the CodeBuild everything with make. GNU make can handle parallel tasks with a -jN argument, and it's common to use a number of tasks N that's between 1 and 2 times the number of hardware threads on the computer being used for the build. E.g. on a dual-E5520 mac CPUs, 4 cores per CPU, 2 threads per core), the fastest builds are made with commands between make -j16 and make -j32.$ make -j4Run It!You can either run your build on an emulator or flash it on a device. Please note that you have already selected your build target with lunch, and it is unlikely at best to run on a different target than it was built for.Flash a DeviceTo flash a device, you will need to use fastboot, which should be included in your path after a successful build. Place the device in fastboot mode either manually by holding the appropriate key combination at boot, or from the shell with$ adb reboot bootloaderOnce the device is in fastboot mode, run$ fastboot flashall -wThe -w option wipes the /data partition on the device; this is useful for your first time flashing a particular device, but is otherwise unnecessary.For more information about building for and running on actual hardware, see Building for devicesEmulate an Android DeviceThe emulator is added to your path automatically by the build process. To run the emulator, type$ emulatorUsing ccacheccache is a compiler cache for C and C++ that can help make builds faster. In the root of the source tree, do the following:$ export USE_CCACHE=1$ export CCACHE_DIR=/<path_of_your_choice>/.ccache$ prebuilt/linux-x86/ccache/ccache -M 20GYou can watch ccache being used by doing the following:$ watch -n1 -d prebuilt/linux-x86/ccache/ccache -sOn OSX, you should replace linux-x86 with darwin-x86.Troubleshooting Common Build ErrorsWrong Java VersionIf you are attempting to build froyo or earlier with Java 1.6, or gingerbread or later with Java 1.5, make will abort with a message such as************************************************************You are attempting to build with the incorrect versionof java.Your version is: WRONG_VERSION.The correct version is: RIGHT_VERSION.Please follow the machine setup instructions at/download************************************************************This may be caused byfailing to install the correct JDK as specified on the Initializing page. Building Android requires Sun JDK 5 or 6 depending on which release you are building.another JDK that you previously installed appearing in your path. You can remove the offending JDK from your path with:$ export PATH=${PATH/\/path\/to\/jdk\/dir:/}Python Version 3Repo is built on particular functionality from Python 2.x and is unfortunately incompatible with Python 3. In order to use repo, please install Python 2.x:$ apt-get install pythonGmake Version 3.82There is a bug in make version 3.82 on Mac OS that prevents building Android.TODO: what the error looks like with GNU make 3.82 on older builds that don't explicitly detect it.Follow the instructions on the Initializing page for reverting GNU make from 3.82 to 3.81.Case Insensitive FilesystemIf you are building on an HFS filesystem on Mac OS X, you may encounter an error such as************************************************************You are building on a case-insensitive filesystem.Please move your source tree to a case-sensitive filesystem.************************************************************Please follow the instructions on the Initializing page for creating a case-sensitive disk image.No USB PermissionOn most Linux systems, unprivileged users cannot access USB ports by default. If you see a permission denied error, follow the instructions on the Initializing page for configuring USB access.If adb was already running and cannot connect to the device after getting those rules set up, it can be killed with adb kill-server. That will cause adb to restart with the new configuration.Building for devicesThis page complements the main page about Building with information that is specific to individual devices.The only supported phone with the current release is the GSM/HSPA+ Galaxy Nexus, a.k.a. "maguro". GSM/HSPA+ Galaxy Nexus is currently the recommended device to use with the Android Open-Source Project.In addition, PandaBoard a.k.a. "panda" is supported in the master branch only, but is currently considered experimental. The specific details to use a PandaBoard with the Android Open-Source Project are in the file device/ti/panda/README in the source tree. Nexus S, a.k.a. "crespo", and Nexus S 4G, a.k.a. "crespo4g", are supported with gingerbread, but can't currently be used with newer versions of the Android Open-Source Project.Nexus One a.k.a. "passion" is obsolete, was experimental in gingerbread and unsupported, and can't be used with newer versions of the Android Open-Source Project.Android Developer Phones (ADP1 and ADP2, a.k.a. "dream" and "sapphire") are obsolete, were experimental and unsupported in froyo, and can't be used with newer versions of the Android Open-Source Project.Building fastboot and adbIf you don't already have those tools, fastboot and adb can be built with the regular build system. Follow the instructions on the page about building, and replace the main make command with$ make fastboot adbBooting into fastboot modeDuring a cold boot, the following key combinations can be used to boot into fastboot mode, which is a mode in the bootloader that can be used to flash the devices:Device Keysmaguro Press and hold both Volume Up and Volume Down, then press and hold Powercrespo Press and hold Volume Up, then press and hold Powercrespo4g Press and hold Volume Up, then press and hold Powerpassion Press and hold the trackball, then press Powersapphire Press and hold Back, then press Powerdream Press and hold Back, then press PowerAlso, on devices running froyo or later where adb is enabled, the command adb reboot bootloader can be used to reboot from Android directly into the bootloader with no key combinations.Unlocking the bootloaderIt's only possible to flash a custom system if the bootloader allows it.This is the default setup on ADP1 and ADP2.On Nexus One, Nexus S, Nexus S 4G, and Galaxy Nexus, the bootloader is locked by default. With the device in fastboot mode, the bootloader is unlocked with$ fastboot oem unlockThe procedure must be confirmed on-screen, and deletes the user data for privacy reasons. It only needs to be run once.On Nexus One, the operation voids the warranty and is irreversible.On Nexus S, Nexus S 4G, and Galaxy Nexus, the bootloader can be locked back with$ fastboot oem lockObtaining proprietary binariesStarting with IceCreamSandwich, the Android Open-Source Project can't be used from pure source code only, and requires additional hardware-related proprietary libraries to run, specifically for hardware graphics acceleration.Official binaries for Nexus S, Nexus S 4G, Galaxy Nexus, and PandaBoard can be downloaded from Google's Nexus driver page, which add access to additional hardware capabilities with non-Open-Source code.There are no official binaries for Nexus One, ADP2 or ADP1.Extracting the proprietary binariesEach set of binaries comes as a self-extracting script in a compressed archive. After uncompressing each archive, run the included self-extracting script from the root of the source tree, confirm that you agree to the terms of the enclosed license agreement, binaries and their matching makefiles will get installed in the vendor/ hierarchy of the source tree.There's an additional step on Nexus S 4G. Build the signapk tool with$ make signapkThen reassemble the proprietary applicatons with$ vendor/samsung/crespo4g/reassemble-apks.shCleaning up when adding proprietary binariesIn order to make sure that the newly installed binaries are properly taken into account after being extracted, the existing output of any previous build needs to be deleted with$ make clobberPicking and building the configuration that matches a deviceThe steps to configure and build the Android Open-Source Project are described in the page about Building.The recommended builds for the various devices are available through the lunch menu, accessed when running the lunch command with no arguments:Device Branch Build configurationmaguro android-4.0.1_r1full_maguro-userdebugpanda master full_panda-engcrespo android-2.3.6_r1full_crespo-userdebugcrespo4g android-2.3.7_r1full_crespo4g-userdebugpassion android-2.3.6_r1full_passion-userdebugsapphire android-2.2.2_r1full_sapphire-userdebugdream android-2.2.2_r1full_dream-userdebugFlashing a deviceSet the device in fastboot mode if necessary (see above).Because user data is typically incompatible between builds of Android, it's typically better to delete it when flashing a new system.$ fastboot erase cache$ fastboot erase userdataAn entire Android system can be flashed in a single command: this writes the boot, recovery and system partitions together after verifying that the system being flashed is compatible with the installed bootloader and radio, and reboots the system.$ fastboot flashallOn maguro, panda, crespo, crespo4g, sapphire and dream (but not on passion), the commands above can be replaced with a single command$ fastboot -w flashallNexus S, Nexus S 4G and Galaxy Nexus Bootloader and Cell Radio compatibilityOn Nexus S, Nexus S 4G, and Galaxy Nexus, each version of Android has only been thoroughly tested with on specific version of the underlying bootloader and cell radio software. However, no compatibility issues are expected when running newer systems with bootloaders and radio images according to the following tables.Nexus S (worldwide version "XX"):Android Version Preferred Bootloader Preferred Radio Also possible2.3 (GRH55)I9020XXJK1I9020XXJK82.3.1 (GRH78)I9020XXJK1I9020XXJK82.3.2 (GRH78C)I9020XXJK1I9020XXJK82.3.3 (GRI40)I9020XXKA3I9020XXKB1All previous versions2.3.4 (GRJ22)I9020XXKA3I9020XXKD1All previous versions2.3.5 (GRJ90)I9020XXKA3I9020XXKF1All previous versions2.3.6 (GRK39F)I9020XXKA3I9020XXKF1All previous versionsNexus S (850MHz version "UC"):Android Version Preferred Bootloader Preferred Radio Also possible2.3.3 (GRI54)I9020XXKA3I9020UCKB22.3.4 (GRJ22)I9020XXKA3I9020UCKD1All previous versions2.3.5 (GRJ90)I9020XXKA3I9020UCKF1All previous versions2.3.6 (GRK39C)I9020XXKA3I9020UCKF1All previous versions2.3.6 (GRK39F)I9020XXKA3I9020UCKF1All previous versionsNexus S (Korea version "KR"):Android Version Preferred Bootloader Preferred Radio Also possible2.3.3 (GRI54)I9020XXKA3I9020KRKB32.3.4 (GRJ22)I9020XXKA3M200KRKC1All previous versions2.3.5 (GRJ90)I9020XXKA3M200KRKC1All previous versions2.3.5 (GRJ90)I9020XXKA3M200KRKC1All previous versionsAndroid Version Preferred Bootloader Preferred Radio Also possible2.3.6 (GRK39F)I9020XXKA3M200KRKC1All previous versionsNexus S 4G:Android Version Preferred Bootloader Preferred Radio Also possible2.3.4 (GRJ06D)D720SPRKC5D720SPRKC92.3.4 (GRJ22)D720SPRKC5D720SPRKD8All previous versions2.3.5 (GRJ90)D720SPRKC5D720SPRKE5All previous versions2.3.7 (GWK74)D720SPRKE1D720SPRKH1 (*)All previous versionsGalaxy Nexus (GSM/HSPA+):Android Version Preferred Bootloader Preferred Radio Also possible4.0.1 (ITL41D)PRIMEKJ10I9250XXKK1If you're building a new version of Android, if your Nexus S, Nexus S 4G or Galaxy Nexus has an older bootloader and radio image that is marked as being also possible in the table above but is not recognized by fastboot, you can locally delete the bootloader and version-baseband lines in device/samsung/crespo/board-info.txt or device/samsung/crespo4g/board-info.txt ordevice/samsung/maguro/board-info.txt(*) As a note, radio version D720SPRKH1 for Nexus S 4G sometimes erroneously reports version D720SPRKE1. If this is the case for your Nexus S 4G, you can locally modify the version-baseband line in device/samsung/crespo4g/board-info.txt accordingly.⼀. 环境准备。

在Ubuntu上为Android系统编写Linux内核驱动程序

在Ubuntu上为Android系统编写Linux内核驱动程序

在智能手机时代,每个品牌的手机都有自己的个性特点。

正是依靠这种与众不同的个性来吸引用户,营造品牌凝聚力和用户忠城度,典型的代表非iphone莫属了。

据统计,截止2011年5月,AppStore的应用软件数量达381062个,位居第一,而Android Market的应用软件数量达294738,紧随AppStore后面,并有望在8月份越过AppStore。

随着Android系统逐步扩大市场占有率,终端设备的多样性亟需更多的移动开发人员的参与。

据业内统计,Android研发人才缺口至少30万。

目前,对Android人才需求一类是偏向硬件驱动的Android人才需求,一类是偏向软件应用的Android人才需求。

总的来说,对有志于从事Android硬件驱动的开发工程师来说,现在是一个大展拳脚的机会。

那么,就让我们一起来看看如何为Android 系统编写内核驱动程序吧。

这里,我们不会为真实的硬件设备编写内核驱动程序。

为了方便描述为Android系统编写内核驱动程序的过程,我们使用一个虚拟的硬件设备,这个设备只有一个4字节的寄存器,它可读可写。

想起我们第一次学习程序语言时,都喜欢用“Hello, World”作为例子,这里,我们就把这个虚拟的设备命名为“hello”,而这个内核驱动程序也命名为hello驱动程序。

其实,Android内核驱动程序和一般Linux 内核驱动程序的编写方法是一样的,都是以Linux模块的形式实现的,具体可参考前面Android学习启动篇一文中提到的Linux Device Drivers一书。

不过,这里我们还是从Android系统的角度来描述Android内核驱动程序的编写和编译过程。

一. 参照前面两篇文章在Ubuntu上下载、编译和安装Android最新源代码和在Ubuntu上下载、编译和安装Android最新内核源代码(Linux Kernel)准备好Android内核驱动程序开发环境。

ubuntu下android源码编译修改遇到到问题及解决办法

ubuntu下android源码编译修改遇到到问题及解决办法
8. 源码中存放app到路径 out/target/product/generic/system/app
刷机时,该路径中到apk都会成为系统自带应用。
9. 错误: ./adb devices 提示???????????? no permissions
----解决办法:切换到root用户,使用adb kill-server, adb start-server 就可以了
build下的一个文件:
source build/envsetup.sh (前面要加上source,否则找不到mmm等命令)(不同的shell窗口都得运行该命令后才能使用mmm等命令)
b. 使用mmm命令来编译指定的模块,例如QuickSearchBox应用程序:
//注释 ~/Android/out/host/linux-x86/bin有我们要执行的emulator命令,而~/Android/out/target/product/generic是Android镜像存放目录,下面执行emulator命令时会用到。
emulator
adb -s emulator-5554 install -r ebook.apk
在真机上重新安装ebook.apk
adb -s HT9BYL904399 install -r ebook.apk
在emulator-5554模拟器上卸载ebook.apk(不保留数据和缓冲目录)
adb -s emulator-5554 uninstall net.blogjava.mobile.ebook
02-23 11:11:16.719: I/EasouSearch(2741): http get::8080/oss/upload/QuickSearchBox.apk

ubuntu下编译android源码错误解决记录

ubuntu下编译android源码错误解决记录

数据库系统管理制度数据库系统管理制度是指为了保障数据库系统的安全、稳定和高效运行,而制定的一系列规章制度和管理措施。

合理的数据库系统管理制度可以提高数据库系统的可靠性,保护数据的安全性,防止数据丢失和泄露,提高数据的完整性、一致性和可用性。

以下是数据库系统管理制度的一些要点:一、数据库系统管理的基本原则1.安全原则:确保数据库系统的安全,防止数据被非法拷贝、篡改或泄露。

2.稳定原则:保证数据库系统的稳定运行,防止系统故障和服务中断。

3.效率原则:提高数据库系统的运行效率,保证用户可以快速访问和处理数据。

4.合规原则:遵守相关法律法规和企业规定,保护用户隐私和敏感数据。

二、数据库系统管理的组织机构和职责1.数据库管理员(DBA)的职责:负责数据库系统的安装、配置、备份和恢复,监控系统性能,并对系统进行优化,管理用户的账号和权限,解决数据库系统相关的问题。

2.安全管理员的职责:负责数据库系统的安全策略和控制策略的制定和执行,制定用户权限管理规则,监控和审计数据库系统的访问和活动,检查和处理安全漏洞。

3.运维人员的职责:负责日常维护工作,包括系统巡检、性能监控、问题排查和解决,数据库备份和恢复等。

三、数据库系统管理的技术标准和流程1.数据库系统的选择和部署标准:根据业务需求和安全要求,选择合适的数据库系统,并根据标准化的部署流程进行安装和配置。

2.数据库系统的备份和恢复标准:制定定期备份数据库和日志的策略,保证数据不丢失,同时确保备份的可靠性和完整性。

3.数据库系统的安全管理标准:建立用户权限管理体系,对数据库用户进行分类和授权,限制用户的访问权限,定期修改密码,确保数据库系统的安全性。

4.数据库系统的性能管理标准:监控数据库系统的性能指标,定期进行性能优化,包括索引优化、SQL语句优化、硬件升级等,提高数据库系统的响应速度和并发能力。

5.数据库系统的故障处理标准:建立故障处理流程,监控系统运行状态,及时发现和解决故障,确保系统可用性。

在Ubuntu上下载、编译和安装Android最新内核源代码(Linux Kernel)

在Ubuntu上下载、编译和安装Android最新内核源代码(Linux Kernel)

在前一篇文章提到,从源代码树下载下来的最新Android源代码,是不包括内核代码的,也就是Android源代码工程默认不包含Linux Kernel代码,而是使用预先编译好的内核,也就是prebuilt/android-arm/kernel/kernel-qemu文件。

那么,如何才能DIY自己的内核呢?这篇文章一一道来。

一. 首选,参照前一篇在Ubuntu上下载、编译和安装Android最新源代码准备好Android源代码目录。

二. 下载Linux Kernel for Android源代码。

1. 使用GIT工具下载,执行以下命令:USER-NAME@MACHINE-NAME:~/Android$ mkdir kernelUSER-NAME@MACHINE-NAME:~/Android$ cd kernelUSER-NAME@MACHINE-NAME:~/Android/kernel$ git clonegit:///kernel/common.git同样是经过漫长的等待后,在kernel目录下有一个common目录,Linux内核代码就在这里了。

2. 下载完成后,可以查看下载的内核代码版本:USER-NAME@MACHINE-NAME:~/Android/kernel$ cd commonUSER-NAME@MACHINE-NAME:~/Android/kernel/common$ git branch android-2.6.363. 下载完Android的Linux内核代码后,会发现在arch/arm/configs下没有模拟器要使用的硬件配置文件goldfish_defconfig,而这个配置文件是编译内核代码时需要用到的,因此,需要checkout goldfish版本:USER-NAME@MACHINE-NAME:~/Android/kernel/common$ git branch -a * android-2.6.36remotes/origin/HEAD -> origin/android-2.6.36remotes/origin/android-2.6.35remotes/origin/android-2.6.36remotes/origin/archive/android-2.6.25remotes/origin/archive/android-2.6.27remotes/origin/archive/android-2.6.29remotes/origin/archive/android-2.6.32remotes/origin/archive/android-gldfish-2.6.29remotes/origin/archive/android-goldfish-2.6.27选择android-gldfish-2.6.29:USER-NAME@MACHINE-NAME:~/Android/kernel/common$ git checkoutremotes/origin/archive/android-gldfish-2.6.29下载完毕后,就能在arch/arm/configs下看到goldfish_defconfig这个文件了。

Ubuntu下编译Android源码全过程

Ubuntu下编译Android源码全过程

Ubuntu下编译Android源码全过程(转)源码, 编译, Ubuntu, Android一、获取Android源代码Git是LinuxTorvalds(Linux之父)为了帮助管理Linux内核开发而开发的一个开放源码的分布式版本控制软件,它不同于Subversion、CVS这样的集中式版本控制系统。

在集中式版本控制系统中只有一个仓库(Repository),许多个工作目录(WorkingCopy),而在Git这样的分布式版本控制系统中(其他主要的分布式版本控制系统还有BitKeeper、Mercurial、GNUArch、Bazaar、Darcs、SVK、Monotone等),每一个工作目录都包含一个完整仓库,它们支持离线工作,本地提交可以稍后提交到服务器上。

因为Android是由Kernel、Dalvik、Bionic、Prebuilt、build等多个项目组成,如果我们分别使用Git来逐个获取显得很麻烦,所以Android项目编写了一个名为Repo的Python 的脚本来统一管理这些项目的仓库,使得项目的获取更加简单。

在Ubuntu 8.04上安装Git只需要设定正确的更新源,然后使用apt-get就可以了,apt-get 是一条Linux命令,主要用于自动从互联网的软件仓库中搜索、安装、升级、卸载软件或操作系统。

apt-get命令一般需要root权限执行,所以一般跟着sudo命令。

sudo apt-get install git-core curl这条命令会从互联网的软件仓库中安装git-core和curl。

其中curl是一个利用URL语法在命令行方式下工作的文件传输工具,它支持很多协议,包括FTP、FTPS、HTTP、HTTPS、TELENT等,我们需要安装它从网络上获取Repo脚本文件。

curl/repo>~/bin/repo这句命令会下载repo脚本文件到当前主目录的/bin目录下,并保存在文件repo中。

ubuntu安装及android源码编译环境搭建

ubuntu安装及android源码编译环境搭建
(假设是64位系统)
a. sudo apt-get install git-core gnupg flex bison gperf build-essential \
zip curl zlib1g-dev libc6-dev lib32ncurses5-dev ia32-libs \
d. 编译完成
编译完成时,会在源码目录生成out文件夹,还有system.img等文件,如
Target system fs image: out/target/product/generic/obj/PACKAGING/systemimage_unopt_intermediates/system.img
通过这一步选择系统默认的jdk
这样,再在shell中输入代码:
java -version 时,就会显示系统使用的java是sun的java。
3. 搭建编译环境(可参考文档 /source/initializing.html)
update-alternatives --install /usr/bin/javac javac /home/yourname/JDK/jdk1.6.0_24/bin/javac 300
通过这一步将我们安装的jdk加入java选单。
然后执行代码:
update-alternatives --config java
假设安装位置总共有的大小为120G,则在其上建立三个分区:
a. swap 分区:swap格式,4G
b. /home 区:Ext3格式,73G
c. / 挂载区:Ext3格式,43G
3. 剩余步骤按照指引即可。
二、android源码编译环境搭建
(假设安装ubuntu的用户名是yourname)

Ubuntu下编译Android及安装

Ubuntu下编译Android及安装

Ubuntu环境下编译Android源码及安装本次实验环境为Ubuntu10.04、Android版本为2.1,采用的是ARM9 Mini6410开发板自带的Android源码。

其它版本尚未测试,不过原理类似。

第一步:准备JDK环境Android源码有部分是用Java编写的,所以编译Android源码前,必须安装Java类库,即JDK。

编译Android源码需要JDK1.5版(主要是需要其中的javadoc),1.6版是不兼容的。

JDK1.5已经停止支持,其最终的版本是JDK 5.0 Update 22安装JDK有两种方法(推荐第二种):方法一,自己下载jdk可从Sun官网上下载:/javase/downloads/5u22/jdk 选择平台Linux,勾选同意许可协议:单击Continue,在弹出的页面中一共有两个下载,选第一个jdk-1_5_0_22-lin ux-i586.bin下载:方法二,用apt-get命令首先,打开/etc/apt/sources.list文件,打开时注意,无论用vim还是gedit命令,都要在前面加上sudo,如sudo vim /etc/apt/sources.list,不然没法保存。

然后,将下面语句添加到文件末尾,注意空格deb /ubuntu/ jaunty multiversedeb /ubuntu/ jaunty-updates multiverse 最后,分别执行如下命令sudo apt-get updatesudo apt-get install sun-java5-jdk因为,要从网上下载安装包,所以时间可能比较长,请耐心等待。

安装过程中,会弹出一个许可证说明书,按Tab切换,选择Yes,等待安装完成即可。

第二步:安装编译所需的包分别执行一下命令(注意空格):sudo apt-get install git-core flex bison gperf libesd0-dev zipsudo apt-get install libwxgtk2.6-dev zlib1g-dev build-essential libstdc++6sudo apt-get install tofrodos x-dev libx11-dev libncurses5-dev第三步:编译源码首先,解压源码,本例中源码路径为/home/user/Android/android-2.1-fs-20100815.tar.gz ,切换到源码包目录执行sudo tar xzvf android-2.1-fs-20100815.tar.gz ,在当前目录会生成一个Android文件夹,里面存放着解压出来的所有源码。

Ubentu编译Android源码(AOSP)

Ubentu编译Android源码(AOSP)

Ubentu编译Android源码(AOSP)前⾔:⼀直想要编译⼀下Android 源码,之前去google 看,下载要下载repo。

当时很懵逼,repo 是个什么?(repo 是⼀个python 脚本,因为Android 源码git 仓库太多,帮助管理git 仓库的,你不需要知道⾥⾯什么实现。

会⽤就⾏。

)然后往下看,看到⽹上说,编译Android AOSP 只能⽤Ubuntu,当时⾃⼰的⼼也哇哇凉啊。

⾃⼰只有⼀个⼯作的电脑,⾃⼰的电脑配置太低。

看⽹上说,还要200G 的空间。

(有⼀个拦路虎)之前⾃⼰给⾃⼰的windos 安装过双系统,但是好像⼀直启动不了。

现在想想,应该是因为当时没有设置引导盘的顺序吧。

现在我⽤⼀个usb 连接了⼀个1T的硬盘,⾥⾯安装了Ubentu . 如果我插了这个硬盘,启动的就是ubuntu, 如果没有,就是⼯作的windows 。

⼯作学习两不误。

不知道什么动⼒让我突破了所有上⾯的拦路虎,依然决然去编译源码。

⾯试的时候,别⼈提到过,我说我想,但是没有做到,别⼈说,那么你为了编译源码,你第⼀步应该怎么做? 我说⾸先下载源码,安装Ubuntu。

终于⼀步⼀步⾛过来了。

感谢⾯试的那个⼈给我指点,让我思考。

⼀路⾛来,少些艰⾟。

下载代码⽤了两天,还是下载的清华镜像的,公司的⽹太慢了,43G 下载了两天,然后正好周末,编译成功花费了两天周末时间,但是还是很值得的。

⾥⾯有很多坑,给⼤家分享下。

下载AOSP:google 的AOSP 的话,因为FQ和数据量太⼤,考虑国内的镜像。

这个⽹址是清华⼤学的镜像站。

由于⾸次同步需要下载约 30GB 数据,过程中任何⽹络故障都可能造成同步失败,我们强烈建议您使⽤初始化包进⾏初始化。

也就是我们直接下载⼀个git仓库。

这样的话,不会说,⽂件太⼤,git clone 的时候⽼是中断。

下载下载完成后记得根据 checksum.txt 的内容校验⼀下。

当时我是⽤Windows 迅雷下载的⽂件。

Ubuntu下编译Android源码并运行Emulator 2

Ubuntu下编译Android源码并运行Emulator 2

Ubuntu下编译Android源码并运行Emulator 2//apt-get autoremove sun-java5-jdk//apt-get install nautilus-open-terminalandroid源码的编译安装虚拟机时建议设置空间为16G左右,否则后面编译源代码可能会导致空间不够编译环境:Ubuntu8.101、安装一些环境sudo apt-get install build-essential //sudo apt-get install makesudo apt-get install gccsudo apt-get install g++ //sudo apt-get install libc6-devsudo apt-get install patch //sudo apt-get install texinfo //sudo apt-get install libncurses-dev //sudo apt-get install git-core gnupg //sudo apt-get install flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl sudo apt-get install ncurses-devsudo apt-get install zlib1g-devsudo apt-get install valgrindsudo apt-get install python2.5安装java环境sudo apt-get install sun-java5-jdk不要用sun-java6-jdk,否则会有问题2、设置环境变量vim ~/.bashrc在.bashrc中新增或整合PA TH变量,如下#java 程序开发/运行的一些环境变量在home/你的用户名/.bashrc中加入下面一些,有些是后面运行编译后的模拟器而用的export JA VA_HOME=usr/lib/jvm/java-1.5.0-sunexport JRE_HOME=usr/lib/jvm/java-1.5.0-sun/jreexport PA TH=$PATH JA V A_HOME/binexport PA TH=$PATH:~/mydroid/out/host/linux-x86/binexport ANDROID_PRODUCT_OUT=~/mydroid/out/target/product/genericexport CLASSPATH=.{JA V A_HOME}/lib JRE_HOME/lib CLASSPATHexport JA VA_PATH=${JA V A_HOME}/bin{JRE_HOME}/binHOME_BIN=~/bin/export PA TH=${PATH}{JA V A_PA TH}{JRE_PATH}{HOME_BIN};3、安装repo(用来更新android源码)创建~/bin目录,用来存放repo程序,如下:$ cd ~$ mkdir bin注意:下载后的.repo也许并不在这个文件夹中,请返回上一级目录找到后拷贝至此下载repo脚本并使其可执行:$ curl /repo >~/bin/repo$ chmod a+x ~/bin/repo4、下载android源码并更新之$ mkdir mydroid$ cd mydroid方式一建议不要用repo来下载(android源码超过1G,非常慢),直接在网上下载http: ///bbs/pub/cupcake.tar.gz。

Ubuntu 10.04(64位)下载并编译 Android 2.2 源码

Ubuntu 10.04(64位)下载并编译 Android 2.2 源码

Ubuntu 10.04(64位)下载并编译Android 2.2 源码[只有11条命令]为了方便,我把所有操作写成了命令,按顺序(软件安装--源码下载--编译)执行成功即可:1. 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 ia32-libs x11proto-core-devlibx11-dev lib32readline5-dev lib32z-dev java-common unixodbc2. sudo apt-get install sun-java6-jdk3. cd4. mkdir -p software/bin5. curl /repo >software/bin/repo6. chmod a+x software/bin/repo7. mkdir -p software/android/src/new8. cd software/android/src/new9. repo init -u git:///platform/manifest.git -b froyo10. repo sync11. make -j4=========================================================== ======================================================== 1.前言本文叙述了如何从零开始搭建基于Google官方Android 2.2.1(froyo)源码的开发环境,包括如何下载源代码、编译源代码,以及在模拟器中运行编译生成的镜像。

文中开发机是基于Ubuntu 10.04的,同样适用于其他版本的Ubuntu。

Ubuntu下编译Android源码并运行Emulator2

Ubuntu下编译Android源码并运行Emulator2

Ubuntu下编译Android源码并运行Emulator2Ubuntu下编译Android源码并运行Emulator2在Ubuntu上编译和运行Android源码并运行Emulator需要一些准备工作和步骤,下面是详细的步骤说明。

准备工作:1.安装必要的依赖项:- Java Development Kit (JDK): 通过运行`sudo apt-get install openjdk-8-jdk`命令安装Java开发工具包。

- Git: 运行`sudo apt-get install git`命令安装Git。

- 必要的库和工具: 运行`sudo apt-get install libx11-dev libxext-dev libxi-dev libxrender-dev libxtst-dev libxt-dev libcups2-dev libncurses5-dev libgnome2-0 libgnomeui-0 libgtk2.0-0 libatk1.0-0 libbonoboui2-0 libcairo2 libfontconfig1-devlibxslt-dev libxml2-dev libcurl4-openssl-dev libusb-1.0-0-dev libgtk2.0-bin libdbus-1-dev libdbus-glib-1-dev libgconf2-dev libnss3-dev automake libtool pkg-config`命令安装必要的库和工具。

2. 安装Repo及相关工具:编译源码:1. 初始化环境:运行`. build/envsetup.sh`命令初始化环境。

2. 选择目标设备:运行`lunch`命令选择目标设备,例如选择"2.修改设备名-eng"即选择修改设备名为eng类型的目标设备。

3. 编译源码:运行`make -j4`命令开始编译源码,-j4参数可以指定并行编译的线程数,可以根据系统配置适当调整。

Android系统开发编译及系统移植

Android系统开发编译及系统移植

Android系统开发编译环境配置主机系统:Ubuntu9.04(1)安装如下软件包sudo apt-get install git-coresudo apt-get install gnupgsudo apt-get install sun-java5-jdksudo apt-get install flexsudo apt-get install bisonsudo apt-get install gperfsudo apt-get install libsdl-devsudo apt-get install libesd0-devsudo apt-get install build-essentialsudo apt-get install zipsudo apt-get install curlsudo apt-get install libncurses5-devsudo apt-get install zlib1g-devandroid编译对java的需求只支持jdk5.0低版本,jdk5.0 update 12版本和java 6不支持。

(2)下载repo工具curl /repo >/bin/repochmod a+x /bin/repo(3)创建源代码下载目录:mkdir /work/android-froyo-r2(4)用repo工具初始化一个版本(以android2.2r2为例)cd /work/android-froyo-r2repo init -u git:///platform/manifest.git -b froyo初始化过程中会显示相关的版本的TAG信息,同时会提示你输入用户名和邮箱地址,以上面的方式初始化的是android2.2 froyo的最新版本,android2.2本身也会有很多个版本,这可以从TAG信息中看出来,当前froyo的所有版本如下:* [new tag] android-2.2.1_r1 -> android-2.2.1_r1* [new tag] android-2.2_r1 -> android-2.2_r1* [new tag] android-2.2_r1.1 -> android-2.2_r1.1* [new tag] android-2.2_r1.2 -> android-2.2_r1.2* [new tag] android-2.2_r1.3 -> android-2.2_r1.3* [new tag] android-cts-2.2_r1 -> android-cts-2.2_r1* [new tag] android-cts-2.2_r2 -> android-cts-2.2_r2* [new tag] android-cts-2.2_r3 -> android-cts-2.2_r3这样每次下载的都是最新的版本,当然我们也可以根据TAG信息下载某一特定的版本如下:repo init -u git:///platform/manifest.git -b android-cts-2.2_r3(5)下载代码repo syncfroyo版本的代码大小超过2G,漫长的下载过程。

在Ubuntu上编译android

在Ubuntu上编译android

在Ubuntu7.10上编译android1 概述上个星期看到android开放源代码的消息,虽然觉得Google的这个动作会对业界产生很大影响,但没有时间仔细看,只浏览了Project layout。

今天上午一个网友在mail中说已经编译、运行过android。

我趁着中午休息时间,在一个Ubuntu7.10的虚拟机上编译、运行了一下。

我在这个虚拟机上编译过openmoko、poky。

相对于这两个使用OpenEmbedded的平台,android的编译要简单一些,快一些。

我在编译openmoko和poky时,将所有下载包都保存在一个目录中,将编译目录的sources子目录指向这个目录。

这样做,一方面即使以后有些链接失效,也还可以编起来(其实编译时都不需要连接外网);另一方面在重新编译时,不用重新下载,可以加快编译速度。

即使这样,完全编译一次poky也要一个晚上。

编译android时,下载用了1个小时,编译也只需要1个小时。

2 编译中的两个小问题2.1 python和JDKGoogle网站对编译过程的介绍还是很清晰的。

不过在介绍其它软件包时,都给出了apt-get命令,却单独给出了python和JDK的链接地址,容易对读者产生误导,以为要手工安装这两个软件。

其实这两个软件也应该通过apt-get安装。

特别是python,如果从源代码安装,可能因为依赖其它软件,导致一些组件编译失败,影响android的编译。

而且python 2.6的源代码包没有提供make uninstall,卸载也比较麻烦。

其实我们只需要一个apt-get命令,就可以安装所有依赖的软件。

2.2 "fatal: git 1.5.4 or later required"在Ubuntu7.10上执行repo init时,会出现"fatal: git 1.5.4 or later required"的错误提示。

Ubuntu18041编译Android60源码

Ubuntu18041编译Android60源码

Ubuntu18041编译Android60源码编译Android 6.0源码需要首先准备好编译环境,如下所示:2. 安装必要的软件包:打开终端,执行以下命令安装编译 Android 所需的软件包:```sudo apt-get updatesudo 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``````mkdir androidcd androidrepo sync```4. 配置环境变量:打开 `~/.bashrc` 文件,在文件末尾添加以下内容,并保存文件:```export PATH=/path/to/android/sdk/platform-tools:/path/to/android/sdk/tools:$PATHexport JAVA_HOME=/path/to/java/jdk```请替换 `/path/to/android/sdk` 和 `/path/to/java/jdk` 为实际的 Android SDK 和 Java JDK 的路径。

5. 启动编译过程:在终端中进入工作目录,执行以下命令开始编译Android:```. build/envsetup.shlunch```选择相应的设备类型,并继续执行以下命令:```make -j4```其中,`-j4`参数表示使用4个核心并行编译。

根据系统配置的不同,您可以调整此参数。

编译过程可能需要数小时,具体时间取决于计算机性能。

Android源码编译环境的搭建

Android源码编译环境的搭建

Android源码编译环境的搭建1. 下载Android源码 + ubuntu9.10 --源码的下载和ubuntu的安装⽹上介绍很多,这⾥就不多讲解了2. 安装编译组件a. sudo apt-get install bisonb. sudo apt-get install vimc. 解决:安装JDK 5.01):根据官⽅⽂档⾥所说,源代码的编译必须使⽤JDK5才能编译的了,所以这⾥我们使⽤jdk5 2): 需要先更新源,在终端⾥执⾏ sudo vim /etc/apt/sources.list3): 在source.list⾥把以下2⾏拷贝到⽂档最后⾯:deb jaunty multiversedeb jaunty-updates multiverse保存退出。

4): 执⾏ sudo apt-get update 更新源.5): 配置编译环境并下载JDK5:sudo apt-get install sun-java5-jdkd. sudo apt-get install build-essentiale. sudo apt-get install zlib1g-devf. sudo apt-get install flexg. sudo apt-get install libncurses-devh. sudo apt-get install libx11-devi. sudo apt-get install gperf3. 设置环境变量vi ~/.bashrc#java 程序开发/运⾏的⼀些环境变量JAVA_HOME=/usr/lib/jvm/java-1.5.0-sunJRE_HOME=${JAVA_HOME}/jreexport ANDROID_JAVA_HOME=$JAVA_HOMEexport CLASSPATH=.:${JAVA_HOME}/lib:$JRE_HOME/lib:$CLASSPATHexport JAVA_PATH=${JAVA_HOME}/bin:${JRE_HOME}/binexport JAVA_HOME;export JRE_HOME;export CLASSPATH;HOME_BIN=~/bin/export PATH=${PATH}:${JAVA_PATH}:${HOME_BIN};#java 程序开发/运⾏的⼀些环境变量export ANDROID_PRODUCT_OUT=$androiddir/out/target/product/genericANDROID_PRODUCT_OUT_BIN=$androiddir/out/host/linux-x86/binexport PATH=${PATH}:${ANDROID_PRODUCT_OUT_BIN}:${ANDROID_PRODUCT_OUT};保存退出,然后执⾏source ~/.bashrc同步源注意$androiddir是你android源码的⽬录4. 编译源码在源码⼯程⽬录Make,耐性等待5. 启动等待源码编译成功后,在源码⽬录执⾏下⾯的命令,初始化环境变量. build/envsetup.sh //注意输完envsetup.sh后需要按Tab下执⾏ emulator & ,如果正确弹出模拟器窗⼝,恭喜你,成功了!。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

环境Linux 版本:Ubuntu 11.04 (可由10.10的版本进行升级)64位系统GCC版本:gcc version 4.5.2Java版本:java version "1.6.0_26"下载android源码前注意:1、保证Ubuntu系统中的容量在80G左右,以保证足够的空间来存放android源码以及编译后的相关文件。

2、保证Ubuntu系统进行Internet访问。

联网方法:采用拨号进行连接。

相关操作步骤如下所示:1、虚拟机→设置→硬件→网络适配器→网络连接→桥接2、启动Ubuntu系统,打开终端(在普通用户下),输入相关命令如下:$ pppoeconf //打开后输入上网账号跟密码,确认保存$ sudo pon dsl-provider //上网连接命令经过这两个步骤后就可以进行上网了。

Android源码编译所依赖的tools01.$ sudo apt-get update02.$ sudo apt-get -y install git-core03.$ sudo apt-get -y install gnupg04.$ sudo apt-get -y install sun-java6-jdk flex05.$ sudo apt-get -y install bison06.$ sudo apt-get -y install gperf07.$ sudo apt-get -y install libsdl-dev08.$ sudo apt-get -y install libesd0-dev09.$ sudo apt-get -y install libwxgtk2.6-dev10.$ sudo apt-get -y install build-essential11.$ sudo apt-get -y install zip12.$ sudo apt-get -y install curl13.$ sudo apt-get -y install libncurses5-dev14.$ sudo apt-get -y install zlib1g-dev15.$ sudo apt-get -y install valgrind注意:(如果是32bit的系统的话,则要更改几个Android.mk文件)01./external/clearsilver/cgi/Android.mk02./external/clearsilver/java-jni/Android.mk03./external/clearsilver/util/Android.mk04./external/clearsilver/cs/Android.mk用gedit打开,修改m64为m32即可另外将build/core/main.mk中的ifneq (64,$(findstring 64,$(build_arch)))修改为:ifneq (i686,$(findstring i686,$(build_arch)))对于32位系统所出现的问题,解决方法:Error1:make: ***[out/host/linux-x86/obj/STATIC_LIBRARIES/libutils_intermediates/RefBase.o] error 1在terminal中输入$ gedit frameworks/base/libs/utils/Android.mk将LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS)修改为:LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS) –fpermissiveError2:make: *** [out/host/linux-x86/obj/EXECUTABLES/obbtool_intermediates/Main.o] error 1此处编译错误是由于ubuntu 11.10采用了GCC4.6.1导致的修改源码目录下/build/core/combo/HOST_linux-x86.mk并将以下语句:HOST_GLOBAL_CFLAGS+= -D_FORTIFY_SOURCE=0修改为:HOST_GLOBAL_CFLAGS+= -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0Android源码下载1、安装repo安装过程步骤如下所示:Repo下载安装1、$ mkdir ~/bin //在home目录下创建bin文件夹2、$ PATH=~/bin:$PA TH //环境变量设置3、$ curl https:///dl/googlesource/git-repo/repo > ~/bin/repo //repo下载4、$ chmod a+x ~/bin/repo //权限设置,保证repo可执行Repo client初始化1、$ mkdir Android //创建Android目录,用于存放下载的android源码2、$ cd Android //进入到Android目录3、$ repo init -u https:///platform/manifest //指定URL清单,指定包含在Android源代码的各种存储库将被安置在工作目录中当然也可以指定android版本,使用如下命令:$ repo init -u https:///platform/manifest -b android-4.0.1_r1Android源码文件获取$ repo sync注意:在Android源码下载过程中凡出现问题,可以进入Android源码下载的相关官方网站/source/downloading.html 进行查看。

Android源码编译环境初始化1、$ source build/envsetup.shOR$ . build/envsetup.sh2、$ lunch full-eng //选择编译目标Code编译$ make -j4 //其中j4表示同时启动4个线程任务进行编译,可以直接使用make,这样就是最大程度使用线程数来进行编译总结:到这里为止,android源码完成了编译过程,编译后,会在源码目录下的/out/target/product/generic/有三个镜像文件生成,分别是system.img、userdata.img以及ramdisk.img 。

注意:1、如果编译过程没有出问题,但是在/out/target/product/generic/下3个镜像文件不全,可以再次进行一次命令make,就可以解决问题了。

2、如果是编译过程中出现错误,一般导致的原因是因为缺少了相关编译环境,可以根据提示进行安装,安装后,重新进行编译。

Windows XP下使用Android模拟器运行所编译好的文件。

原理:将Android模拟器下所加载的system.img替换成编译后的system.img即可。

1、将编译好的system.img从Ubuntu中拷贝出来方法:1)先拷贝到U盘或者移动硬盘中,再从U盘或移动硬盘拷贝到Windows XP硬盘下;2)先进行Windows XP跟Ubuntu文件夹共享,这样就可以将system.img拷贝到共享文件夹中;3)传FTP,从FTP上进行下载;4)在Ubuntu中上网将system.img作为附件进行邮件发送,然后从Windows XP下进行下载。

2、将拷贝出来的system.img文件放置到Android模拟器下的对于文件夹中,如果Android是4.0以上的版本的话,一般是在system-imges文件夹中。

C:\Program Files\Android\android-sdk\system-images\android-15\armeabi-v7a3、启动模拟器就可以运行了。

注意:创建Android虚拟机的时候,Android版本应该跟Ubuntu下编译好的Android版本要保持一致,否则有可能替换system.img后,Android系统无法正常启动,或者无法进入Android 启动界面。

Android源码修改并进行编译下面以2个实例来进行说明,实例1目的是实现Android系统永不休眠,实例2是实现Android系统启动后,不自动进入锁屏界面。

实例1:实现Android系统永不休眠其实很简单,只需要对源码下的配置文件XML下的参数进行修改即可。

步骤如下:1、$ cd frameworks/base/packages/SettingsProvider/res/values //在下载的Android源码目录下输入此命令,进入到values目录下2、$ gedit defaults.xml //使用文本编辑器打开defaults.xml文件3、将<integer name="def_screen_off_timeout">60000</integer>改为<integer name="def_screen_off_timeout">-1</integer>保存后退出//其中60000单位是ms,表示60s,就是说60s屏幕会进行休眠状态,改为-1后,不再进入休眠4、$ cd ../../../../../../ //返回到源码目录下5、$ source ./build/envsetup.sh //环境初始化6、$ mmm frameworks/base/packages/SettingsProvider/ //对SettingsProvider模块进行编译7、$ make snod //重新打包system.img到这里,模拟编译就完成了,查看效果的话,直接将Android模拟器下的system.img替换掉启动运行即可。

注意:mmm命令可以对模块进行编译,后面必须接上模块所在目录,查看某目录是否为一模块,就看当前目录下是否有Android.mk文件,如果有的话,就是模块。

除了可以使用mmm 进行编译的话,还可以使用mm,但是mm是在当前目录下实行编译的,也就是模块目录下使用此命令。

实例2:实现Android启动后不进入锁屏状态。

修改KeyguardViewMediator.java文件下的变量,将其赋值改为false即可。

步骤如下:1、$ cd frameworks/base/policy/src/com/android/internal/policy/impl/ //在下载的Android 源码目录下输入此命令,进入到impl目录下2、$ gedit KeyguardViewMediator.java //是用文本编辑器打开java文件3、将private boolean mExternallyEnabled = true;代码中的true改为false,保存退出4、$ cd ../../../../../../ ../../../ //返回到源码目录下5、$ source ./build/envsetup.sh //环境初始化6、$ mmm frameworks/base/policy/ //对policy模块进行编译7、$ make snod //重新打包system.img注意:如果在进行模块代码编译了,报出少了一个odex后缀名的文件的错误时,总结了下,导致报错的原因可能是Android版本的差异,不过没事,即使模块编译通不过,还是可以对整个源码进行编译的(直接在源码目录下执行make命令即可),只是时间会相对较长,同样会将修改的模块整合到system.img文件中。

相关文档
最新文档