Genymotion recently moved root access behind a paywall, making it a premium feature. However, if you're using Genymotion for Android development, testing, or educational purposes, having root access can be essential. Root access allows developers to access deeper functionality, test root-only features, and explore Android's internals without restrictions.
The good news is that with a bit of work, you can still enable root on a Genymotion emulator if you have access to its disk image and platform keys. This guide walks you through the process of adding a custom system app, RootToggle, which will allow you to switch root access on and off without needing Genymotion's paid root access feature.
This Gist details the steps to compile, sign, and install RootToggle as a system app in a Genymotion emulator by directly modifying the emulator's disk image IN LINUX (use a virtual machine on Windows to do that).
- RootToggle.apk: The signed APK for RootToggle
- RootToggle Source Files: Source code for the RootToggle app
- Setup Instructions: Guide to add RootToggle to the system partition in Genymotion
If you prefer to compile the APK from source, follow these steps:
-
Get the source: Download source.zip
-
Build the APK: Open the project in Android Studio and build the APK, or use the Gradle command line.
./gradlew assembleRelease
-
Locate the Unsigned APK: After building, the unsigned APK will be in the
app/build/outputs/apk/releasedirectory.
You will need platform.pk8 and platform.x509.pem keys for the emulator. If for some reason this repo doesn't exist anymore, you could get it here.
git clone https://github.com/Genymobile/genymotion_platform_vendor_genymotion_security_public
cp genymotion_platform_vendor_genymotion_security_public/release-keys/platform* .Run the following command to sign the APK:
/path/to/build-tools/<version>/apksigner sign \
--key platform.pk8 \
--cert platform.x509.pem \
--out RootToggle-signed.apk \
app/build/outputs/apk/release/app-release-unsigned.apkThe signed APK is now ready to be installed as a system app.
Using QEMU and qemu-nbd, we’ll add the signed APK to the Genymotion emulator’s system partition.
-
Load the NBD (Network Block Device) Module:
sudo modprobe nbd
-
Attach the QCOW2 Disk Image:
sudo qemu-nbd --connect=/dev/nbd0 ~/.Genymobile/Genymotion/deployed/Google\ Pixel\ 7\ Pro/system.qcow2
-
Identify the System Partition:
Run
fdisk -lto confirm the correct partition (usually/dev/nbd0p4for large partitions). -
Mount the System Partition:
sudo mkdir -p /mnt/android_system sudo mount /dev/nbd0p4 /mnt/android_system
-
Create the App Directory:
sudo mkdir -p /mnt/android_system/system/priv-app/RootToggle
-
Copy the Signed APK:
sudo cp RootToggle-signed.apk /mnt/android_system/system/priv-app/RootToggle/RootToggle.apk
-
Set the Correct Permissions:
sudo chmod 644 /mnt/android_system/system/priv-app/RootToggle/RootToggle.apk
-
Unmount and Disconnect:
sudo umount /mnt/android_system sudo qemu-nbd --disconnect /dev/nbd0
Start your Genymotion emulator as usual. The RootToggle app should now be installed as a system app with the necessary permissions to modify persist.sys.root_access.