Custom built android phone

How to Build a Custom ROM from Android Open Source Project

If you’re familiar with rooting your Android phone or downloading custom ROMs, such as the highly popular CyanogenMod or its successor Lineage OS, you may have wondered – how do people build these ROMs? How much work exactly goes into developing a customized ROM?

This guide will walk you through the basics of developing your own custom Android ROM. It should be noted that this is a massive undertaking – if you have zero experience in coding or fooling around in Linux terminals, you may want to get some knowledge under your belt before diving into this deep-end. But if you have at least a basic idea of those things, I will try to explain things as simply as possible, so you can follow along.

Basically what we’re doing is downloading the raw Android source code (AOSP) and modifying it to our liking. Because there are so many sources to choose from for different devices, this guide will simply reference the master source known as AOSP (Android Open Source Project).

Now the thing about the AOSP is that the pure source code does not include device-specific hardware proprieties. In layman’s terms, hardware like your camera and GPU will not work “out of the box” when developing with the AOSP. In fact, your device will not even boot without these hardware binaries.

If you’re developing for a Google-branded phone (Pixel, Nexus, etc) you can find the hardware binaries directly from Google, and this guide will walk you through obtaining and building them into your ROM. However, if you’re developing a ROM for a brand-name phone (Sony, Samsung, etc)… well, bless your heart, because you’re in for a ride.

Some manufacturers have their own open-source projects or release development tools for would-be developers, whereas other manufacturers keep a tight lid on their proprietary codes. Here’s a brief list of open-source projects from the more popular manufacturers:

With that out of the way, let’s continue under the assumption we are building a ROM for the most basic, vanilla Android experience, for a Google Pixel device. With this knowledge under your belt, you’ll be able to branch out on your own and start developing customized versions of specific manufacturer’s ROMs.

Requirements for this Guide:

  • Android Open Source Project
  • Pixel XL phone or an Android emulator for Linux
  • 64-bit Linux Operating System – Ubuntu or Linux Mint are the most newbie-friendly distros, whereas BBQLinux was developed specifically with Android developers in mind.
  • Python
  • A beefy computer (compiling code takes a lot of memory and space!)

Setting Up Your Build Environment

Let’s begin by setting up the Android emulator on your Linux machine. Whether or not you have a Google Pixel XL device, it’s always safest to try your new ROM on an Android emulator before flashing it to your device. My personal favorite is Genymotion, so I’ll walk you through installing that particular emulator. However, you can also check out this guide “Best Android Emulators”, as most of them also have Linux compatibility.

Head over to the Genymotion website, register an account, verify it through email, and download the executable to your Linux desktop.

Now open a Linux terminal, and type:

Chmod +x genymotion-xxxxx.bin (replace xxxx with the version number in the filename)
./genymotion-xxxxxx.bin

Press Y to create the Genymotion directory. Now type in the terminal:

cd genymotion && ./genymotion

Now it will ask you to begin the installation process, so just keep clicking Next until you get to the Add Virtual Devices window. Select “Pixel XL” under Device Model option, and then complete the installation. You can test the virtual device out if you want, it will basically be like having a Pixel XL phone on your desktop.

Let’s now set up Python:

$ apt-get install python

Now we need to setup the Java Development Kit on your Linux machine. Open the Linux terminal and type the following commands:

Читайте также:  Unable to resolve host no address associated with hostname андроид

$ sudo apt-get update
$ sudo apt-get install openjdk-8-jdk

Now you will need to configure the Linux system to allow USB device access. Run the following code in the Linux terminal:

This will download the required 51-android.txt file that allows the aforementioned USB device access. Open the .txt file and modify it to include your Linux username, then place the .txt file in the following location: (as the root user). Now plug your device into your computer via USB for the new rules to automatically take effect.

Downloading the Android Source

The AOSP is hosted on Git, so we’re going to use a tool called Repo to communicate with Git.

First we need to setup a /bin folder in your Home directory. Type the following commands into the Linux terminal:

Now we will download the Repo tool, so type into the Linux terminal:

/bin/repo
$ chmod a+x

After Repo is installed, we must now create an empty directory to hold your work files. So type this into the Linux terminal:

$ mkdir WORKING_DIRECTORY
$ cd WORKING_DIRECTORY

Now we’ll configure Git with your name and email address – use a Gmail address that you check regularly, otherwise you will not be able to use the Gerrit code-review tool.

$ git config –global user.name “Your Name”
$ git config –global user.email
you@gmail.com

