[Galaxy Ace S5830 General] CallMeVentus:
Hello everyone yet again :p

Info: This also works for CM7 , just that the Cooper repo is already natively included in the files and folders , so you can skip step 2.5

I'm creating a new thread for all those people

who know a little bit of code but don't know what to do to compile for Galaxy Ace

(AOSP or CM7).

THANKS TO http://source.android.com and http://wiki.cyanogenmod.com

32-bit computers are not recommended to compile Gingerbread and above versions!

For now, I'll cover AOSP. (I'll show a CM7 guide once I learn how to compile it)

Alright, to compile Gingerbread AOSP you'll need a computer that has:

-At least an Intel Core i3 at 2.4Ghz or a similar AMD processor

-4GB RAM (my RAM speeds are at 1333Mhz). If lesser RAM, then swap is needed (for 2GB RAM use 15GB swap, that what I used before)

-40GB Partition for single compilation or 80GB for multiple versions (NOT including Ubuntu installation)

-Ubuntu 10.04 LTS OR Mac OSX 10.6 (other versions of Ubuntu, including 09.10 or lower or 10.10 or higher, may not work as well as 10.04)(

Same thing goes for Snow Leopard, Lion has certain problems

)

Here's how to compile for Gingerbread:

Step 1: Setting up the build environment.

Linux:

In general you will need:

-Python 2.4 - 2.7

-JDK 6 if you wish to build Gingerbread or newer; JDK 5 for Froyo or older.

-Git 1.7 or newer.

To install Sun JDK 6 do the following:

$ sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
$ sudo apt-get update
$ sudo apt-get install sun-java6-jdk

You will also need to install certain packages:

For 64-bit computers:

$ 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 \
libxml2-utils

