ROM Android: Compile dari source

From OnnoWiki
Revision as of 07:59, 10 November 2014 by Onnowpurbo (talk | contribs)
Jump to navigation Jump to search


Before we start, just thought I would mention that "$" symbolizes a new line of code. Most of this information can be found on Building the System | Android Open Source

1) Make sure you have Ubuntu 10.04 installed on your computer.

2) Download the newest Android SDK for Linux here: http://developer.android.com/sdk/index.html

3) Extract the insides into /<username>/android/sdk/ (create these directories)

4) Open up a Terminal. Type: Code:

 $ cd android/sdk/tools 
 $ ./android 

5) The Android SDK Manager will now pop up, make sure you have platform-tools and Android 4.0.3 checked. Then click Install '#' packages. Make sure to Accept All then select "Install". After a few minutes, it will finish and you can close the window.

6) Go back into Terminal. Type: Code:

$ cd
$ sudo gedit .bashrc (make sure to give it your password) 

7) A new window will pop-up with words you will not understand. Just make sure to scroll all the way to the bottom on a blank line and enter this: export PATH=${PATH}:~/android/sdk/platform-tools | Save and close the file.

8) Now, time to install the Java 6 JDK. Open Terminal and type everything as follows: Code:

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

9) This next code will install a lot of stuff that is critical to building Android. In Terminal copy and paste all of this and then simply hit enter: Code:

$ 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 xsltproc

10) For this next part, we will be configuring USB Access for your Android device. Open Terminal and type: Code:

$ gksu nautilus (enter your password if asked) 

11) This will open up File Browser with root abilities. Find the directory /etc/udev/rules.d/ | Create a new file called 51-android.rules and open it. It will be blank so copy and paste this:

   # 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 stingray/wingray (Xoom)
   SUBSYSTEM=="usb", ATTR{idVendor}=="22b8", ATTR{idProduct}=="70a9", MODE="0600", OWNER="<username>"
   # fastboot protocol on stingray/wingray (Xoom)
   SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="708c", MODE="0600", OWNER="<username>"
   # adb protocol on maguro/toro (Galaxy Nexus)
   SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", MODE="0600", OWNER="<username>"
   # fastboot protocol on maguro/toro (Galaxy Nexus)
   SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e30", MODE="0600", OWNER="<username>"
   # adb protocol on panda (PandaBoard)
   SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d101", MODE="0600", OWNER="<username>"
   # fastboot protocol on panda (PandaBoard)
   SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d022", MODE="0600", OWNER="<username>"
   Click to expand...

12) Still in the file, go to Search --> Replace. In "Search for" enter <username> (yes, include the <>). For "Replace with" enter your computer's username (the one you set up Ubuntu with). Click "Replace All" then save and exit the file.

13) Open Terminal once again and type: Code:

$ cd
$ mkdir bin
$ sudo gedit .bashrc 

14) In the file that pops up, scroll to the bottom and enter the following on a blank line: export PATH=${PATH}:~/bin | Save and exit the file.

15) Back in the Terminal window, type: Code:

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

16) You just installed the repo command into the bin folder we created recently. Now we need to use that command to access the android source code. Back in the same Terminal window, type: Code:

$ cd ~/android
$ mkdir source
$ cd source
$ repo init -u [URL]https://android.googlesource.com/platform/manifest[/URL] -b android-4.0.3_r1
 

17) After running the last command, it should prompt you to type in your name and e-mail address. Please enter in your REAL Gmail's name and e-mail address.

18) This next step will take possibly anywhere from 1-4 hours depending on your computer. In your Terminal window, type: Code:

$ cd
$ cd android/source
$ repo sync    

19) After the "repo sync" finishes, in the same Terminal window, you will want to verify the Git Tags by typing: Code:

