Unlock Bootloader, install TWRP, install custom ROM (VoLTE supported) in Lenovo Z2 Plus.

Note: By unlocking Bootloader you will lose warranty of your phone.
Disclaimer: Treat this post as a guide, since the post is not responsible if anything goes wrong.

This post will explain how one can unlock bootloader and install TWRP Recovery image in Lenovo Z2 Plus. This post also explain how to install custom ROMs, specifically Viper OS or AICP in the device. Both the custom ROMs support VoLTE. At the time of writing this post, the Android Version of both ROMs is 7.1.2 (Nougat).

Prerequisite:

Summary of files needed to install custom ROM:

  • Platform Tools: ADB and Fastboot.
  • TWRP image
  • unlock_bootloader.img from developer.zuk.com
  • Google apps
  • Custom ROM

Let’s get the above list of files one by one.

Platform Tools:

You can either install full Android SDK (big file) from [1], if you are interested in android development, or just install platform tools (smaller files). You can get the platform tools from [2], [3], [4].

TWRP image for Lenovo Z2 Plus:

Team Win Recovery Project (TWRP) is an open-source software custom recovery image for Android-based devices. You can get the TWRP image for Lenovo Z2 Plus from [5].

Unlock bootloader image:

  1. Open link http://developer.zuk.com/bootloader [6] in chrome and use google translate to translate page to English.
  2. Select Model Z2 for Z2 plus.
  3. Enter 8 digit serial number of your phone, which you can get from Phone’s settings-> About -> Status -> Serial number.
  4. Provide your email id, check the check-boxes and submit.
  5. You will get an email in your email id from zuk.com (almost immediately, so check your spam folder in case it is not in the inbox).
  6. Download the unlock_bootloader.img (1KB file :p) in the attachment.

Download Google Apps:

  1. Open link http://opengapps.org/ [7].
  2. Select Platform: ARM64
  3. Select Android 7.1.
  4. Select Variant (say, micro).

Important Points for selecting correct Variant:

  • Select appropriate variant in step 4 above, otherwise you will feel frustrated later with either a lot of google apps, or missing some default apps (replaced by google apps), which will be because of wrong google apps variant, and not because of custom ROM.
  • Check comparison between different variants at [8].
  • The comparison table at the above link, shows for each variant, what all google apps are included in it. So for example, Super variant has almost all the google apps, while Pico variant has the least number of google apps.
  • Note that the entry O means this variant replaces the Stock/AOSP version of the application by default. For example, for Super & Stock variant, the entry for Google Contacts is O. This means that if you go with Super or Stock variant, this variant will replace the default Contacts app supplied by the custom ROM with the Google Contacts. Then you will only be able to store contacts in Google, and will not be able to store contacts in your device, since google contacts will not give you the option to store contacts in your device.
  • I selected micro variant, as per my requirement (which is have only important google apps and have some default apps from custom ROM to be not replaced by google apps).

Download Custom ROM:

Following are the Custom ROM, I tested with Lenovo Z2 Plus:

  1. Viper OS: Download link – [10]
  2. AICP: Download link – [11].

You can check reviews of both the custom ROMs in forum.xda-developers.com [9] and/or youtube for look and feel. Few comments:

  1. Both support VoLTE (checked Reliance Jio, India)
  2. AICP has more stock like feeling, while Viper OS gives more customizations.

Summary of files downloaded till now:

You must have installed ADB & Fastboot. You should also have following files (put it in same location):

  1. unlock_bootloader.img
  2. TWRP image (like twrp-3.1.1-0-z2_plus.img)
  3. Open Google Apps (like open_gapps-arm64-7.1-micro-20170728.zip)
  4. Custom ROM (either Viper OS like Viper-z2_plus-7.1.2-Python-v2.1-20170702-OFFICIAL.zip, or AICP like aicp_z2_plus_n-12.1-NIGHTLY-20170728.zip)

Enable USB debugging in your phone & check ADB:

  1. Go to Phone’s settings-> About.
  2. Tap ZUI version 7 times to get Developer Options.
  3. Go to Phone’s settings -> Advanced Settings, there you will find Developer Options; enable USB debugging.
  4. Connect your phone with your PC, it will prompt to Allow USB debugging.
  5. Check “Always allow from this computer” option and proceed.
  6. Open command terminal, run the command: “adb devices”. It should list your device serial number and ‘device’ (not unauthorized).

Instructions:

