[Moto Z2 Force  Guides, News, & Discussion] Technical:
B. Preparing the phone to move into custom ROMs (AOSP) + TWRP recovery

Requirements: unlocked bootloader (see guide A) and no security lock: disable PIN, gestures and fingerprinting (because TWRP cannot read the locked/cryptographed data of the phone). Enough battery in your phone (80%).

If you do not prepare your phone to custom ROMs and if you do not have both bootloaders of the phone in the same Android version of the ROM you’ll flash, you’ll hard brick the phone and lose also the access to the bootloader! You’ve been warned: follow the guide!

Note: if you hard brick, I suggest you be prepared to follow the Unbrick Qualcomm mobiles with Step-by-step guide or the Unbrick All Qualcomm Snapdragon’s from Qualcomm HS-USB QDLoader 9008 guide, but I never tested them myself. You can also use Qualcomm Flash Image Loader (QFIL) tool.

1. Backup everything you need. Your phone will be reset including the internal sdcard.

2. Into the phone, enable the Developer Options clicking 7 times over the version (About section in the Settings). Go to Developer Options and enable USB debugging.

3. Install the Motorola drivers and the adb/fastboot files.

3.1) do not use other adb/fastboot binaries: we cannot guarantee they will work.

3.2) you need to use a USB 2.0 port of your computer. Some users report that USB 3.0 will also work.

4. Download the firmware of the same Android major version of the future ROM you’ll install (Oreo for Oreo ROMs, for instance). When (and if) we move to Android P, most probably we will need to follow this guide again.

- Retail (XT1789-05) (Europe/Brazil).

- Other models (branded): ATT, Sprint, T-Mobile (TMO), USC, Verizon.

- Note: NPXS26 versions stand for Nougat and OPXS27 for Oreo. You do not need Nougat versions for anything.

5. Extract the zip contents to a blank folder in your computer.

6. Download the FlashAll_XT1789-05.zip file, extract the content and move all files to the same firmware folder (step 5 above). Be sure to overwrite any file (if needed).

7. Run the Preparation.bat file there to generate the flashfile.bat file that will send the commands to the phone. Credits: the original preparation files were from RootJunky (can be downloaded here) and include more options that we do not need for our purpose here. Also, it includes adb/fastboot binaries that could not work with our phone.

8. Reboot the phone into the bootloader (see adb command below or power + volume down buttons). Open a command line window in the firmware folder (step 5 above), test the connection and execute the flashfile.bat file generated on step 7.

adb devices
adb reboot bootloader
fastboot devices
flashfile.bat

Never ever unplug the device from the USB 2.0 port while flashing the firmware. This could cause a hard brick and your device will be dead.

9. There is a pause at the end. You should review if everything went fine (or even click on the menu of the command line window, select all and copy&paste the contents in a .txt file for further help/revision).

10. Reboot your phone into the system (ROM) and do a quick configuration (remember that everything will be deleted when you install TWRP further…).

11. Into the phone, enable the Developer Options clicking 7 times over the version (About section in the settings). Go to Developer Options and enable USB debugging.

12. Download both the .img and .zip file of the TWRP recovery from the official site. It's the same file for all models/variants of Z2 Force phone. Put the files into our firmware folder (step 5 above). Copy the .zip file to the phone internal card. Note: versions older than 3.2.2-2 does not support PIN/Password/Fingerprint, so disable them before proceed. Most probably, ROMs before July 20th, 2018 cannot be flashed in older TWRP.

13. Now boot (not flash) the TWRP .img file using a command line window in the same firmware folder (step 5 above):

adb devices
adb reboot bootloader
fastboot devices
fastboot boot <TWRP file name>.img

14. Only now that you’re inside TWRP temporarily flash the TWRP .zip file you’ve saved into the phone (step 12 above).

15. Reboot into TWRP (use the main reboot menu in TWRP).

16. Now, you should reboot again into bootloader: inside TWRP, go to Reboot menu and choose Bootloader.

17. Now you will wipe all user data via bootloader. This is necessary to use an AOSP ROM when you come from stock. Using a command line window in the same firmware folder of your computer (step 5 above), run the following commands:

fastboot devices
fastboot -w

18. Now you can reboot the phone into System using the buttons volume up/down to navigate and confirming with the Power button. You’ll be with stock ROM and TWRP. If you want to move to a custom AOSP ROM, do a quick configuration: into the phone, enable the Developer Options clicking 7 times over the version (About section in the settings). Go to Developer Options and enable USB debugging and go to the proper guide (Process C).