Steps to Root with Chainfire's One-Click Root:
1) Download One-Click Root kit: http://download.chainfire.eu/297/CF-Root1/CF-Auto-Root-mako-occam-nexus4.zip?retrieve_file=1
(src: http://download.chainfire.eu/297/CF-Root/CF-Auto-Root/CF-Auto-Root-mako-occam-nexus4.zip)
2) Boot the Nexus 4 into bootloader mode via adb or hardware buttons (press and hold Volume Up, Volume Down and Power buttons until Fastboot/Bootloader menu and START icon appear on the screen).
3) Connect the Nexus device to computer via USB cable.
4) Unzip the CF-Auto-Root-mako-occam-nexus4.zip file on your computer.
5) Run the root-windows.bat file. (or corresponding one for your OS)
Nexus 4 drivers: http://web.ist.utl.pt/~ist164819/trubi/lib/exe/fetch.php?media=registered:drivers.zip
Steps to Flash image:
1) Build Kernel
cd kernel/msm ARCH=arm SUBARCH=arm CROSS_COMPILE=../../prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin/arm-eabi- make -j8 mako_defconfig ARCH=arm SUBARCH=arm CROSS_COMPILE=../../prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin/arm-eabi- make -j8 cd ../..
2) Build Middleware
. build/envsetup.sh lunch aosp_mako-userdebug time make -j8
3) Device Setup and Flash
adb reboot-bootloader fastboot oem unlock (There is a bug with adb and fastboot which doesn't let me use flashall without using oem unlock first) fastboot flashall -w (-w deletes user data, remove it to update OS without deleting APPs)
3*) In case you get stuck with the < waiting for device > msg after the fastboot flashall command:
3a*) Get the usb information:
lsusb -v | less
This command should return a lot of information, so keep your eyes opened for something like this:
Bus 001 Device 027: ID 18d1:4e30 Google Inc. Couldn't open device, some information will be missing Device Descriptor: ... idVendor 0x18d1 Google Inc.
3b*) Edit or create the file, like this:
sudo vi /etc/udev/rules.d/11-android.rules
Now add a line like this, inserting your own username and vendor id
SUBSYSTEMS=="usb", ATTRS{idVendor}=="18d1", MODE="0640", OWNER="kostah"
3c*) Restart the usb service:
sudo service udev restart
3d*) Optionally you may confirm if the device node permissions changed, and you should be ready to retry the fastboot flashall command to flash the device.
ls -Rl /dev/bus/usb
Google Apps install:
Root again
Install RomManager.apk
Install CWM with RomManager
adb reboot recovery
Install gapps from sdcard