For 32-bit computers (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-utils

(***NOTE: I've gotten errors when trying to apt-get install lib32ncurses5-dev.)

IF you're on Ubuntu 11.10 you might need to do this:

$ sudo ln -s /usr/lib/i386-linux-gnu/libX11.so.6 /usr/lib/i386-linux-gnu/libX11.so

Now for OSX (taken from http://source.android.com):

To 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 build Mac OS applications such as the Android Emulator for OSX.

If 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-proof. Using sp**** 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 with this:

# hdiutil create -type SP**** -fs 'Case-sensitive Journaled HFS+' -size Xg ~/android.dmg

Where "X" is how big your image will be (in GB).

This will create a .dmg (or possibly a .dmg.sp****file) 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 to your ~/.bash_profile to mount the image when you execute "mountAndroid":

# 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.

Installing required packages:

-Install

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.

-MacPorts from http://macports.org

Note: Make sure that /opt/local/bin appears in your path BEFORE /usr/bin. If not, add:

export PATH=/opt/local/bin:$PATH

to your ~/.bash_profile.

-Get make, git, and GPG packages from MacPorts:

$ POSIXLY_CORRECT=1 sudo port install gmake libsdl git-core gnupg

If you're on MacOS 10.4, install bison too:

$ POSIXLY_CORRECT=1 sudo port install bison

Bugs and fixes:

-Reverting from gmake3.82:

There 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 says:

file:///Users/Shared/dports

above the rsync line. Then make this directory:

$ mkdir /Users/Shared/dports

-In the new dports directory, run:

$ svn co --revision 50980 http://svn.macports.org/repository/macports/trunk/dports/devel/gmake/ devel/gmake/

-Create a port index for your new local repository:

$ portindex /Users/Shared/dports

-Finally, install the old version of gmake with:

$ sudo port install gmake @3.81

-Setting a file descriptor limit:

On 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 1024
ulimit -S -n 1024

Your Linux/MacOS build environment is now complete, moving on to downloading....

Step 2: Downloading the source

You'll need to use repo to download sources from repositories.

Here's how I did it:

-

Make a /bin directory in your home directory and it must be in your PATH

:

$ mkdir ~/bin
$ PATH=~/bin:$PATH

-Download the Repo script and ensure that it can be executed:

$ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
$ chmod a+x ~/bin/repo

Now that downloading repo is done and executable, we need to initialise it.

Create an empty directory for where all your Android files will be downloaded, stored and made:

$ mkdir WORKING_DIRECTORY
$ cd WORKING_DIRECTORY

Where WORKING_DIRECTORY can be any name you want (as long as it has no spaces)

Use repo init to grab the latest branch (or rather, the gingerbread branch)

$ repo init -u https://android.googlesource.com/platform/manifest -b android-x.x.x_r1

Where "x" can be

2.3, 2.3.1, 2.3.2, 2.3.3, 2.3.4, 2.3.5, 2.3.6 or 2.3.7

.

For now use the versions that the Galaxy Ace currently has (2.3.3-2.3.5 and 2.3.7)

Optional step:

Once you're done with that, you'll need to download them.

This simple 8-character command is easy to execute but it'll be hard on your internet connection:

$ repo sync

Ensure that you have at least 5Mbps of internet if you want it completed in a day.

Once you're done syncing, use this code:

$ gpg --import

To sign what you've downloaded.

Once you entered that, copy and paste this long line of ****:

-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.2.2 (GNU/Linux)

mQGiBEnnWD4RBACt9/h4v9xnnGDou13y3dvOx6/t43LPPIxeJ8eX9WB+8LLuROSV
lFhpHawsVAcFlmi7f7jd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JPWsB/M
pK+KMs/s3r6nJrnYLTfdZhtmQXimpoDMJg1zxmL8UfNUKiQZ6esoAWtDgpqt7Y7s
KZ8laHRARonte394hidZzM5nb6hQvpPjt2OlPRsyqVxw4c/KsjADtAuKW9/d8phb
N8bTyOJo856qg4oOEzKG9eeF7oaZTYBy33BTL0408sEBxiMior6b8LrZrAhkqDjA
vUXRwm/fFKgpsOysxC6xi553CxBUCH2omNV6Ka1LNMwzSp9ILz8jEGqmUtkBszwo
G1S8fXgE0Lq3cdDM/GJ4QXP/p6LiwNF99faDMTV3+2SAOGvytOX6KjKVzKOSsfJQ
hN0DlsIw8hqJc0WISQQYEQIACQUCSedYRAIbDAAKCRDorT+BmrEOeCUOAJ9qmR0l
EXzeoxcdoafxqf6gZlJZlACgkWF7wi2YLW3Oa+jv2QSTlrx4KLM=
=Wi5D
-----END PGP PUBLIC KEY BLOCK-----

Paste it into your terminal and press Ctrl+D.

You now have a complete local copy of the Android codebase.

Step 2.5: Include the Samsung COOPER source for compilation (AOSP only)

Yes, this has to be done so you can compile for cooper (Samsung Galaxy Ace).

-Navigate the terminal to the ~/WORKING_DIRECTORY/device/samsung folder:

$ cd ~/WORKING_DIRECTORY/device/samsung

Where WORKING_DIRECTORY = your android folder

-Make use of git to clone a folder from PabloPL's GitHub:

$ git clone git://github.com/PabloPL/android_device_samsung_cooper

Once it's done, you should see a folder with that name in the root of your working directory. Rename it to "cooper" and cut & paste it to device/samsung.

Download the Android SDK Tools and make sure you set ADB correctly to be in your PATH.

For more info and how-to steps go here: http://www.lineardroid.co.uk/2010/04/how-to-set-up-adb-in-ubuntu/

Once you're done setting up ADB, go to the cooper folder and run extract-files.sh in the terminal.

ADB should pull some files from your device and automatically close the terminal. (You might need to be in CM7 for ADB to successfully pull all libs, I may be wrong though. Someone test it and tell me if it works)

Now we're done for now.

Oh yes, before I forget:

Have a copy of CM7 before you build!

AOSP does not fully support ARMv6 devices and therefore uneeded errors may arise, so the CM7 files can save you.

Step 3: Building Android (most exciting/boring part)

Initialize the environment with the envsetup.sh script.

$ . build/envsetup.sh

Choose your target to build with lunch.

$ lunch cooper-eng

(***NOTE: Change full_base.mk in device_cooper.mk to full.mk) (AOSP only)

(***NOTE2: There'll be another error about an unknown architecture: ARMv6-VFP. That's where your CM7 files come in handy.) (AOSP only)

Build 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 machine (2 CPUs, 4 cores per CPU, 2 threads per core), the fastest builds are made with commands between make -j16 and make -j32.

I usually use this (thanks to cdesai):

$ make -j8 update-api
$ make -j8 otapackage

OR:

$ make -j16 update-api
$ make -j16 otapackage

Do have patience because your computer will get inevitably laggy.

Once you're done debugging all errors and stuff you will have a flashable .zip located in WORKING_DIRECTORY/out/target/cooper.

Thanks for reading this whole chunk, though I know it's an XDA App eyesore.

If you do encounter errors feel free to ask here :)