$ gpg --import (nothing will happen, that's okay)

20) Copy and paste this into Terminal then click CTRL+D to enter:

   -----BEGIN PGP PUBLIC KEY BLOCK-----
   Version: GnuPG v1.4.2.2 (GNU/Linux)
   mQGiBEnnWD4RBACt9/h4v9xnnGDou13y3dvOx6/t43LPPIxeJ8eX9WB+8LLuROSV
   lFhpHawsVAcFlmi7f7jdSRF+OvtZL9ShPKdLfwBJMNkU66/TZmPewS4m782ndtw7
   8tR1cXb197Ob8kOfQB3A9yk2XZ4ei4ZC3i6wVdqHLRxABdncwu5hOF9KXwCgkxMD
   u4PVgChaAJzTYJ1EG+UYBIUEAJmfearb0qRAN7dEoff0FeXsEaUA6U90sEoVks0Z
   wNj96SA8BL+a1OoEUUfpMhiHyLuQSftxisJxTh+2QclzDviDyaTrkANjdYY7p2cq
   /HMdOY7LJlHaqtXmZxXjjtw5Uc2QG8UY8aziU3IE9nTjSwCXeJnuyvoizl9/I1S5
   jU5SA/9WwIps4SC84ielIXiGWEqq6i6/sk4I9q1YemZF2XVVKnmI1F4iCMtNKsR4
   MGSa1gA8s4iQbsKNWPgp7M3a51JCVCu6l/8zTpA+uUGapw4tWCp4o0dpIvDPBEa9
   b/aF/ygcR8mh5hgUfpF9IpXdknOsbKCvM9lSSfRciETykZc4wrRCVGhlIEFuZHJv
   aWQgT3BlbiBTb3VyY2UgUHJvamVjdCA8aW5pdGlhbC1jb250cmlidXRpb25AYW5k
   cm9pZC5jb20+iGAEExECACAFAknnWD4CGwMGCwkIBwMCBBUCCAMEFgIDAQIeAQIX
   gAAKCRDorT+BmrEOeNr+AJ42Xy6tEW7r3KzrJxnRX8mij9z8tgCdFfQYiHpYngkI
   2t09Ed+9Bm4gmEO5Ag0ESedYRBAIAKVW1JcMBWvV/0Bo9WiByJ9WJ5swMN36/vAl
   QN4mWRhfzDOk/Rosdb0csAO/l8Kz0gKQPOfObtyYjvI8JMC3rmi+LIvSUT9806Up
   hisyEmmHv6U8gUb/xHLIanXGxwhYzjgeuAXVCsv+EvoPIHbY4L/KvP5x+oCJIDbk
   C2b1TvVk9PryzmE4BPIQL/NtgR1oLWm/uWR9zRUFtBnE411aMAN3qnAHBBMZzKMX
   LWBGWE0znfRrnczI5p49i2YZJAjyX1P2WzmScK49CV82dzLo71MnrF6fj+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-----
   Click to expand...

21) Go to Binaries for Nexus Phones and Flagship Devices - Google Support for Nexus Phones and Flagship Devices - Google Code and download the proper Nexus binaries, for Verizon you want to locate "Galaxy Nexus (CDMA/LTE)" and download the Graphics Component. After it finishes, open the imgtech-toro-iml74k.tgz and you will see a .sh file. Copy it and paste it into /android/source/. Do not put it in any other folders.

22) Locate "extract-imgtec-toro.sh" in the directory just listed and double click it. Select "Run in Terminal". Keep clicking enter until you get to the end of the License. Then type I ACCEPT and enter. You just created a new folder inside of the Android source called "vendor".

23) In your File Browser window, locate /android/source/device/samsung/toro. In "toro", you should see a file called extract-files.sh. Open this file with gedit. When it opens up, go to Search --> Replace. In "Search for" enter adb pull | In "Replace with" enter ./adb pull | Select "Replace All" then save and exit the file.

24) Back in the File Browser, locate /android/sdk/platform-tools. You should see a file called "adb". Right click it, select copy, then back into /android/source/device/samsung/toro right click and paste "adb". At this point, you will want to plug in your device and make sure USB Debugging is enabled.

25) Open a Terminal window and type: Code:

$ cd ~/android/source/device/samsung/toro

$ ./adb devices (it should now show your device is attached)

$ ./extract-files.sh

