[XPERIA X10 Android Development] Perceval from Hyrule:
Hello all,

if you are like me, you love to do things by yourself and see how it works. In this thread I'll show you how to create your Linux environment in order to create and compile your own roms - any version (1.5, 2.3, etc etc). I had soooooo many problems to make it work, so here is THE thread :)

BE CAREFUL : this thread is ONLY to set up the OS. The Android you will compile will not be compatible with your x10 as it needs to be "edited" for our phones. It basically shows you how to get ready :)

Note : parts 1 and 2 explain how to set up Ubuntu into a virtual machine in Virtualbox. If you don't virtualize Linux, if your Ubuntu is already installed, etc etc you can directly go to 3. It's just here to explain how to install Ubuntu.

This tutorial works of course for any "hard installation" of Ubuntu (I mean not in a Virtual machine) and in any virtualizing software (Virtualbox, VMWare, etc etc). I've dropped the Virtualbox tutorial because the software is free :)

1. Requirements

2. Set up Ubuntu 64 bit (Virtualbox)

3. Set up Android Source dependencies

4. Set up Android Source

5. Regular use

1. Requirements

A working computer, capable of virtualization (if you don't want to wipe your Windows or your MacOS X !) and with Internet connection

Few Gb on your hard drive (10Gb minimum ! Recomended : 15-30Gb)

As much RAM as possible (Minimum 1024Mb), and as powerful CPU as possible (Core2Solo, Core2Duo, ...)

A bit a time

2. Set up Ubuntu 64 bit

Download and install the latest Oracle VM Virtualbox for Windows

Download latest

64-bit

Ubuntu Linux (as .iso package) - you can store the file wherever you want.

(Optional) Download the VirtualBox v4 extension, this will allow you to support improvements like USB2.0... Install : once VirtualBox will be installed, File>Preferences>Extensions>Add... If you get an error (Error 1), try to put the file in a "very simple" location (like C:\) and reinstall.

Once you've set up Virtualbox, run it. Click on "New", then follow the wizard.

Make sure you set the following :

Operating System : Linux

Version : Ubuntu (64 bit)

RAM : 512Mb (you can adjust more, but avoid use lower than 512Mb - I use 2Gb)

Create a new hard drive : set it variable size or fixed sized, but you'll need at last 15Gb to get all the files. To feel confortable, I use 30Gb (variable)

The computer is created, now run it. It will say there's no OS. Click on Devices > CD/DVD > More CD/DVD... Here is you virtual player. Click on Add, and select the Ubuntu .ISO file you downloaded. Then, choose it in the list, and click Choose. Now, you can restart the virtual machine by clicking Machine > Restart.

The computer should restart from the virtual CD, so install it to your virtual hard drive - regular install, same as if you were installing it on a physical HDD.

Once it's installed, do not forget to kick the .iso file from the virtual player for you not to start always on the CD ;)

3. Set up Android Source dependencies

In Ubuntu, do right-click on the upper bar (where are Applications, Shortcuts...), and click Edit Menus. Then, go to System > Administration and tick Software Sources. We need to do this because Sun is highly restrictive on access to Java setup files...

Close that, then click on System > Administration > Software Sources.

Enable all sources, then on the second tab, tick the two Canonical sources (the most important ones, as these sources allow to install Java !)

Close the window and allow to refresh the sources (if you don't, next steps won't work).

Go and read the official Android Source page. That's what we're going to do.

Run a terminal, and copy/paste this : (this is a corrected setup, it should work like a charm -- please tell if it's not)

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

After setup complete, make sure Java works, by typing

java

and

javac

This should return help on both commands. If one of these doesn't work (ie. "command not found"), your environment is not configured properly.

4. Set up Android Source

Create a dir called "bin" in your user dir.

cd ~
mkdir bin
echo $PATH

Then, type this :

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

Next step is to create a folder where we'll store Android sources we work on. You can place it and name it as you wish, let's call it "android" and place it on the user folder.

mkdir android
cd android

Then, run this command :

repo init -u git://android.git.kernel.org/platform/manifest.git

If it returns "command not found", restart Ubuntu !

Enter username and email, although I'm not sure it's useful for our use -custom roms-.

Now, let's get the files ! Type

repo sync

and wait... Wait... Wait... Lots of commands, of "Resolving deltas", "Receiving", etc etc. It can be very long (depends of your Internet speed), just wait...

Finally, let's register the public key and finalize setup process. Type

gpg --import

And the cursor will down a line and nothing will appear. Stuck ? Broken ? Woooops ? Not at all ! :) Program is waiting for you to type the key, which is sooooooo big. So, copy and paste all this :

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

mQ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V82dzLo71MnrF6fj+Udtb5+
OgTg7Cow+8PRaTkJEW5Y2JIZpnRUq0CYxAmHYX79EMKHDSThf/8AAwUIAJPWsB/M
pK+KMs/s3r6nJrnYLTfdZhtmQXimpoDMJg1zxmL8UfNUKiQZ6esoAWtDgpqt7Y7s
KZ8laHRARonte394hidZzM5nb6hQvpPjt2OlPRsyqVxw4c/KsjADtAuKW9/d8phb
N8bTyOJo856qg4oOEzKG9eeF7oaZTYBy33BTL0408sEBxiMior6b8LrZrAhkqDjA
vUXRwm/fFKgpsOysxC6xi553CxBUCH2omNV6Ka1LNMwzSp9ILz8jEGqmUtkBszwo
G1S8fXgE0Lq3cdDM/GJ4QXP/p6LiwNF99faDMTV3+2SAOGvytOX6KjKVzKOSsfJQ
hN0DlsIw8hqJc0WISQQYEQIACQUCSedYRAIbDAAKCRDorT+BmrEOeCUOAJ9qmR0l
EXzeoxcdoafxqf6gZlJZlACgkWF7wi2YLW3Oa+jv2QSTlrx4KLM=
=Wi5D
-----END PGP PUBLIC KEY BLOCK-----

Once pasted, hit CTRL+D, this will make the program to register the key, and will display the key has processed.

Everything is now done, you have all the sources and you are ready to create your own roms. You can edit files simply by double-click, or use any software you want.

If you want to compile, simply run a terminal, go to your folder (remember it is cd android (MS-DOS-like command), where android is the folder you defined above) then type

make

. After a long time (depends on how much RAM you assigned to the machine, 512Mbits is slow), you will generate IMG files.

5. Regular use

If you want to get the latest source files (ie you have 2.1 files and want 2.2.1 files), simply run a terminal, go to your working folder and type

repo sync

. This should do the trick (correct me if I'm wrong)

Compiling sources takes hours to process, and you may want to kill the compile or pause it. You can then abuse of these keyboard shortcuts (common to Ubuntu OS) :

CTRL+C

will kill the process. Use it carefully, as it instantly kills it with no prompt.

RIGHT CTRL+P

is a Virtualbox command. Il will pause the whole Ubuntu (and also your process), and makes the screen ugly/gray (it just stuck the screen on Virtualbox v4.x). This is helpful when you run a Virtual machine, as you can pause the OS and make your computer to sleep/hibernate (or save an image - do NOT turn off your computer, as it will turn off the Virtual machine also !). Out of sleep, you can type again RIGHT CTRL+P to make the process to continue.

** Please note it might be risky to flash your phone with the stock rom you compiled (I mean with no modification), as this is not intended to work on X10 :)

** Please note this install is for AOSP and NOT for Android SDK (you can install it with ease).

What's the difference ?

Android Open Source Project (AOSP) allows you to get the source code of the Android Operating System, in order to improve/change it, and create your personalized Android operating system

Android SDK allow you only to create and edit apps for Android Operating System.

Please note that compiling takes hours to process ! (3 hours or more)

** For any question, deeper info : please FIRST read official documentation. Easy to use, you'll get all info ! **​