yashsingh1/xdaforums huggingface dataset:
[Moto G4 Plus Guides, News, & Discussion] echo92:
Have you performed the steps to unlock your bootloader as explained here: https://xdaforums.com/showpost.php?p=67031801&postcount=2

Check that you've got OEM unlocking toggled and that the unlock data from your device is formatted as one line.
[Moto G4 Plus Guides, News, & Discussion] Ganu231:
I have already enabled oem unlock option under developer option. When i posted my oem code string in motorola unlock page then i clicked on " can my device be unlock ? " then a pop up appeared it said that "your device doesnt qualify for unlock the bootloader " Then What should i do now...?
[Moto G4 Plus Guides, News, & Discussion] echo92:
If your getvar info definitely reports your CID as 0x0032, then your best best might be to contact Motorola; post your fastboot getvar all info and your OEM unlock data as requested in this thread: https://forums.lenovo.com/t5/forums/v3_1/forumtopicpage/board-id/230/thread-id/2654/page/1 Please read the 1st post in the Lenovo/Motorola thread to see how to present the data.

Alphadog should then forward your info so they can (or at least try to) generate an unlock code for your device. Bear in mind it'll take them at least 2 business days (so probably Thursday at the earliest).
[Moto G4 Plus Guides, News, & Discussion] rush77neo:
Dumb Question

Will this process work on a Moto G4? Or is it only for the G4 Plus?
[Moto G4 Plus Guides, News, & Discussion] echo92:
Should work on a Moto G4 (since the devices are very similar). Ensure that you flash a custom kernel before you root, if you're on Nougat. Also, you can flash SuperSU or magisk instead of phh superuser if you wish.
[Moto G4 Plus Guides, News, & Discussion] rush77neo:
Thank you for the response. Is the ElementalX kernel one I should get? My phone is an unlocked Moto G4 MPJ24.139-64
[Moto G4 Plus Guides, News, & Discussion] echo92:
If you're on MPJ24.139-64, you're on Marshmallow, so you don't need ElementalX. The kernel restrictions for Marshmallow aren't as strict as Nougat :)

Here's a guide for rooting on 6.0.1 systems: https://xdaforums.com/moto-g4-plus/how-to/root-systemless-rooting-supersu-2-74-2-t3405772

I've tried it before and it works. A couple of tips:

You may wish to choose a newer version of TWRP, 3.0.2 is quite old (though still works), you may wish to flash, for example, shreps' TWRP (https://xdaforums.com/moto-g4-plus/development/recovery-twrp-3-0-2-r3-moto-g4-g4-plus-t3494337) - I use 3.10 or 3.1.1 without issue :) (though I'm on a G4 Plus)

Before flashing SuperSU, make a backup of your system (full backup) just in case.

With SuperSU, the version in the guide I mentioned is pretty old - try to download and flash a version newer than 2.79 (the latest one is 2.82 SR1 https://xdaforums.com/apps/supersu/2014-09-02-supersu-v2-05-t2868133 ) as they are systemless already, so you don't need the echo 'systemless=TRUE' step, just flash SuperSU once you've got TWRP running.

I imagine you can flash magisk instead of SuperSU too. If any of the flashes go wrong (e.g. boot issues), then revert to your full system backup.

The general plan is (assuming your bootloader is unlocked):

Boot with TWRP (or flash TWRP onto your device, if flashing TWRP, boot into recovery to ensure that TWRP is kept).

Backup your device

Flash either SuperSU (2.82 SR1 preferably) or magisk (v12 or v13).

Wipe cache/Dalvik

Reboot.

Good luck :)
[Moto G4 Plus Guides, News, & Discussion] rush77neo:
Last question. Is Nougat as stable as Marshmellow? Also, is exposed out yet for the G4? I've rooted a few phones but I am no way up to date on the state of Nougat with this phone with regards to rooting and possible installing a custom ROM.
[Moto G4 Plus Guides, News, & Discussion] echo92:
I'd say Nougat (at least the later March or June 2017 builds of stock Nougat, in my experience) is as stable as Marshmallow, though the anti-rooting-malware measures in stock Nougat are more strictly enforced (hence why a custom kernel is needed on Nougat for our devices - else rooting on stock Nougat may result in bootloops as they trigger those malware protections). I'm rooted on the June 2017 Nougat update without issue though.

