[Nexus 4 General] ajack2001my:
I did this 4 days ago and only published this now as I wanted to make sure it was stable and be as close to stock (aka pure Google experience). Only problem I have now is "Now on Tap" doesn't seem to work. Advise from those in the know if appreciated. Credits to those in their respective links I've included here.

-------

How I installed Android 6.0 (Marshmallow) on my Nexus 4...

I used Windows 7 as the base platform as all the tools needed are easily found on this platform.

WARNING: You will lose all data in phone, backup as necessary. I will not be responsible for this HOWTO, do so at your own risk. Yes, it worked for me. Your mileage may vary...

A. Prior to building/installing the Marshmallow build, you will need the following.

A.1. Install ADB and FASTBOOT tools.

These are the tools used to install Marshmallow on your phone. You can either install the full Android SDK or get them from this XDA thread at URL http://xdaforums.com/showthread.php?t=2317790

A.2. Install WinRAR.

You will need to use a tool called WinRAR to extract or replace certain files in an archive. You can download a copy from URL http://www.win-rar.com/

A.3. Download a Mako Google factory image of Lollipop at URL https://developers.google.com/android/nexus/images?hl=en#occam

We are going to modify the factory image of a Lollipop build. To upgrade my Mako, I used the LMY48M build.

A.4. Download the WORKING IMAGE of Android M on Nexus 4

Get the image file from URL http://dmitry.gr/index.php?r=06.+Thoughts&proj=02.+Android+M+on+Nexus4

You will get an archive called "MakoM_bin_v2.zip" file. If there is a newer version, use that instead but I used this version when I installed on my Mako.

A.5. Download TWRP for Mako

Get the TeamWin Recovery Project (TWRP) v2.8.7.0 from URL https://dl.twrp.me/mako/twrp-2.8.7.0-mako.img

A.6. Download the Google Apps (not provided in the AOSP builds).

Get the file "gapps-mm-fix.zip" from URL https://www.androidfilehost.com/?fid=24052804347833783

A.7. Download a patched kernel image that allows you to install SuperSU root.

Get the file "Fixed_Data_root.img" from URL https://www.androidfilehost.com/?fid=24052804347833767

A.8. Download a fix for Location services (GPS) not working.

Get the file "framework-res.apk" from URL http://xdaforums.com/showpost.php?p=63229334&postcount=434

A.9. Download the root manager utility.

Get the file "BETA-SuperSU-v2.52.zip" from URL http://download.chainfire.eu/743/SuperSU/BETA-SuperSU-v2.52.zip

B. Checklist

B.1. If you have downloaded everything, you should have a list of the following:

- minimal_adb_fastboot_v1.3.1_setup.exe

- wrar521.exe

- occam-lmy48m-factory-03ae06e5.tgz

- MakoM_bin_v2.zip

- twrp-2.8.7.0-mako.img

- gapps-mm-fix.zip

- Fixed_Data_root.img

- framework-res.apk

- BETA-SuperSU-v2.52.zip

C. Installation and building the installer

C.1. Install the "minimal_adb_fastboot_v1.3.1_setup.exe" and "wrar521.exe" installers, leave settings as default.

C.2. Extract the content of file "occam-lmy48m-factory-03ae06e5.tgz" using WinRAR, it'll create a folder called "occam-lmy48m". Rename "occam-lmy48m" to "mako-marshmallow".

C.3. Extract the content of file "MakoM_bin_v2.zip" and you should get the following files:

- system.img

- Choose either "n4_lte_modem.img" or "normal_modem.img" depending if you want LTE support or just 3G (UMTS) support and rename that file to "radio-mako-m9615a-cefwmazm-2.0.1701.07.img"

C.4. Rename the file "twrp-2.8.7.0-mako.img" to "recovery.img", and "Fixed_Data_root.img" to "boot.img"

C.5. Replace the "radio-mako-m9615a-cefwmazm-2.0.1701.07.img" file inside the "mako-marshmallow" folder with our "radio-mako-m9615a-cefwmazm-2.0.1701.07.img" which we extracted from file "MakoM_bin_v2.zip"

