Over-the-air updates have long been the bane of many rooted Android users’ existences. It’s an endless battle: installing the update breaks root or won’t flash at all, but everyone wants the latest version of their mobile OS. Thanks to a new tool called FlashFire, the struggle may be over.

Why OTA Updates Don’t Play Nicely with Rooted Phones

RELATED: What's the Difference Between Jailbreaking, Rooting, and Unlocking?

Android is based on Linux, so Android devices come with a “root” user that functions like the Administrator user account on Windows. By default, Android doesn’t give you access to the root account. Rooting is the process of enabling access to the root account, installing the su binary. Applications can call su to gain elevated privileges, so they can break free from Android’s security sandbox and do more powerful things. Android doesn’t come pre-rooted because of the security problems this could lead to, especially for less technically inclined users.

The root process also installs an application like SuperSU, which controls access to the su binary, so you can choose which applications are allowed to have root access.

You’ll usually lose your root access when you install an operating system update. On Lollipop and earlier versions of Android, the over-the-air (OTA) update sets your Android system partition back to its factory state, removing the su binary. On newer devices with systemless root, it overwrites the boot image. And if you have a custom recovery, the OTA update may not be able to install itself at all.

Once upon a time, SuperSU had an “Survival Mode” that would let you flash updates, but that’s no longer around. Enter FlashFire.

What Is FlashFire?

FlashFire is powerful tool from Chainfire, the maker of SuperSU, that allows rooted users to perform a variety of actions, like flashing OTA updates and full zip files, create and restore backups, wipe data, and much more. It effectively eliminates the need to use recovery to manually backup or restore, and automatically handles un-rooting and re-rooting when flashing update files.

RELATED: How to Root Your Android Phone with SuperSU and TWRP

Theoretically, it should work on many, if not most, Android 4.2+ handsets. However, there are caveats.

On many devices, having root will prevent OTAs from downloading and flashing. On some devices it will actually download, but you would need a tool like FlashFire to successfully flash it. On other devices, it will not actually download, so you’d have to get the OTA file some other way (they are often posted on sites like XDA Developers), and then maybe you can flash it with a tool like FlashFire. If you can’t get the OTA file, you may be out of luck.

Furthermore, if you’re running a rooted device that’s getting a full version update—from Lollipop to Marshmallow, for example—things get murkier. Since there’s no way to root Marshmallow without an unlocked bootloader, you’ll completely lose root access if your device’s bootloader is locked. That’s unavoidable. If you’ve unlocked the bootloader, however, FlashFire should be able to preserve (or at least reinstate) root access once the update is finished.

So: while FlashFire isn’t guaranteed to work on every device, if you’ve gone the “official” route to root your phone, it will probably work.

If you want to learn more I encourage anyone interested to check this thread on XDA before getting started. When you’re ready, you can install FlashFire from the Play Store.

How to Use FlashFire to Flash an OTA Update, Without Losing Root

When you get notified that there’s an update available for your device, the first thing you’ll want to do is go ahead and download it—but don’t install it. If you tell the update to go ahead and install, it will likely fail since you’re running a rooted device.

Instead, fire up FlashFire once the OTA has finished downloading. It should automatically detect the update file and ask if you want to generate the actions to flash it. Go ahead and tap “OK.”

This will generate a screen that may seem a little overwhelming to novice users, but it’s essentially just a breakdown of what FlashFire intends to do with the OTA file. Each option is customizable if you tap on it—for example, if you don’t want to wipe the cache partition, simply de-select that option. You can also add various actions, but I wouldn’t necessarily recommend doing that right now.

If you have a custom recovery like TWRP installed, FlashFire will back it up before starting the process, and restore it afterwards.

Once you’ve finalized the set of instructions, hit the “Flash” button. It will give a warning that it can take a bit of time for FlashFire to load, and a couple of black screens may appear. Go ahead and tap “OK” again.

After that, FlashFire will reboot and you’ll see a bunch of scrolling text on the display. Leave the device alone to do its thing—that’s just FlashFire running the needed commands. When it’s finished, it’ll reboot with the update flashed and root restored. Boom. So simple.

What to Do if Flashing the OTA Doesn’t Work

If you’ve modified your device in a way that prevents FlashFire from applying the update—maybe you’re running a custom kernel, or the /system partition has been modified by the Xposed Framework, for example—then the update will “fail.” There’s currently no notification that the update wasn’t applied, so you’ll have to jump into the Settings > About phone menu and see if the build number has changed. If not, then you know the update wasn’t applied (there’s also a good chance Android will notify you that the update still needs to be installed).

When this happens, the best thing to do is to download the factory image for your device if it’s available. In this example, I’ll be flashing the newest update (April 2016 security patches) onto my Nexus 7.

Once downloaded, copy the factory image’s .tgz file to your phone’s internal storage or SD card.

Open up FlashFire and tap the floating action button (the red button with the plus) in the bottom right corner. Select “Flash firmware package.”

This will open up a file manager of sorts, which should default to the root internal storage folder. Scroll down until you find the file you just moved to the device.

Once you select the image file, FlashFire will scan the archive to verify its contents, then present a list of what can (and will) be flashed. You’re free to select what you want here—if you have a custom recovery and want to keep it that way, simply de-select the “recovery” option, for example.

Once you’re ready to flash, just tap the checkmark in the upper right corner. You’ll once again be presented with the list of actions before it proceeds, so if you want or need to change anything, now’s the time.

After you’ve confirmed all the steps, hit the “Flash” button. You’ll see the same warning about FlashFire taking some time to load and that a couple of black screens may appear. Just hit “OK.”

FlashFire will reboot and do its thing. Since it’s flashing a full image file and not just a simple update, it could take a little while for it to finish. Once it does, however, it’ll reboot and you’ll be good to go.

This is just scratching the surface of what FlashFire can currently do, and that goes without mentioning what it will be capable of in the future. We’ll undoubtedly have more things to say about it once we’ve spent more time with upcoming updates to the app.