xposed is currently out for Marshmallow, not for Nougat (you can see the news item in https://www.xda-developers.com/xposed-android-nougat-support/ ) - xposed for MM is here: https://xdaforums.com/showthread.php?t=3034811

As for custom ROMs, you just need a custom TWRP recovery and an unlocked bootloader. Root is not needed to flash a custom ROM :) Most if not all the custom ROMs have straightforward instructions for flashing. Most of them have a requirement for having previously flashed the stock Nougat ROM, that usually pertains to ensuring your fingerprint sensor works (which you don't have), so it's up to you if you choose to flash the stock Nougat before you flash a custom ROM.

Good luck whatever you choose. :)
[Moto G4 Plus Guides, News, & Discussion] rush77neo:
Thank you for the links and the help. I really appreciate it!
[Moto G4 Plus Guides, News, & Discussion] Sobhan Bhuyan:
Will this work on XT1643? Pls advice
[Moto G4 Plus Guides, News, & Discussion] echo92:
Should work on XT1643 - on Nougat, please ensure you flash a custom kernel (e.g. ElementalX or vegito) before you root. If you wish to root with SuperSU or magisk instead of phh superuser, have a look at these posts too: https://xdaforums.com/moto-g4-plus/how-to/guide-root-moto-g4-plus-supersu-android-t3587918 or https://xdaforums.com/showpost.php?p=72496111&postcount=270
[Moto G4 Plus Guides, News, & Discussion] shubh01608:
How to unroot it again..can u please help me ..i have rooted by this method byt i need to unroot now without losing or resettiny device
[Moto G4 Plus Guides, News, & Discussion] echo92:
Are you on phh superuser, or other rooting methods?

If on phh superuser (bear in mind I've not tried this, appears to have worked for others): https://xdaforums.com/showpost.php?p=72950733&postcount=293 Please double check your system to confirm which stock kernel you need. If you have NPJS25.93-14-8 (the June update), let us know and I'll try to upload it. If you took a TWRP backup before you flashed ElementalX, you could use the boot partition from that backup, as it should contain a clean stock kernel.

You could use SuperSU instead of magisk if you choose. The essential thing is to remove all traces of your old root from the kernel (I think just flashing ElementalX again may not work, unfortunately, as it doesn't clean out the ramdisk - which is where the clean stock kernel comes in).
[Moto G4 Plus Guides, News, & Discussion] shubh01608:
It worked like a charm.

A big thanks for your support brother.

God bless you :)
[Moto G4 Plus Guides, News, & Discussion] maheshhr:
Error installing zip file

Hello

I have moto g4 plus Android 7.0 Build number NPJS25.93-14-8. I have unlocked the bootloader and I have flashed TWRP. But when I tried to install phh Superuser from TWRP I get the following error: "Invalid zip file format! Error installing zip file"/sdcard/superuser.zip". I have downloaded phh Superuser file from the link posted here unzipped the files, edited the "config" file like instructed. Zipped the file again with 7zip application. Copied the file to internal memory.

I had to do the way I did is because, I cant save the config file within the unzipped folder.
[Moto G4 Plus Guides, News, & Discussion] echo92:
Before going to your problem (sounds like the zip is corrupted on zipping it again), have you:

a)Backed up your device in TWRP before attempting to flash anything to your system?

b)Ensured that you have a custom kernel (e.g. ElementalX or Vegito) before you attempt to root? Without a custom kernel, you'll softbrick your device if you attempt to root the stock Motorola kernel on Nougat based Moto G4 devices.