C.6. Open the "image-occam-lmy48m.zip" file and replace the following files which we downloaded from the twrp.me or dimitry.gr site. They are:

- boot.img

- system.img

- recovery.img

C.7. Open a command shell:

Start -> Run -> cmd

From the command shell, go to the folder called "mako-marshmallow"

C.8. Make sure the Nexus 4 has at least 80% battery and restart the phone into bootloader mode (by switching off the phone, the pressing the on button and at the same time pressing the volume down button). To confirm you are in bootloader mode, type in the command:

fastboot devices

You should now see the output "xxxxxxxxxxxxxxxx fastboot" appear, where "xxxxxxxxxxxxxxxx" is the serial number that appears on your Nexus 4 screen. They should be the same and you should only have one line appearing, disconnect any other device if they appear on the list.

C.9. Install the image you just build by running the script "flash-all.bat". A Series of statuses will appear on the screen. Do not disconnect the phone from the cable and let the script install everything. If done correctly, you will find the Nexus 4 rebooting. WARNING: This will erase all user data on your Nexus 4!

C.10. Once you see the Home screen of Marshmallow on your Nexus 4, go to Settings -> About Phone and tap the BUILD number seven (7) times. When you go back to the Settings screen, just above the "About Phone" is a new menu item called "Developer Options".

C.11. Go to Settings -> Developer Options and enable "USB debugging". To ensure debugging is on, go to the command shell and type:

adb devices

It sure display the list of devices with the same serial number and should have the word "device" next to the serial number. You will be prompted on the phone if you want to allow this connection.

C.12. Make sure the USB is connected in MTP mode (Transfer files mode). In windows file maanger (Press the Win-E keys), you will see a device called "Nexus 4". Open it and in the "Internal storage", go to the "Download" folder and copy the following files:

- gapps-mm-fix.zip

- framework-res.apk

- BETA-SuperSU-v2.52.zip

Then, in a command shell, issues the command:

adb reboot bootloader

C.13. From the bootloader screen, press the volume down button until the option "Recovery" appears, then press the Power button once to boot into TWRP/Recovery.

C.14. In TWRP, select to install the file "gapps-mm-fix.zip" and "BETA-SuperSU-v2.52.zip" from the "Download" folder. Once completed, press the "Reboot" button that appears in TWRP.

C.15. When the phone restarts. Go to Settings -> Backup & reset and reset the whole phone. If you get a error message from the "Setup Wizard", press the Open-apps (ie. the square softkey on the screen) and you should see the "Settings" pane.

C.16. Once the phone restart from the master reset exercise. You will be prompted as if you just switched on a new phone. Fill in as necessary until you get to the Home screen.

C.17. We will need to replace a file to get Location Services (GPS) working. From you command shell:

adb root

adb remount

adb shell

cp /sdcard/Download/framework-res.apk /system/framework/

exit

adb reboot

C.18. I disabled the following apps (drag the app to the "App Info" button, and press the "Disable" button) for the following and replaced the with similar app from Google Play (name in brackets). This was done as the built in apps kept crashing every few minutes or didn't work as expected. The apps are:

- Browser (Chrome Browser)

- Clock (Clock)

- Camera (Google Camera)

- Calendar (Google Calendar)

- Contacts (Google Contacts)

- Music (Google Play Music)

- Gallery (Google Photos)

- Search (Google)

- EMail (GMail)

C.19. Restart phone and you're ready to experience a stable (close to Google stock) build of Marshmallow on your Mako (Nexus 4).

C.20. Fixing the "Google Now on Tap" not working problem (thanks to gamekid94).

Go to Settings -> Apps

- Tap on the "Gear" (icon on the top right) -> Default Apps -> Assist & voice input -> Assist app

- Select "None", then select "Google App".

Go to Settings -> Google -> Search & Now -> Voice

- Enable "Now on Tap"

C.21. Install and customize as you see fit.