Now we’ll tell Repo to pull the latest master manifest of AOSP from Git:

If done successfully, you’ll receive a message that Repo has been initialized in your working directory. You’ll also find a “.repo” directory inside the client directory. So now we’ll download the Android source tree with:

Building the Android Source

This is where the hardware binaries mentioned at the beginning of this guide come into play. Let’s head over to the AOSP drivers page and download the Pixel XL binaries for Android 7.1.0 (NDE63P). You want to download both the vendor image and the hardware components. These come as compressed archives, so extract them to your desktop and run the self-extracting script from the root folder. Choose to install the binaries to the root of the WORKING_DIRECTORY we created earlier.

Now type into your Linux terminal:

$ make clobber
$ source build/envsetup.sh

Now we’ll choose the target to build, so type:

$ lunch aosp_marlin-userdebug
$ setpaths
$ make –j4

There, we have now “built” an Android ROM from source. So let’s test it in the emulator, by typing into the terminal:

So play around in the emulator a bit. As you can see, a purely vanilla Android experience is quite minimal, and this is why manufacturers customize the AOSP to their needs. So you could flash this ROM we just built to your device if you wanted, but without adding any enhancements, a purely vanilla Android experience would be a very boring thing indeed.

So what manufacturers will typically do with the AOSP is fork it, add their own proprietary binaries, customize the UI, add a boot logo, etc. Manufacturer’s basically just paint over the stock Android ROM, and so that will be your next goal as well.

Stay tuned, as the second part of this guide will go through adding fonts, themes, and a boot animation to your ROM!

Источник

How to Install a Custom ROM on your Android Phone to give it a fresh new look!

Every smartphone comes with a default ROM or UI pre-installed. It can be AOSP-based with not a lot of added features, more commonly referred to as Stock Android, or it can be a custom skin from a particular brand. Samsung phones, for example, use a custom UX based on Android called OneUI. Xiaomi phones use MIUI, Oppo uses ColorOS, OnePlus uses OxygenOS, etc. Every UI looks different and has a different set of features.

While some may like a certain UI or skin, others may not. Some users prefer a feature-rich interface with the ability to install themes and modify system elements while some may want a clean, simple experience with no frills. This is where installing a custom Android ROM comes into the picture.

A custom ROM essentially replaces the stock ROM or skin on your phone with the one you choose to install. For example, if you have a Xiaomi or Redmi phone running on MIUI but you don’t like the interface, you can install a custom ROM that will change the UI to stock Android or something else you like.

Читайте также:  File system check андроид

There are multiple benefits to installing a custom Android ROM. If the UI you’re currently using has a lot of ads or bloatware, you can install a custom ROM to get rid of them. If your phone’s OEM has stopped updating your device and you’re stuck on an older Android version, you can use a custom ROM based on a newer version of Android. If you like a different OEM’s UI and want to try it on your phone, you can install a custom ROM.

Now that you know what a custom ROM can do, let’s tell you how you can install it on your Android phone. Note that there’s no universal custom ROM, although Project Treble somewhat materialized it by introducing the concept of the Generic System Image (GSI). While it is possible to install a GSI sprinkled with all the goodies from your favorite custom ROM, keep in mind that it may not offer you the same level of stability and performance that you can get from a fine-tuned dedicated custom ROM for your device. So with all of this being said, you’ll have to install a ROM that’s specifically made for your phone. Failing to do so may result in bricking your phone. You’ll then have to find ways to recover it or take it to the service center.

Note: Installing a custom ROM can void the warranty on some devices since it involves unlocking the bootloader. Proceed with caution as you can cause temporary/permanent damage to your device if you don’t follow all the steps correctly.

Sometimes, installation instructions can have some variations depending on your device. These are generic instructions. Please double-check with your device forums for variations.

Pre-requisites to Install a Custom ROM

There are certain things you need before you can start installing a custom Android ROM on your phone. Let’s go over all of them so your device is ready for the installation process.

  • An Android device.
  • An unlocked bootloader (if you don’t know how to unlock the bootloader of your phone, head over to the XDA Forums and search for your device name followed by “unlock bootloader” and you’ll find a guide. The process is different for every phone so make sure you follow the one specifically meant for your device.)
  • A custom recovery: TWRP is a good option, you can follow our detailed guide to install TWRP on your phone. However, some custom ROMs have specific recommendations on the recovery you need to use, so please follow that if such instructions are present.
  • A custom ROM zip file that you want to install (again, head over to the XDA Forums and search for your device, go through all the available ROMs, and choose the one you want to install.)
    • Please note again that custom ROM installation instructions can and do vary by device and ROM. If your ROM of choice comes with its own instructions, please follow them instead of this guide. This guide is a general list of instructions and does not take into account any special device instructions.
  • GApps or Google Apps.
  • A little bit of patience.