You may wish to use ZArchiver (from the Play Store, credit to 1chrome: https://xdaforums.com/showpost.php?p=71435995&postcount=1716) for editing the config file. If you're still unable to flash phh superuser, you may wish to use SuperSU or magisk 13.3 (which are both more up to date than phh superuser, and may give you more compatibility with root apps).

For SuperSU, have a look here https://xdaforums.com/moto-g4-plus/how-to/guide-root-moto-g4-plus-supersu-android-t3587918 or for magisk as well: https://xdaforums.com/showpost.php?p=72496111&postcount=270
[Moto G4 Plus Guides, News, & Discussion] maheshhr:
Thanks for the advice. I am rooting android for the first time. I may rooting because I want record some telephone calls. I do not want to install any custom ROMs. Since I am a noob can you guide me what I am supposed to do.
[Moto G4 Plus Guides, News, & Discussion] echo92:
What do you need guiding with, the process of rooting? The 2 guides I've linked previously should be helpful in how to root with either SuperSU or magisk, which are 2 of the more popular rooting managers. SuperSU appears to be the more stable root, though magisk comes with the option to 'hide' root from Google's anti-tamper/anti-root protections (called SafetyNet), which if triggered by root/xposed prevent you from using certain apps. EDIT - appears that SuperSU has its own hiding solution too :)

Basically (look in the guides for more info):

Flash TWRP ( or boot TWRP)

