How to Install CyanogenMod on the LG Optimus G (ATT) (e970)
Important Notes
Recovery can be installed via the same app used for unlocking the bootloader: FreeGee. This does require root. Once the bootloader is unlocked, recovery may also be flashed via fastboot.
Installing a custom recovery using fastboot
See All About Recovery Images for more information about custom recoveries and their capabilities.
Bạn đang xem: Cyanogenmod ROM LG Optimus G (AT&T) (e970)
- Make sure your computer has working fastboot and adb.
- Download recovery — you can directly download a recovery image using the link below, or visit twrp.me to obtain the latest version of Team Win Recovery Project for your device. Recovery: Download md5: 531fca48e4ddeb32043f6e1c488d8bd0
- Connect the Optimus G (ATT) to the computer via USB.
- Make sure the fastboot binary is in your PATH or that you place the recovery image in the same directory as fastboot.
- Open a terminal on your PC and reboot the device into fastboot mode by typing adb reboot bootloader or by using the hardware key combination for your device while it is powered off.
- Once the device is in fastboot mode, verify your PC sees the device by typing fastboot devices
- If you don’t see your device serial number, and instead see “<waiting for device>”, fastboot is not configured properly on your machine. See fastboot documentation for more info.
- If you see “no permissionsfastboot”, make sure your UDEV rules are setup correctly.
- Flash recovery onto your device by entering the following command: fastboot flash recovery your_recovery_image.img where the latter part is the filename of the recovery image.
- Once the flash completes successfully, reboot the device into recovery to verify the installation. Boot to recovery instructions: Hold Volume Up & Power until fastboot screen appears, then press Volume Down twice, then press Power to boot recovery.
- Note: Some ROMs overwrite recovery at boot time so if you do not plan to immediately boot into recovery to install CyanogenMod, please be aware that this may overwrite your custom recovery with the stock one.
Installing CyanogenMod from recovery
- Make sure your computer has working adb.
- Download the CyanogenMod build package for your device that you’d like to install to your computer. Optional: Download 3rd party applications packages, like Google Apps which are necessary to download apps from Google Play.
- Place the CyanogenMod .zip package, as well as any optional .zip packages, on the root of /sdcard:
- Using adb: adb push filename.zip /sdcard/
Note: You can copy the .zip packages to your device using any method you are familiar with. The adb method is used here because it is universal across all devices and works in both Android and recovery mode. If you are in recovery mode, you may need to ensure /sdcard (sometimes called Internal Storage) is mounted by checking its status in the Mounts menu. If you have booted regularly, USB debugging must be enabled.
- If you are not already in recovery, boot to recovery mode now.
- Hold Volume Up & Power until fastboot screen appears, then press Volume Down twice, then press Power to boot recovery.
- In Team Win Recovery Project, select menu choices by tapping on the appropriately labelled button.
- Optional (Recommended): Select the Backup button to create a backup.
- Select Wipe and then Factory Reset.
- Select Install.
- Navigate to /sdcard and select the CyanogenMod .zip package.
- Follow the on-screen notices to install the package.
- Optional: Install any additional packages you wish using the same method (if you are installing multiple packages, install CyanogenMod first and then install any subsequent packages on top of it).
- Once installation has finished, return to the main menu and select Reboot, then System. The device will now boot into CyanogenMod.
How To Build CyanogenMod For LG Optimus G (“e975”)
Introduction
These instructions will hopefully assist you to start with a stock Optimus G, unlock the bootloader (if necessary), and then download the required tools as well as the very latest source code for CyanogenMod (based on Google’s Android operating system). Using these, you can build both CyanogenMod and CyanogenMod Recovery image from source code, and then install them both to your device.
It is difficult to say how much experience is necessary to follow these instructions. While this guide is certainly not for the very very very uninitiated, these steps shouldn’t require a PhD in software development either. Some readers will have no difficulty and breeze through the steps easily. Others may struggle over the most basic operation. Because people’s experiences, backgrounds, and intuitions differ, it may be a good idea to read through just to ascertain whether you feel comfortable or are getting over your head.
Remember, you assume all risk of trying this, but you will reap the rewards! It’s pretty satisfying to boot into a fresh operating system you baked at home 🙂 And once you’re an Android-building ninja, there will be no more need to wait for “nightly” builds from anyone. You will have at your fingertips the skills to build a full operating system from code to a running device, whenever you want. Where you go from there- maybe you’ll add a feature, fix a bug, add a translation, or use what you’ve learned to build a new app or port to a new device- or maybe you’ll never build again- it’s all really up to you.
What you’ll need
- A Optimus G
- A relatively recent computer (Linux, OS X, or Windows) with a reasonable amount of RAM and about 100 GB of free storage (more if you enable ccache or build for multiple devices). The less RAM you have, the longer the build will take (aim for 8 GB or more). Using SSDs results in considerably faster build times than traditional hard drives.
- A USB cable compatible with the Optimus G (typically micro USB, but older devices may use mini USB or have a proprietary cable)
- A decent internet connection & reliable electricity 🙂
- Some familiarity with basic Android operation and terminology. It would help if you’ve installed custom roms on other devices and are familiar with recovery. It may also be useful to know some basic command line concepts such as cd for “change directory”, the concept of directory hierarchies, that in Linux they are separated by /, etc.
If you are not accustomed to using Linux- this is an excellent chance to learn. It’s free- just download and run a virtual machine (VM) such as Virtualbox, then install a Linux distribution such as Ubuntu (AOSP vets Ubuntu as well). Any recent 64-bit version should work great, but the latest is recommended.
Using a VM allows Linux to run as a guest inside your host computer- a computer in a computer, if you will. If you hate Linux for whatever reason, you can always just uninstall and delete the whole thing. (There are plenty of places to find instructions for setting up Virtualbox with Ubuntu, so I’ll leave it to you to do that.)
So let’s begin!
Build CyanogenMod and CyanogenMod Recovery
Prepare the Build Environment
Install the SDK
If you have not previously installed adb and fastboot, install the Android SDK. “SDK” stands for Software Developer Kit, and it includes useful tools that you can use to flash software, look at the system logs in real time, grab screenshots, and more- all from your computer.
Install the Build Packages
Several “build packages” are needed to build CyanogenMod. You can install these using the package manager of your choice.
For both 32-bit & 64-bit systems, you’ll need:
bc bison build-essential curl flex git gnupg gperf libesd0-dev liblz4-tool libncurses5-dev libsdl1.2-dev libwxgtk2.8-dev libxml2 libxml2-utils lzop maven openjdk-7-jdk pngcrush schedtool squashfs-tools xsltproc zip zlib1g-dev
In addition to the above, for 64-bit systems, get these:
g++-multilib gcc-multilib lib32ncurses5-dev lib32readline-gplv2-dev lib32z1-dev
For Ubuntu 15.10 (wily) and newer, substitute:
- lib32readline-gplv2-dev → lib32readline6-dev
For Ubuntu 16.04 (xenial) and newer, substitute (additionally see java notes below):
- libwxgtk2.8-dev → libwxgtk3.0-dev
- openjdk-7-jdk → openjdk-8-jdk
Java versions: Different versions of CyanogenMod require different versions of the JDK (Java Development Kit):
- CyanogenMod 7 – 9: Sun/Oracle Java SE 1.6
- CyanogenMod 10.1: Sun/Oracle Java SE 1.6 or 1.7
- CyanogenMod 10.2 – 11.0: Sun/Oracle Java SE 1.6 or 1.7 (OpenJDK 1.7 works fine, but the build system will display a warning)
- CyanogenMod 12.0 – 13.0: OpenJDK 1.7 (see note about OpenJDK 1.8 below)
- CyanogenMod 14.1: OpenJDK 1.8
Ubuntu 16.04 (Xenial Xerus) or newer and OpenJDK: Since OpenJDK 1.7 was removed from the official Ubuntu repositories, you have a couple options:
- Obtain OpenJDK 1.7 from the openjdk-r PPA
- Enable experimental OpenJDK 1.8 support in CyanogenMod 13.0 (not available in earlier version). To enable OpenJDK 1.8 support, add this line to your $HOME/.bashrc file: export EXPERIMENTAL_USE_JAVA8=true.
Also see http://source.android.com/source/initializing.html which lists needed packages.
Create the directories
You will need to set up some directories in your build environment.
To create them:
$ mkdir -p ~/bin $ mkdir -p ~/android/system
Install the repo command
Xem thêm : IPhone SE 32Gb Mới 100% (Máy Trần – Đã Kích Hoạt)
Enter the following to download the “repo” binary and make it executable (runnable):
$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo $ chmod a+x ~/bin/repo
Put the ~/bin directory in your path of execution
In recent versions of Ubuntu, ~/bin should already be in your PATH. You can check this by opening ~/.profile with a text editor and verifying the following code exists (add it if it is missing):
# set PATH so it includes user’s private bin if it exists if [ -d “$HOME/bin” ] ; then PATH=”$HOME/bin:$PATH” fi
Initialize the CyanogenMod source repository
Enter the following to initialize the repository:
Note: Make sure the cm branch entered here is the one you wish to build and is supported on your device. $ cd ~/android/system/ $ repo init -u https://github.com/CyanogenMod/android.git -b cm-13.0
Download the source code
To start the download of all the source code to your computer:
$ repo sync
The CM manifests include a sensible default configuration for repo, which we strongly suggest you use (i.e. don’t add any options to sync). For reference, our default values are -j 4 and -c. The -j 4 part means that there will be four simultaneous threads/connections. If you experience problems syncing, you can lower this to -j 3 or -j 2. -c will ask repo to pull in only the current branch, instead of the entire CM history.
Prepare to wait a long time while the source code downloads.
Get prebuilt apps (CM11 and below)
Next,
$ cd ~/android/system/vendor/cm
then enter:
$ ./get-prebuilts
You won’t see any confirmation- just another prompt. But this should cause some prebuilt apps to be loaded and installed into the source code. Once completed, this does not need to be done again.
Prepare the device-specific code
After the source downloads, ensure you are in the root of the source code (cd ~/android/system), then type:
$ source build/envsetup.sh $ breakfast e975
This will download the device specific configuration and kernel source for your device. An alternative to using the breakfast command is to build your own local manifest. To do this, you will need to locate your device on CyanogenMod’s GitHub and list all of the repositories defined in cm.dependencies in your local manifest.
Extract proprietary blobs
Now ensure that your Optimus G is connected to your computer via the USB cable and that you are in the ~/android/system/device/lge/e975 directory (you can cd ~/android/system/device/lge/e975 if necessary). Then run the extract-files.sh script:
$ ./extract-files.sh
You should see the proprietary files (aka “blobs”) get pulled from the device and moved to the ~/android/system/vendor/lge directory. If you see errors about adb being unable to pull the files, adb may not be in the path of execution. If this is the case, see the adb page for suggestions for dealing with “command not found” errors.
Turn on caching to speed up build
You can speed up subsequent builds by adding
Xem thêm : Nhà di động là gì? Những mẫu nhà di động giá rẻ nhất 2023
export USE_CCACHE=1
to your ~/.bashrc file (what’s a .bashrc file?). Then, specify the amount of disk space to dedicate to ccache by typing this from the top of your Android tree:
prebuilts/misc/linux-x86/ccache/ccache -M 50G
where 50G corresponds to 50GB of cache. This only needs to be run once and the setting will be remembered. Anywhere in the range of 25GB to 100GB will result in very noticeably increased build speeds (for instance, a typical 1hr build time can be reduced to 20min). If you’re only building for one device, 25GB-50GB is fine. If you plan to build for several devices that do not share the same kernel source, aim for 75GB-100GB. This space will be permanently occupied on your drive, so take this into consideration. See more information about ccache on Google’s android build environment initialization page.
Start the build
Time to start building! So now type:
$ croot $ brunch e975
The build should begin.
If the build breaks…
- If you experience this not-enough-memory-related error…
ERROR: signapk.jar failed: return code 1make: *** [out/target/product/e975/cm_e975-ota-eng.root.zip] Error 1
…you may want to make the following change to ~/android/system/build/tools/releasetools/common.py:
Search for instances of -Xmx2048m (it should appear either under OPTIONS.java_args or near usage of signapk.jar), and replace it with -Xmx1024m or -Xmx512m.
Then start the build again (with brunch).
- If you see a message about things suddenly being “killed” for no reason, your (virtual) machine may have run out of memory or storage space. Assign it more resources and try again.
Install the build
Assuming the build completed without error (it will be obvious when it finishes), type:
$ cd $OUT
in the same terminal window that you did the build. Here you’ll find all the files that were created. The stuff that will go in /system is in a folder called system. The stuff that will become your ramdisk is in a folder called root. And your kernel is called… kernel.
But that’s all just background info. The two files we are interested in are (1) recovery.img, which contains CyanogenMod Recovery, and (2) cm-13.0-20161224-UNOFFICIAL-e975.zip, which is the CyanogenMod installation package.
Install CyanogenMod
Back to the $OUT directory on your computer- you should see a file that looks something like:
cm-13.0-20161224-UNOFFICIAL-e975.zip
Now you can flash the cm…zip file above as usual via recovery mode. Before doing so, now is a good time to make a backup of whatever installation is currently running on the device in case something goes wrong with the flash attempt. While CyanogenMod Recovery doesn’t have a backup feature, there are other custom recoveries available that do. You can also use something like Titanium Backup (root required) as an alternative.
Success! So….what’s next?
You’ve done it! Welcome to the elite club of self-builders. You’ve built your operating system from scratch, from the ground up. You are the master/mistress of your domain… and hopefully you’ve learned a bit on the way and had some fun too.
Now that you’ve succeeded in building CyanogenMod for your device, here are some suggestions on what to do next.
Also, be sure to take a glance at the Dev Center on this wiki for all kinds of more detailed information about developer topics ranging from collecting logs, understanding what’s in the source code directories, submitting your own contributions, porting CyanogenMod to new devices, and a lot more.
Congrats again!
Content of this page is based on informations from wiki.cyanogenmod.org, under CC BY-SA 3.0 licence.
Nguồn: https://sigma.edu.vn
Danh mục: Công Nghệ