26) The last command we just entered extracted files such as CDMA/LTE radios from your phone and stuck them into the source. YOU CAN NOT BE ON A CUSTOM ROM OR THIS WILL NOT WORK. PLEASE BE ON ANDROID 4.0.2 OTA ROOTED (if you are on a custom ROM and don't feel like reverting to stock... please read the second post in this thread explaining a different way to do it)! We are now at the point where we can compile the final product.

27) In Terminal, type: Code:

$ cd ~/android/source
$ lunch (it will now give you options, find "full_toro-userdebug" and type the number next to it and hit enter)
$ make -j4 otapackage 

28) The last command we just ran can take up to 5 hours, depending on the speed of your computer. If you have a quad-core, I recommend running make -j8 otapackage. It will take less time. After it completes, we will give it root access, and disable the automatic flashing back to stock recovery.

29) Congratulations! You just compiled your first ROM. Now we must make last minute edits to ensure success. To see your final product, locate /android/source/out/target/product/toro. There should be one .zip file in the directory. Copy and paste it to your Desktop.

30) We will now add root access. To do so, first go here to download Superuser.apk and the su binary I put together in a zip file: Galaxy Nexus Root by droseum20.zip | After downloading, open up the .zip until you see two folders, app and bin. Open "app" and you will see "Superuser.apk". Then, open your compiled ROM from your desktop. Go to System --> app. copy and paste Superuser.apk from one .zip to the other. Now go to System --> bin in both .zips. Take "su" and drag and drop it into the "bin" folder in your compiled ROM. Now it should have full root access.

31) When compiling a ROM, it will automatically stick the stock recovery in there and we want to keep ClockworkMod, so we will do as follows. First. you will want to delete the recovery folder that is in your ROM. Next, from your ROM go to /META-INF/com/google/android/ and open updater-script. From here, not only we will delete flashing the OG recovery, we will also add some next text when any users flash our ROM.

32) Now that you have the updater-script opened, Go to Search --> Search. Type in search for recovery. It will bring you to a line that says, "package_extract_dir("recovery", "/system")". Completely delete this line. If you want to give the users who flash your ROM some nice text while it is in the boring process of flashing, keep reading to 33. If you don't care and just want to finish this long process, skip to 34 (I advise reading 33 though).

33) Still in the updater-script file, scroll all the way to the top. Make a new, blank, top line. Type ui_print("and then whatever you want. At the end of each line, you must include"); If you are confused, here is an example: ui_print("This is an example"); Now, if you want to make almost a design by using multiple lines, you can do that as well.

34) After you save and exit the updater-script file, you may move on to this. Here I will show you how to either have Google Apps built into your ROM, or have Google Apps and your ROM flash separately. For this section, I give full credit to @Kejar31, the creator of GummyNex. Download his Google Apps from this ROM thread over at RootzWiki: [ROM][AOSP][4.0.3][CDMA] GummyNex 0.5.0 - 01/10/12 - RootzWiki After downloading, it will come out in a .zip package. Simply drag and drop it to your desktop.

35) Now, you have Google Apps downloaded, but not baked inside of your ROM. To do this, we will open the GAPPS.zip file. Simply drag and drop the data folder from his GAPPS package into your ROM (not in any folder). Now, drag and drop the signed folder from one to the other. In the GAPPS pacakge, go to System, then app. Copy and paste all of them into the /System/app/ folder in your ROM. Then open the System --> etc from GAPPS and your /System/etc/. Open permissions on both, then copy and paste all the permissions from GAPPS into your ROM. Now copy and paste all the contents from /systesm/framework/ to your ROM. Open, /System/lib/ on both and once again copy and paste the contents from GAPPS into your ROM. Lastly, go to /System/Vendor/ and copy and paste the folder inside vendor (called pitpatt) into /System/vendor/ in your ROM.

36) Okay, now you are ready to flash the ROM onto your phone to make sure all goes well. Simply transfer the full_toro-ota-eng.<username>.zip onto your phone however you usuaully would. Flash clockworkmod recovery if you already have not, wipe data/factory reset, wipe cache, then dalvik cache, install from zip on sd card, find the ROM and click "Yes" to install. Reboot your phone and make sure everything worked as expected! Run into a problem? Just read the second post or contact me via Google Talk (droseum20@gmail.com).



Referensi