Backup your device in TWRP (this is your backup in case your device doesn't boot whilst attempting to root).

Flash ElementalX 1.04 or vegito.

Wipe Dalvik/cache.

Reboot to test if your system is still working.

If so, reboot to TWRP.

Flash either SuperSU 2.82 or later OR magisk 13.3 (do not mix and match root managers without properly uninstalling the old root manager.

Reboot.

Bear in mind that in some territories, call recording seems to be a legal grey area, and in some cases you may have to notify the other party they are being recorded and obtain their consent.
[Moto G4 Plus Guides, News, & Discussion] maheshhr:
Thanks again. In my country its not illegal.
[Moto G4 Plus Guides, News, & Discussion] maheshhr:
Hi echo92

I rooted like you mentioned in your post. I have TWRP recovery, ElementalX kernal 1.04 and SuperSU 2.82.

Do I have to install ElementalX Kernal Manager app to change the settings? Since one particular app is not optimised for battery consumption under android settings but still I feel its getting over ridden by the ElementalX
[Moto G4 Plus Guides, News, & Discussion] stevcho91:
Hello

I tried this method to root my moto G4 but it softbricked my phone. I think it was due to me not having kernel drivers installed? Anyway, I didn't backup my previous rom and I can't access my phone internal memory or SD card from bootloader now to put stock moto G4 rom now? What should I do?

I still would like to root my phone, but it's not working right now and I need my phone. How can I add files from my windows pc and try to rescue it?
[Moto G4 Plus Guides, News, & Discussion] echo92:
What settings are you trying to change? EX Kernel Manager appears to only affect the kernel, and I'm not sure if it'll affect battery optimisation of that app in question.

If you wish to, you can install EX Kernel Manager (please pay for it) to tune your kernel and get more battery efficiency (either by reducing the max core speeds or disabling big cores).

---------- Post added at 05:01 PM ---------- Previous post was at 04:55 PM ----------

Did you flash ElementalX or another custom kernel as directed?

If not, then you've likely tripped the anti-rooting protections in the stock kernel.

Are you able to boot into TWRP at least? If you can, try to connect your device to your PC, then download ElementalX 1.04 to your computer (from here: https://xdaforums.com/moto-g4-plus/development/kernel-elementalx-g4-0-01-t3424836 ), then copy the ElementalX from your computer to your device's internal storage.

After that, you should be able to flash ElementalX via TWRP, then wipe cache/Dalvik and reboot. See if that gets your device up and running.

If you can connect your device whilst it's in TWRP recovery, you should be able to see your storage and backup if you wish.

If that doesn't work, then you'll have to attempt a partial re-flash of your stock ROM (shouldn't affect your data), which stock ROM did you have?
[Moto G4 Plus Guides, News, & Discussion] stevcho91:
thanks for the reply. No I didn't because it wasn't directed, my phone wasn't NPJ25.93-11/12/14 I checked, but I must have checked badly, or I don't know what...

I can access TWRP but I can't copy files from my windows pc, it says usb connected in bootloader, but I can't access my phone from PC, I could only do that when my phone was booted, and now it can't.... So, I can't put stock rom on my internal card or sd and try to reflash it...

Maybe there is some way to see my storage from adb tool? I thought of puting my sd card in another phone , copying ElementalX and then puting it back in this phone and trying to flash it from TWRP?

Or should I just try to use minimal adb and reflash stock rom first? I don't have much data, my phone is new, so no big deal, I just want it up and running again, and I am afraid to brick it

Thanks once again
[Moto G4 Plus Guides, News, & Discussion] echo92:
Yeah, the opening post should really mention that regardless of what build you have, stock Nougat on Moto G4 requires a custom kernel to root without issue.

So you've booted your device to TWRP (leaving it on the TWRP main menu), and yet you don't see your device when you've connected it to your computer via USB? Have you got the minimal adb/fastboot drivers on your computer still (I assume so as you've installed TWRP)? Can you take your SD card out and try booting again?

If you can't see your internal storage, you may wish to try re-flashing the stock ROM. I don't know what build you had previously, though the latest stock ROM is the June 2017 stock ROM: https://xdaforums.com/moto-g4-plus/how-to/stock-rom-npjs25-93-14-4-march-1-t3608138 If you can remember your stock ROM security patch level or build, we could give you more tailored advice, or you may wish to flash the latest stock ROM anyway.

Assuming that you have adb/fastboot still:

Reboot your device to the bootloader.

Attach your device to your computer

In the adb terminal, verify your device is communicating by typing 'fastboot devices' in adb (without quotes), it should return your device serial code.

If communicating, you can use the following commands in the adb terminal to update your device, it'll replace TWRP and any other modifications with stock and should not lock your bootloader. It should not affect your data but be prepared to factory reset if your device is not stable:

fastboot flash partition gpt.bin
fastboot flash bootloader bootloader.img
fastboot flash logo logo.bin
fastboot flash boot boot.img
fastboot flash recovery recovery.img
fastboot flash dsp adspso.bin
fastboot flash oem oem.img
fastboot flash system system.img_sparsechunk.0
fastboot flash system system.img_sparsechunk.1
fastboot flash system system.img_sparsechunk.2
fastboot flash system system.img_sparsechunk.3
fastboot flash system system.img_sparsechunk.4
fastboot flash system system.img_sparsechunk.5
fastboot flash system system.img_sparsechunk.6
fastboot flash system system.img_sparsechunk.7
fastboot flash modem NON-HLOS.bin
fastboot erase modemst1
fastboot erase modemst2
fastboot flash fsg fsg.mbn
fastboot erase cache
fastboot reboot
[Moto G4 Plus Guides, News, & Discussion] stevcho91:
THANK YOU! It was possible to add kernel while in TWRP, I only tried while in bootloader. I installed the kernel and my phone works again.

After that I backed up and installed the root.zip folder again.

But root checker says I still have not rooted the phone properly. But I can give superuser permissions to apps?. After all that I have gone through, I would like to have root, is this well rooted device or not?
[Moto G4 Plus Guides, News, & Discussion] echo92:
Which root manager are you using, phh or SuperSU or magisk? Do your apps have root access even if root checker isn't saying your device is rooted?
[Moto G4 Plus Guides, News, & Discussion] skastream:
Im currently on android 6 - should I do root and Twrp with 6 or should I do the stock update to 7 first- which version is safer/better
[Moto G4 Plus Guides, News, & Discussion] stevcho91:
phh, but my apps have root access so I guess it's ok?
[Moto G4 Plus Guides, News, & Discussion] echo92:
If your apps have root access and they're functioning properly, I'd leave it alone and enjoy the root access :) Seems that root checker isn't picking something up in its checks.

---------- Post added at 01:27 PM ---------- Previous post was at 01:20 PM ----------

Depends on what you're after - both 6 and 7 seem to be stable and perfectly usable (I'm rooted on 7, with the June 2017 update, with magisk 13.3 and have SafetyNet working).

If you choose to stay on 6:

Simpler to root (just flash TWRP and SuperSU/magisk)

Can use xposed and other xposed modules (xposed for Nougat is not that stable yet)

Latest security patch for stock is July 2016

If you choose to update to 7:

You'll have to flash TWRP, then a custom kernel, then root (else rooting with the stock kernel will bootloop your device).

xposed for Nougat is still experimental and provided by unofficial builds, though rovo89 appears to have an official build getting close to release (and might be Oreo ready too)

Latest security patch for stock is June 2017 (though if you've updated to this, downgrading is very risky!)
[Moto G4 Plus Guides, News, & Discussion] skastream:
Thx for your answers. Lets say I stay on rooted stock Android 6 and later maybe we get stock Android 8 by lenovo and I want to switch. How do I make the OTA updates work again. Can I then go back to unrooted stock , Can I make a proper stock android 6 backup for that?
[Moto G4 Plus Guides, News, & Discussion] echo92:
Hmm, if you wanted to revert back to stock, then you've have to uninstall root (and flash an unmodified stock kernel), flash a stock recovery and then you may be able to update via OTA. However, the OTAs may fail if they detect that TWRP has been given read-write access to your system. A workaround for this is if you took a TWRP backup before you allowed TWRP to modify your system partition. Furthermore, if you've downgraded your system at any point (which I don't think you have), taking OTAs may result in a hardbrick depending on which firmware you downgraded from.

The easiest way though and the least-likely-to-brick-your-device method would be to formally flash the latest fastboot ROM, which currently is the June 2017 Nougat fastboot stock ROM (or the Oreo stock fastboot ROM if that comes out). One way to flash is as I described in a couple of posts above yours: https://xdaforums.com/moto-g4-plus/how-to/guide-how-root-nougat-moto-g4-plus-t3484672/post73484561

This involves updating the GPT, bootloader, system and modem, with removing TWRP and root, which should formally update your device to Nougat (or Oreo if we do get it, not confirmed). This method should also preserve your data from MM, but as always with flashing anything to your device, you may have to factory reset to get your device stable.

If you were to flash the June 2017 stock update, assuming that's the update before the Oreo OTA, then you should be able to get the OTA and flash (assuming your GPT/bootloader and the rest of your device is formally updated to June 2017 and no modifications, including TWRP and root, are present on your device).

Alternatively, if you do not wish to update your device's bootloader (e.g. you wish to be able to downgrade to MM without risking a hard brick) and wish to retain TWRP, I imagine a member may in time release a TWRP flashable of the stock Oreo ROM - this should only update the system side of things, and not touch your GPT/bootloader. You may have to update your modem firmware to match though, and you will not be able to accept OTA updates. You however should be able to run Oreo. Again, this is all assuming we'll get the Oreo update...
[Moto G4 Plus Guides, News, & Discussion] innominateprogrammer:
Works on XT1625

works on moto g4 XT1625 but I had to download Elementalx from the official site.
[Moto G4 Plus Guides, News, & Discussion] cra1g321:
I know this is a moto G4 Plus thread but there is no G4 root thread for nougat.

I've got a moto G4 with nougat 7.0 Build Number = NPJS25.93-14-4

is it possible to root this device ?
[Moto G4 Plus Guides, News, & Discussion] echo92:
Provided your device is not an Amazon Prime device - the one with ads on the lockscreen - the instructions for unlocking your device and rooting apply the same for Moto G4 as they do for Moto G4 Plus (after all, the only difference is the fingerprint sensor and the camera).

As per many posts in this thread, once you've unlocked your bootloader and flashed TWRP, you must flash a custom kernel to successfully root; rooting on the stock Motorola kernel (the one with hudsoncm) will cause your device to bootloop as you've likely triggered the anti-rooting protections. A custom kernel doesn't appear to have those same protections - by custom kernel, I refer to ElementalX or vegito.

Once done, you may wish to flash either SuperSU or magisk or phh superuser. The guides for flashing SuperSU or magisk can be also found here: https://xdaforums.com/moto-g4-plus/how-to/guide-root-moto-g4-plus-supersu-android-t3587918 or https://xdaforums.com/showpost.php?p=72496111&postcount=270

Essentially, the steps are all the same though for rooting:

1)Unlock bootloader

2)Flash/boot TWRP and backup

3)Flash ElementalX or another custom kernel

