Installing and rooting an AVD

Here, I would like to install an AVD with Android Studio, then root it

Where to install

First of all, I would like to have my virtual machines installed on a different SSD (Or Hard drive), in my case, this is because my main disk is always busy, and i want the Android Virtual Device to be snappy, others may have storage space concerns, others may want to skip this step, depends…

To do this on my Debian machine, i need to add the following line to ~/.bashrc

export ANDROID_AVD_HOME="/hds/ssngoem/avd"

On windows, i would have to Edit the system environment variables.

If you just want to move a machine, move it from ~/.android/avd/, don’t move the ini file, instead edit the ini file and fix the location of the virtual machine to wherever you put it

Make it

Now, all we need to do is create a machine in Android Studio!

Root it

To root the phone we need rootAVD

Start by checking whether the AVD is connected to the PC with adb devices

adb devices
List of devices attached
emulator-5554 device

So it seems that it is !

Now, we need rootAVD from newbit (https://gitlab.com/newbit/rootAVD)

git clone https://gitlab.com/newbit/rootAVD.git
cd rootAVD
./rootAVD.sh listAllAvds (On windows, use rootAVD.bat instead of sh)

The above command will give you a list of commands for each and every one of your Android Virtual Devices ! I will copy the first one, but the end of every line there is the last word that explains what it is

Once you run the command to root the phone, the phone will reboot (Or shutdown), you need to start the phone again (Make sure you chose cold boot from the … menu), and you will find a tool called magisk on the phone emulator, you need to run it, when you run it for the first time, it will tell you there is additional setup that needs to be done, which will reboot the device again

Your phone should now be rooted, to be sure, you can

adb shell
whoami
su (The phone screen will ask for permission)
whoami

Leave a Reply

Your email address will not be published. Required fields are marked *