There is a good video in youtube [12] which shows how to unlock bootloader, install TWRP and install Viper OS. I would suggest you to have a look to get the visuals of how the various screens will look at the time of whole process. Then follow the below steps:

Steps to unlock the bootloader & install TWRP:

  1. Open the command terminal .
  2. Run “sudo su” for root access (in linux OS). Reason fastboot needs root access.
  3. Go to the path having unlock_bootloader.img & twrp-3.1.1-0-z2_plus.img files.
  4. To check your device is accessible, run following command:

    adb devices

  5. Run following command to reboot the device:

    adb reboot bootloader

    The above command will reboot the device and you will get fastboot mode screen as shown below. Note it will show the DEVICE STATE as locked.
    locked

  6. Test fastboot has access to your device (run command in your PC terminal):

    fastboot -i 0x2b4c devices

    The above command should list your device.

  7. Run below command:

    fastboot -i 0x2b4c flash unlock unlock_bootloader.img

    You should get the output like:

    target reported max download size of 1610612736 bytes
    sending ‘unlock’ (0 KB)…
    OKAY [ 0.037s]
    writing ‘unlock’…
    OKAY [ 0.053s]
    finished. total time: 0.090s

  8. Note that after running the command (shown below) the device will boot, and you will get a screen with ‘Start >’ text at top right corner as shown in image below. The screen will be there for 5 seconds. At that screen, press any volume key to open option’s menu. In the option’s menu, navigate up or down using volume up key or volume down key. Navigate to fastboot option, and press power key for selection. You will get the fastboot screen. The fastboot screen is required to run further fastboot commands.
    unlocked_first_screen
    Run the following command to unlock boot loader:

    fastboot -i 0x2b4c oem unlock-go

    The above command will unlock the bootloader.

  9. If you have run the above command and also selected the fastboot option from option’s menu, you should get a screen similar to the screen shown in image below, but now it should show the DEVICE STATE as unlocked as shown below:
    unlocked_boot
    Run the following command to test that fastboot still has access to your device:

    fastboot -i 0x2b4c devices

    It should list your device.

  10. Run below command to flash TWRP recovery:

    fastboot -i 0x2b4c flash recovery twrp-3.1.1-0-z2_plus.img

  11. Run below command to restart your phone in TWRP recovery mode:

    fastboot -i 0x2b4c boot twrp-3.1.1-0-z2_plus.img

    The above command will open TWRP Recovery mode.

  12. You have successfully installed TWRP Recovery Mode. Swip to allow modifications. This will list options like Install Wipe etc.

Summary of commands used:

adb devices
adb reboot bootloader
fastboot -i 0x2b4c devices
fastboot -i 0x2b4c flash unlock unlock_bootloader.img
fastboot -i 0x2b4c oem unlock-go
fastboot -i 0x2b4c devices
fastboot -i 0x2b4c flash recovery twrp-3.1.1-0-z2_plus.img
fastboot -i 0x2b4c boot twrp-3.1.1-0-z2_plus.img

Create backup of stock ROM:

Before installing custom ROM, it is advisable to create backup of the stock ROM present in the device. So in case something goes wrong, or you want to revert your phone back to stock ROM, you can use the backup. Following are the steps to create backup of stock ROM:

  1. In TWRP Recovery mode (which you get in last section), select Backup.
  2. Select options: Boot, Recovery, System, System Image, Data, Firmware
  3. Swip to backup.
  4. After completion, navigate back to TWRP Home Screen.
  5. In your PC, open the Internal storage of your phone, you will find TWRP folder. Copy the TWRP folder in your PC. You can use this folder later to recover the stock ROM, using Restore option in TWRP Recovery Mode.

Wipe internal storage:

  1. In TWRP, select Wipe; them Swipe to Factory Reset.
  2. Select back to go back to previous window, then select “Format Data”, type “yes” to continue.
  3. Select back, then back, then select “Advanced Wipe”.
  4. In Advanced Wipe window, check the options: Dalvik / ART Cache, cache, System, data, Internal Storage. In short select all except USB-OTG.
  5. Swipe to Wipe.
  6. Navigate back to TWRP Home Screen.

Install custom ROM:

Below are the steps to install Viper OS (i.e. Viper-z2_plus-7.1.2-Python-v2.1-20170702-OFFICIAL.zip). If instead of Viper OS you want to install AICP use file “aicp_z2_plus_n-12.1-NIGHTLY-20170728.zip” instead of “Viper-z2_plus-7.1.2-Python-v2.1-20170702-OFFICIAL.zip”. Following are the steps:

  1. Open Internal Storage of phone in PC, copy Google Apps file (open_gapps-arm64-7.1-micro-20170728.zip) and custom ROM file (Viper-z2_plus-7.1.2-Python-v2.1-20170702-OFFICIAL.zip).
  2. In the device in TWRP Mode, click Install, which will open new screen listing the 2 zip files copied in above step. Click custom ROM file (i.e. Viper-z2_plus-7.1.2-Python-v2.1-20170702-OFFICIAL.zip file, which will open a new screen.
  3. Click Add more Zips, which will open previous screen listing the 2 zip files. Select google apps file, i.e., open_gapps-arm64-7.1-micro-20170728.zip.
    Now you have selected both the files.
  4. Swip to confirm flash.
    This will take few minutes to install custom ROM, then google apps.
  5. Click “Reboot System”, then Click “Do not install”.
    The phone will reboot, flash a screen for 5 seconds having that “Start >”, ignore that screen, then the phone will boot with the new custom ROM.
  6. Wait for few minutes (approx 5-10 minutes). If it stuck at boot logo, press power button to restart phone. This will reboot the phone. It will take approx 1-2 minutes at boot logo, and then must boot the new custom ROM.

Congratulations you have successfully installed custom ROM in your Lenovo Z2 Plus !!!

References:

  1. https://developer.android.com/studio/index.html
  2. http://rpmfind.net/linux/rpm2html/search.php?query=android-tools
  3. https://developer.android.com/studio/releases/platform-tools.html
  4. https://developer.android.com/studio/command-line/index.html
  5. https://eu.dl.twrp.me/z2_plus/twrp-3.1.1-0-z2_plus.img
  6. http://developer.zuk.com/bootloader
  7. http://opengapps.org/
  8. https://github.com/opengapps/opengapps/wiki/Package-Comparison
  9. https://forum.xda-developers.com/lenovo-zuk-z2
  10. https://download.viper-os.com/z2_plus/
  11. http://dwnld.aicp-rom.com/?device=z2_plus
  12. https://www.youtube.com/watch?v=OKlUc-oLJxA

Setup Android Studio & Android Virtual Device in Fedora

This post will be regarding setting up Android Studio in Fedora and adding Android Virtual Device.

Download Android Studio from link [1], and extract at the desired location. Run the android-studio/bin/studio.sh file. First time it will ask to install android sdk, so continue with it.

Create desktop entry / launcher:

  • To create a desktop entry, in android studio go to Tools -> Create Desktop Entry.
  • To create command line launcher, in android studio go to Tools -> Create Command-line Launcher.

Setup Android Virtual Device (AVD):
An android app can be tested either in Android Virtual Device, or in the phone itself. Following are the steps to setup Android Virtual Device:

  • In android studio, go to Tools -> Android -> AVD Manager.
  • Select Create Virtual Device.
  • By default, phone category and a phone say Nexus 5X will be selected. Change as per desired or proceed with default.
  • Next it will ask to select a system image, depending on the release name, api level and target api. Click on Download as per desired option. Note you can go back to select different phone, to get more or less options for system image.
  • It will download and install the selected component in the Android Sdk.
  • Verify and save the AVD configuration.

Troubleshooting:
Error: “WARN – vdmanager.AvdManagerConnection – Failed to create sdcard in the AVD folder.” If you get above error while creating android virtual device, it means you need sdcard utility.

For Fedora following are the dependencies:
32-bit Android SDK requires:

sudo dnf install glibc.i686 zlib.i686 libstdc++.i686 ncurses-libs.i686

64-bit Android SDK requires:

sudo dnf install glibc zlib zlib.i686 libstdc++ ncurses-libs mesa-libGL-devel adb libgcc.i686

References:

  1. https://developer.android.com/studio/index.html
  2. https://stackoverflow.com/questions/17993584/failed-to-create-sdcard-in-the-avd-folder-in-linux-fedora

Transferring files between Android Mobile & Fedora 23 via USB.

The latest Android devices uses MTP to transfer files between Android devices and computer. Following are the packages I installed to connect my android phone:

sudo dnf install libmtp
sudo dnf install gvfs-mtp
sudo dnf install simple-mtpfs
sudo dnf install mtp-detect

Not all the packages are need, but listing all the packages I know of, since different things work for different devices. In my case mtp-detect worked.

After installing the mtp, connect the android device with the usb cable, and it should get listed in the Places tab, as other drives are listed when mounted.