Compiling Android

From iDroid Project

Revision as of 21:24, 15 July 2022 by Bionicman08 (Talk | contribs)
Jump to: navigation, search

Contents

Open-Source Licenses

The iDroid Project is an Open-Source Project. Android is under Apache License, version 2.0. As such, changes to the source code must be made public.

If you plan to compile Android with your own changes to the source code, please make your changes public. What you have changed may be helpful for the iDroid Project and for helping in troubleshooting.

Android requires a 64-bit system to build Android Gingerbread (version 2.3, which the iDroid Project uses).

Linux Systems

Ubuntu

The following instructions are for Ubuntu based systems.

Gingerbread requires the Java 6 JDK. Unfortunately, this is not in Ubuntu's default repos so you should add the repo through the following Terminal commands (open a Terminal):

sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
sudo add-apt-repository "deb-src http://archive.canonical.com/ubuntu lucid partner"
sudo apt-get update

Enter your password when prompted. The instructions for what packages to install will be later along this guide.

Linux Mint 10 & 11

Special thanks to Bionicman08 for the Linux Mint guide.

These instructions are NOT for the Debian based version of Mint. Do not attempt this on the Debian-based version of Mint unless you want to risk major problems or unless you are clinically insane, by that I mean that you wake up in the morning thinking that you are a turnip.

The first thing to do is to update your apt-cache, in Terminal:

sudo apt-get update

Now you need to update your system using the Update Manager and not sudo apt-get upgrade (Note: apt-get upgrade WILL cause issues with your system)

x86_64

If you are using a 64-bit system (either Ubuntu or Mint), open a Terminal and enter:

sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl sun-java6-jdk zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev ia32-libs x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev

You will need to accept the Java license.

i386/i686

Building Gingerbread is not supported on a 32-bit system. But if you insist on using an x86/32-bit system (either Ubuntu or Mint), open a Terminal and enter:

sudo apt-get install git-core gnupg sun-java6-jdk flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev

You will need to accept the Java license. How to get Gingerbread to compile on a 32-bit system is not covered in this guide.

VirtualBox

If you are running Linux within a guest session in VirtualBox then for Ubuntu it is recommended that you follow this, if on Linux Mint it is essential that you do.

  1. Install the guest Additions
  2. Shutdown the guest OS
  3. Make note of the number of enabled CPU's for the guest and adjust to how you want. (using all available will speed up the compiling process)
  4. Boot the Linux guest

OS X

To build the Android files in a Mac OS environment, you need an Intel/x86 machine running MacOS 10.4 (Tiger) 10.5 (Leopard), or 10.6 (Snow Leopard). The Android build system and tools do not support the obsolete PowerPC architecture.

Creating a Case-Sensitive File System

Android must be built on a case-sensitive file system. The Android Open-Source Project recommends that you build Android on a partition that has been formatted with the Case-sensitive Journaled HFS+ file system:

  • A case-sensitive file system is required because the sources contain files that differ only in case.
  • Journaled systems are more robust. (This is optional, but recommended.)
  • HFS+ is required to successfully build Mac OS applications such as the Android Emulator for OS X.

If you want to avoid partitioning/formatting your hard drive, you can use a case-sensitive disk image instead (easier). To create the image:

  1. In OS X, launch /Applications/Utilities/Disk Utility
  2. Select "New Image"
  3. Size: 15 GB (this will work, but you can choose more if you want to, iDroid will require more than 10GB when built)
  4. Volume format: case sensitive, journaled

This will create a .dmg file which, once mounted, acts as a drive with the required formatting for Android development. For a disk image named android.dmg (or whatever you named it) stored in your home directory, you can add the following to your ~/.bash_profile to mount the image when you execute mountAndroid:

# command to mount the android file image 
function 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.