How to Install a Custom ROM

Now you have everything ready to install a custom ROM, we can begin the process.

Step 0: Back up your data

There’s one more thing you need to do before starting the installation though, and that’s to make a backup of all your data. We have a detailed guide to help you back up every aspect of your phone’s data so make sure you do that so it’s easy to restore your data once you install a new ROM.

Step 1: Downloading the correct ROM

As we mentioned earlier, the best way to do this is to head over to the XDA Forums for your device and look for a ROM that best suits your needs. Custom ROMs are device-specific so download a ROM that’s made specifically for your device. Also, there can be multiple variants of the same device based on carrier, region, etc. so keep this in mind too. Locate the appropriate custom ROM for your exact device. If you’re not sure, ask about compatibility in the XDA Forums.

Once you’ve found the ROM you want to install, download the zip file either on your computer or on your phone. Note that you will need to data wipe your phone in some of the later steps, so it is advisable to do the file transfer later on, after the data wipe — but ensure that your phone can connect to your computer and can receive files, just to be clear that your device drivers are in place. Later on, you will need to copy the ROM file to the root of your phone’s internal storage. Don’t extract the zip file.

Читайте также:  Наложение поверх других окон android как включить самсунг

Step 2: Downloading GApps or Google Apps

Custom ROMs do not come with Google’s apps and services pre-installed (with the exception of a few). So if you want to be able to sign in with your Google account and use Google’s services like Sync, Play Store, Gmail, Drive, etc., you’ll need to install a separate GApps package. There are multiple variants of GApps you can install. You can refer to our guide on finding the right Gapps package for you and download one that’s appropriate for you. This will also be in the form of a zip file. Download and transfer it to your phone’s internal storage. You can also install them right from your PC/Mac if you opt for the adb sideload method.

Note: Some custom ROMs like Pixel Experience come with GApps pre-installed. In such cases, you don’t have to flash the GApps file separately.

Step 3: Booting into TWRP

Once you’ve copied the ROM and GApps files to your phone’s internal memory, it’s time to boot into TWRP to flash the files. If you’re not familiar with booting into recovery mode on your phone, we have a guide telling you how to boot into recovery on your phone so you can follow that to boot into TWRP. Once you’re in TWRP, there are a few things you need to do before installing the ROM which we’ll go over in the next step.

Step 4: Installing the Custom ROM

Once you’re in TWRP, it’s a good idea to take a nandroid backup of your entire system before proceeding further. This can be useful in case you end up with a failed installation. You’ll be able to boot into TWRP and restore the backup to go back to the previous state of your device.

  • To do this, select the Backup option in TWRP and select Boot, System Image, Data, Modem, and EFS, and then Swipe to backup. Wait till it’s done.

  • This step will wipe your entire phone: Go back to the main menu of TWRP and select Wipe. Then, Swipe to Factory Reset. Select the Format Data option and type in ‘yes’ and select the tick mark to format your phone. Note that formatting the /data partition will need you to reboot once so that TWRP can properly identify the newly created file system.

  • Moreover, since the internal memory of the device is wiped during formatting, you must copy the ROM and GApps files once again to your phone’s storage.
    • You can do this from within TWRP itself. Head over to the Mount section and select the Enable MTP option.
    • Now, connect your phone to your PC and it should be detected as a storage device. Transfer the ROM and gapps files.

  • Once done, go back to the main menu on TWRP and select Install. Browse to the location where you saved the ROM and GApps files. First, select the ROM and Swipe to Install it.
    • Head back to the previous menu and select the GApps file. Install that as well. Once the installation is complete, select Reboot to System.
    • If your installation does not boot with this sequence of steps, you may need to flash/install the ROM, reboot back into recovery, and then flash the GApps file. This additional reboot is needed in some cases.

You now have a custom Android ROM installed on your phone! Wait for your phone to boot up. It may take a while for the initial boot process so don’t panic, your phone will boot into the setup process.

That’s how you can install a custom Android ROM on your phone. It’s a fairly simple process and with a little bit of time and patience, you can enjoy a fresh new ROM on your phone with added features, customization, theming, and more. If you installed a custom ROM and you don’t like it or it has issues, just download a new ROM and repeat the installation process.

Источник

Оцените статью