4)Flash your preferred rooting manager

5)Reboot and you should be rooted.
[Moto G4 Plus Guides, News, & Discussion] cra1g321:
Yeah it's not the amazon one thankfully, thanks for the reply, wasn't sure about the build number still being able to be rooted or not,

figured it was best to ask here, thanks for fast reply and great info.
[Moto G4 Plus Guides, News, & Discussion] Shreekarg:
Can anyone tell me will i get stock updates if i flash element x kernel ? As far as i know i won't but still need to clarify. Please help me out
[Moto G4 Plus Guides, News, & Discussion] strongst:
Nope.
[Moto G4 Plus Guides, News, & Discussion] krishna8691:
i am onto NPJ25.93 14-8 build can i flash twrp and then go into twrp and flash lineage os 14.1 and boot ?

without flashing elemental x kernel ?
[Moto G4 Plus Guides, News, & Discussion] echo92:
Yes, you only need to flash TWRP to flash lineage or any other custom ROM. Root or ElementalX are not needed, and in fact are replaced by the custom ROM anyway, so it's unnecessary. The custom ROM will replace your system and data with its own, hence the need to erase those partitions in TWRP (as well as cache and Dalvik) as stated in the instructions for flashing most custom ROMs, before you proceed to flash the custom ROM. You may choose to back up your existing system in TWRP so if the custom ROM flash doesn't work, you'll have a backup to fall back to.
[Moto G4 Plus Guides, News, & Discussion] osccarr:
Hello, im new :)

I have a Moto G4 (Not Plus). I have unlocked bootloader and TWRP. I was on a variety of custom roms but decided to restore my clean stock rom from motog4. Can I rootit in the same way as the earlier versions? Flash ElementalX and Magisk / Su? My version is 7.0 NPJS25.93-14-8 XT1622 .

Thanks for help guys , have a nice day :)
[Moto G4 Plus Guides, News, & Discussion] strongst:
Yes you can do it as you described!
[Moto G4 Plus Guides, News, & Discussion] osccarr:
Thanks :) All working Fine

My last question,

How can I disable automatic updates of OTA Stock Rom? Since I have a custom kernel, I do not want the system to update itself if another security patch comes out etc. Thanks !
[Moto G4 Plus Guides, News, & Discussion] calinb7:
From what I've learned in these forums, I don't think your phone will update with your custom kernel no matter what you do. However, when I rooted 6.0, I used SD Maid to freeze the Motorola update process. I still need to install ElementalX and re-root since updating to 7.0 myself, whereas I could use the stock OEM kernel with 6.0.
[Moto G4 Plus Guides, News, & Discussion] probin1230:
i open cmd prompt and connect phone but "waiting for phone" msg shows in cmd prompt