Set-up the Development Environment

  1. Install XCode version 3.0 or newer from http://developer.apple.com. You must sign-in or register a new account. 'There is a problem with version 4.0 (no 10.5 SDK), please bear with us and wait for a fix.
  2. Set an appropriate per-process file descriptor limit. To do this, add the following lines to your .bash_profile file:
    # set the number of open files to be 1024
    $ ulimit -S -n 1024
    Note that this may not be necessary; on some systems, the output of ulimit -S will show unlimited. In this case, there is no need to set the limit to 1024.
  3. You may then choose to complete the rest of the set-up using Homebrew or MacPorts.

Homebrew

  1. Install Homebrew if you haven't by entering the following command in a Terminal:
    ruby -e "$(curl -fsSLk https://gist.github.com/raw/323731/install_homebrew.rb)"
  2. After Homebrew has been downloaded and installed, enter the following command in Terminal:
    sudo brew install sdl gmake git gnupg

MacPorts

  1. Install MacPorts if you haven't:
    1. Download and run the installer from http://www.macports.org/install.php
    2. Make sure that /opt/local/bin is in your path before /usr/bin by running:
      $ echo $PATH
    3. If you don't see /opt/local/bin, edit $HOME/.bash_profile and add the line export PATH=/opt/local/bin:$PATH after any other PATH-related lines. To verify that your path is now correct, open a new terminal and run echo $PATH again.
  2. Get the following packages from port:
    $ POSIXLY_CORRECT=1 sudo port install gmake libsdl git-core gnupg
  3. If using Mac OS 10.4, also install:
    $ POSIXLY_CORRECT=1 sudo port install bison 
  4. You must use gmake 3.81 but Macports will install 3.82 (which will not work). To install gmake 3.81:
    1. Visit http://trac.macports.org/log/trunk/dports/devel/gmake
    2. Click the link that says "@50980" - although it doesn't explicitly say 3.81, this is it
    3. Click the link that says "Portfile"
    4. Scroll to the bottom and just below "Download in other formats:" click "Original Format"
    5. This is subtle but important: If your browser e.g. Chrome renamed it to Portfile.txt, you need to rename it to simply "Portfile"
    6. In Terminal cd to the location of Portfile and enter the following commands:
      sudo port install
    7. This should install and configure gmake 3.81, after which:
      sudo port installed gmake
    8. The versions of gmake are listed and noted which is active. If 3.81 is active, proceed to the next section, otherwise enter these commands in Terminal:
      sudo port deactivate gmake@3.82_0
      sudo port activate gmake@3.81_0

Installing the Android Repo Tool (all platforms)

Open a Terminal:

cd ~
mkdir bin
curl http://android.git.kernel.org/repo >~/bin/repo
chmod a+x ~/bin/repo

Downloading and Building iDroid

This procedure will download the source from all of the required repositories and then compile them. It would be a good idea to look through the information listed above to prepare your machine before continuing.

Open a Terminal. If you are in OSX, mount android.dmg (or whatever you called it) and in Terminal cd to /Volumes/Android (or whatever you named it).

mkdir pepparkaka 
cd pepparkaka
repo init -u git://github.com/iDroid-Project/platform_manifest.git -b gingerbread
repo sync

If the repo tool is not in your PATH, you will need to use 'repo-dir-path/repo' above instead of 'repo'. Wait for everything to sync (depends on your internet connection) then after repo sync is done:

. build/envsetup.sh && lunch

Choose which device you'd like to build for, enter the number for that device and press enter.

If you are using a 32-bit system, you must make some modifications to be able to build Gingerbread and are advised to skip the next part unless patches have been applied. 64-bit users proceed and enter this command:

make -j2
(-j = num of compile processes, 2 per core, j2 for single core, j4 for dual-core, j8 for quad-core)

VirtualBox users enter the number corresponding with the number of CPU's enabled

Wait for everything to compile and there you go. The compiled system.img will be in pepparkaka/out/target/product/***device***/system.img (Substitute ***device*** with iPhone2G, iPhone3G, or iPodTouch1G depending on what device you were planning to build it for).

References