[SCRIPT] rootAVD - root your Android Studio Virtual Device emulator with Magisk [Android 12][Linux][Darwin/MacOS][WIN][Google Play Store APIs]

Search This thread

bibliotekarz

Member
Apr 11, 2021
13
3
I'm reinstalling AS now and installing the newest one, SDK aswell. Maybe it will help. I will create a new Google Pixel 4 with Google Apps. Cold boot default, update the packages in settings and try again. I have also installed a fresh rootAVD-master script and try this out in administrator. Should fix some errors that might've happened randomly. Done magisk, then magisk su and thats what it shows:
1618178655992.png
 

Attachments

  • 1618178601971.png
    1618178601971.png
    68.4 KB · Views: 5

newbit

Senior Member
Nov 16, 2008
141
61
I'm reinstalling AS now and installing the newest one, SDK aswell. Maybe it will help. I will create a new Google Pixel 4 with Google Apps. Cold boot default, update the packages in settings and try again. I have also installed a fresh rootAVD-master script and try this out in administrator. Should fix some errors that might've happened randomly. Done magisk, then magisk su and thats what it shows:
Why don't you just try Android 11? The 2nd run is only needed on Android S.
Your basic issue, that the popup doesn't show up, when you run su from the adb shell.
I will try to get this situation on my windows machine as well.
You don't need to run the script as admin. They are no special rights needed at all.
If you run magisk in adb shell, it might tells you what is wrong. for example, if the deamon is not running.
And if you run magisk su, it should invoke the pop up as well.
 

bibliotekarz

Member
Apr 11, 2021
13
3
Okay. Now when I do adb shell into su i get the prompt. Everything seems good now. I have restarted the device and will now patch for 2nd time. Now I got Two prompts. Both Of which I accepted. The device is rebooting automatically. Is everything done now, or Do I have to do anything more? @newbit Also thanks for help. You are a boss, If not your help I would be stuck at the start.
 
  • Like
Reactions: newbit

Apalon3709

New member
Apr 20, 2021
3
0
Hello everyone, I am completely new to android studio. I am having trouble installing root on Android 11 and Android S. Here is the log of my installation. Magisk itself is installed, but there is no root
C:\Users\Administrator\Desktop\rootAVD-master>adb shell
emulator64_x86_64_arm64:/ $ exit

C:\Users\Administrator\Desktop\rootAVD-master>set PATH=%LOCALAPPDATA%\Android\Sdk\platform-tools;%PATH%

C:\Users\Administrator\Desktop\rootAVD-master>set PATH=%LOCALAPPDATA%\Android\Sdk\platform-tools;%PATH%

C:\Users\Administrator\Desktop\rootAVD-master>rootAVD.bat %LOCALAPPDATA%\Android\Sdk\system-images\android-S\google_apis_playstore\x86_64\ramdisk.img
Invalid folder name.
" [ * ] create File Backup"
Files copied: 1.
"[-] In any AVD using ADB you can run the code without root in /data/data/com.android.shell"
"[-] ADB connectoin possible"
"[*] looking for Magisk installer Zip"
"[*] Cleaning workspace ADB"
"[*] Creating the workspace ADB"
"[-] To copy the Magisk installer Zip"
C:\Users\Administrator\Desktop\rootAVD-master\Magisk.zip: ...ile pushed, 0 skipped. 59.4 MB/s (6720493 bytes in 0.108 s)
" [ * ] Copy the original AVD ramdisk. img to Magisk DIR"
C:\Users\Administrator\AppData\Local\Android\Sdk\system-im...ile pushed, 0 skipped. 69.5 MB/s (2322258 bytes in 0.032 s)
"[-] Copy script rootAVD in Magisk DIR"
rootAVD.sh: 1 file pushed, 0 ignored. 51.6 MB/s (22575 bytes in a 0.000 s)
"[-] The conversion of the script to the end Unix"
"[-] start to actually boot/Ramdisk/Kernel Patch Image Script"
"[*] by topjohnwu Magisk from and modded by NewBit XDA"
[!] We are in the emulator shell
[- ] Switch to the location of the script file
[ * ] Extracting busybox and Magisk.zip ...
[ - ] Checking the AVDs Internet connection...
[!] The AVD is online
[!] Check available versions of Magisk
[?] Select the version of Magisk to install and make it local
[1] Local '22.1' (ENTER)
[2] Canary fb8000b5(22104)
[3] Stable 22.1

[1] You select the local version of Magisk '22.1'
[ * ] Re-run rootAVD in Magisk Busybox STANDALONE (D)ASH
[!] We are in the emulator shell
[-] We are now in Magisk Busybox STANDALONE (D)ASH
[ * ] rootAVD with the Magisk '22.1'installer
[- ] Get flags
[*] System-as-root, keep dm/avb-verity
[- ] Encrypted data, store forceencrypt
[*] RECOVERYMODE=false
[-] KEEPVERITY=true
[*] KEEPFORCEENCRYPT=true
[- ] Api Level Arch Detection
[- ] Device platform: x64
[-] Device SDK API: 30
[-] ARCH32 x86
[- ] First API level: 31
[ * ] copy all files from /data/data/com. android. shell/Magisk/lib/x86 to /data/data/com. android. shell/Magisk
[ * ] ramdisk.img compression detection
[!] Ramdisk. img uses lz4_legacy compression
[- ] taken from the book of the jackalaki. MagiskOnEmulator/process.sh
[ * ] performing ramdisk partitioning / extracting / repacking
[- ] API level greater than 30
[ * ] Check if we need to repackage the ramdisk before patching ..
[- ] Multiple cpio archives detected
[ * ] Unpacking ramdisk ..
[ - ] Resetting from 0 to 1418329 ..
Detected format: [lz4_legacy]
[- ] Dumping from 1418329 to 2322258 ..
Detected format: [lz4_legacy]
[*] Repackaging ramdisk ..
[ - ] Check the patch status and perform a restore
[- ] Checking the ramdisk status
[- ] STATUS=0
[- ] A stock boot image was detected
[- ] ramdisk fix
[!] PATCHFSTAB=false
[!] Skipping the fstab.ranchu patch with /dev/block/sda
[?] If you want fstab. ranchu to be fixed, set PATCHFSTAB=true
[!] fix ramdisk with Magisk Init
Loading cpio: [ramdisk.cpio]
Add entry [init] (0750)
Create a directory [overlay.d] (0750)
Create a directory [overlay.d/sbin] (0750)
Add entry [overlay.d/sbin/magisk32. xz] (0644)
Add entry [overlay.d/sbin/magisk64. xz] (0644)
Patch with the KEEPVERITY=[true] KEEPFORCEENCRYPT=[true] flag]
Loading cpio: [ramdisk.cpio. orig]
Backup mismatch record: [init] - > [. backup/init]
Writing a new record: [overlay.d] - > [. backup/.rmlist]
Write a new record: [overlay.d/sbin] - > [. backup/. rmlist]
Write a new record: [overlay.d/sbin/magisk32. xz] - > [. backup/.rmlist]
Write a new record: [overlay.d/sbin/magisk64. xz] - > [. backup/. rmlist]
Create a directory [.backup] (0000)
Add an entry [.backup/.magisk] (0000)
cpio dump: [ramdisk.cpio]
[ * ] repackaging back to ramdisk.img format
[!] Rename Magisk.zip for Magisk.apk
"[-] After the ramdisk file.img will be corrected and compressed,"
"[*] pull it back to Magisk DIR"
/data/data/com.android.shell/Magisk/ramdiskpatched4AVD.img...ile pulled, 0 missed. 65,4 MB/s (2732968 byte 0,040 s)
"[-] pull Magisk.apk apps\"
/data/data/com.android.shell/Magisk/Magisk.apk: 1 file pulled, 0 skipped. 70,1 MB/s (6720493 bytes for 0,091 with)
"[- ] pull the Magisk.zip to applications\ "
adb: error: failed to stat remote object '/data/data/com.android.shell/Magisk/Magisk.zip': No such file or directory
"[ - ] Clear the ADB workspace"
"[ * ] Move and rename the patched ramdisk. img to the original AVD DIR " Files
copied: 1.
"[- ] Install all APK files located in the Apps folder"
"[ * ] Trying to install APPS\Magisk. apk "
Performing a Streaming Installation
Success
"[ - ] restart AVD and see if it worked"
"[ - ] Root and Su with Magisk for Android Studio AVDs"
" [ - ] Modded by NewBit XDA - Jan. 2021"
"[ * ] Huge credits and big thanks to topjohnwu and shakalaca"

My work System:
OS: Windows 10
Android Studio 4.1.3
AVD:Pixel 3, android 11(S) and Nexus5X android 11
 

newbit

Senior Member
Nov 16, 2008
141
61
Hello everyone, I am completely new to android studio. I am having trouble installing root on Android 11 and Android S. Here is the log of my installation. Magisk itself is installed, but there is no root
C:\Users\Administrator\Desktop\rootAVD-master>adb shell
emulator64_x86_64_arm64:/ $ exit

C:\Users\Administrator\Desktop\rootAVD-master>set PATH=%LOCALAPPDATA%\Android\Sdk\platform-tools;%PATH%

C:\Users\Administrator\Desktop\rootAVD-master>set PATH=%LOCALAPPDATA%\Android\Sdk\platform-tools;%PATH%

C:\Users\Administrator\Desktop\rootAVD-master>rootAVD.bat %LOCALAPPDATA%\Android\Sdk\system-images\android-S\google_apis_playstore\x86_64\ramdisk.img
Invalid folder name.
" [ * ] create File Backup"
Files copied: 1.
"[-] In any AVD using ADB you can run the code without root in /data/data/com.android.shell"
"[-] ADB connectoin possible"
"[*] looking for Magisk installer Zip"
"[*] Cleaning workspace ADB"
"[*] Creating the workspace ADB"
"[-] To copy the Magisk installer Zip"
C:\Users\Administrator\Desktop\rootAVD-master\Magisk.zip: ...ile pushed, 0 skipped. 59.4 MB/s (6720493 bytes in 0.108 s)
" [ * ] Copy the original AVD ramdisk. img to Magisk DIR"
C:\Users\Administrator\AppData\Local\Android\Sdk\system-im...ile pushed, 0 skipped. 69.5 MB/s (2322258 bytes in 0.032 s)
"[-] Copy script rootAVD in Magisk DIR"
rootAVD.sh: 1 file pushed, 0 ignored. 51.6 MB/s (22575 bytes in a 0.000 s)
"[-] The conversion of the script to the end Unix"
"[-] start to actually boot/Ramdisk/Kernel Patch Image Script"
"[*] by topjohnwu Magisk from and modded by NewBit XDA"
[!] We are in the emulator shell
[- ] Switch to the location of the script file
[ * ] Extracting busybox and Magisk.zip ...
[ - ] Checking the AVDs Internet connection...
[!] The AVD is online
[!] Check available versions of Magisk
[?] Select the version of Magisk to install and make it local
[1] Local '22.1' (ENTER)
[2] Canary fb8000b5(22104)
[3] Stable 22.1

[1] You select the local version of Magisk '22.1'
[ * ] Re-run rootAVD in Magisk Busybox STANDALONE (D)ASH
[!] We are in the emulator shell
[-] We are now in Magisk Busybox STANDALONE (D)ASH
[ * ] rootAVD with the Magisk '22.1'installer
[- ] Get flags
[*] System-as-root, keep dm/avb-verity
[- ] Encrypted data, store forceencrypt
[*] RECOVERYMODE=false
[-] KEEPVERITY=true
[*] KEEPFORCEENCRYPT=true
[- ] Api Level Arch Detection
[- ] Device platform: x64
[-] Device SDK API: 30
[-] ARCH32 x86
[- ] First API level: 31
[ * ] copy all files from /data/data/com. android. shell/Magisk/lib/x86 to /data/data/com. android. shell/Magisk
[ * ] ramdisk.img compression detection
[!] Ramdisk. img uses lz4_legacy compression
[- ] taken from the book of the jackalaki. MagiskOnEmulator/process.sh
[ * ] performing ramdisk partitioning / extracting / repacking
[- ] API level greater than 30
[ * ] Check if we need to repackage the ramdisk before patching ..
[- ] Multiple cpio archives detected
[ * ] Unpacking ramdisk ..
[ - ] Resetting from 0 to 1418329 ..
Detected format: [lz4_legacy]
[- ] Dumping from 1418329 to 2322258 ..
Detected format: [lz4_legacy]
[*] Repackaging ramdisk ..
[ - ] Check the patch status and perform a restore
[- ] Checking the ramdisk status
[- ] STATUS=0
[- ] A stock boot image was detected
[- ] ramdisk fix
[!] PATCHFSTAB=false
[!] Skipping the fstab.ranchu patch with /dev/block/sda
[?] If you want fstab. ranchu to be fixed, set PATCHFSTAB=true
[!] fix ramdisk with Magisk Init
Loading cpio: [ramdisk.cpio]
Add entry [init] (0750)
Create a directory [overlay.d] (0750)
Create a directory [overlay.d/sbin] (0750)
Add entry [overlay.d/sbin/magisk32. xz] (0644)
Add entry [overlay.d/sbin/magisk64. xz] (0644)
Patch with the KEEPVERITY=[true] KEEPFORCEENCRYPT=[true] flag]
Loading cpio: [ramdisk.cpio. orig]
Backup mismatch record: [init] - > [. backup/init]
Writing a new record: [overlay.d] - > [. backup/.rmlist]
Write a new record: [overlay.d/sbin] - > [. backup/. rmlist]
Write a new record: [overlay.d/sbin/magisk32. xz] - > [. backup/.rmlist]
Write a new record: [overlay.d/sbin/magisk64. xz] - > [. backup/. rmlist]
Create a directory [.backup] (0000)
Add an entry [.backup/.magisk] (0000)
cpio dump: [ramdisk.cpio]
[ * ] repackaging back to ramdisk.img format
[!] Rename Magisk.zip for Magisk.apk
"[-] After the ramdisk file.img will be corrected and compressed,"
"[*] pull it back to Magisk DIR"
/data/data/com.android.shell/Magisk/ramdiskpatched4AVD.img...ile pulled, 0 missed. 65,4 MB/s (2732968 byte 0,040 s)
"[-] pull Magisk.apk apps\"
/data/data/com.android.shell/Magisk/Magisk.apk: 1 file pulled, 0 skipped. 70,1 MB/s (6720493 bytes for 0,091 with)
"[- ] pull the Magisk.zip to applications\ "
adb: error: failed to stat remote object '/data/data/com.android.shell/Magisk/Magisk.zip': No such file or directory
"[ - ] Clear the ADB workspace"
"[ * ] Move and rename the patched ramdisk. img to the original AVD DIR " Files
copied: 1.
"[- ] Install all APK files located in the Apps folder"
"[ * ] Trying to install APPS\Magisk. apk "
Performing a Streaming Installation
Success
"[ - ] restart AVD and see if it worked"
"[ - ] Root and Su with Magisk for Android Studio AVDs"
" [ - ] Modded by NewBit XDA - Jan. 2021"
"[ * ] Huge credits and big thanks to topjohnwu and shakalaca"

My work System:
OS: Windows 10
Android Studio 4.1.3
AVD:Pixel 3, android 11(S) and Nexus5X android 11
Looks totally fine to me. Did you notice this part of the README.md?

How To Use it under Android S with Magisk v22.x​

  • rootAVD needs to run twice
  • 1st - to patch the ramdisk.img
  • 2nd - after Shut-Down & Reboot the AVD:
    • Option 1 - re-run same script command
    • Option 2 - run script with EnvFixTask Argument
      • The "Additional Setup Required" will not be triggered in Android S by Magisk App in AVD,
      • this must be done manually on the 2nd run
      • Grant Shell Su Permissions will pop up a few times
      • rootAVD will reboot the AVD automatically
      • check Magisk App !!
Just run the script a second time with the same parameter and see what happens.
rootAVD.bat %LOCALAPPDATA%\Android\Sdk\system-images\android-S\google_apis_playstore\x86_64\ramdisk.img
 

Apalon3709

New member
Apr 20, 2021
3
0
I have the same problem as the person above, there is no request to provide root. Everything has already been tried nothing helps. Magisk is installed, but there is no request to grant root rights
 

newbit

Senior Member
Nov 16, 2008
141
61
The script ran 1 and 2 times. Nothing helps
That is so weird, I can't reproduce the same behavior on my Windows machine. But it is similar as you wouldn't restart the AVD proper
or a snapshot were loaded. Try to Shut down and Cold Boot the AVD, plus delete all its snapshots.
 

michaelspz

New member
May 3, 2021
2
1
Hello Fellows,

here is a little script, rootAVD, I wrote to root Android Studio Virtual Devices with Magisk.
It is actually just a modified boot_patch.sh from @topjohnwu, which didn't work
for Android 11 (R), so I tried the script from @shakalaca MagiskOnEmulator.
Which didn't work for Android 11 (R) either, so I used his decompression routine to
modify my rootAVD script and now it works with Android 11 (R), Android 10 (Q)
and Android 7 (Nougat) with all the Google Play Store API Versions.
Successfully tested with Stock Kernels on Linux, MacOS and Windows.
All credits go to both of them.

I hope this might come in handy.

Cheers
NewBit

[Update 03.03.2021]
Updated to Magisk App v22.0 and Android 12 (S) Support

[Update 25.03.2021]
Added a Menu to choose the Magisk version to support Android 12 (S) rev 2.

[Update 29.03.2021]
Added Download Manager Function for bad TLS record
Please check out the README.md for "up to date" information.

Requesting for Help!

Please provide the following information If you are asking for support:
  • Host System
  • Android Studio Version
  • AVD Version
  • Magisk Version
  • Terminal input & output
Example Templates:
Host System:
sw_vers
ProductName: Mac OS X
ProductVersion: 10.15.7
Android Studio Version: 4.1.3
AVD Version: Google APIs Intel x86 Atom_64 System Image (revision: 2)
Magisk Version: Stable 22.1
Terminal input & output:
Code:
./rootAVD.sh ~/Library/Android/sdk/system-images/android-S/google_apis/x86_64/ramdisk.img
[!] and we are NOT in an emulator shell
[-] Test if ADB SHELL is working
[-] In any AVD via ADB, you can execute code without root in /data/data/com.android.shell
[-] Magisk installer Zip exists already
[*] Cleaning up the ADB working space
[*] Creating the ADB working space
[-] Copy Magisk installer Zip
[*] ./Magisk.zip: 1 file pushed, 0 skipped. 153.2 MB/s (6720493 bytes in 0.042s)
[*] Set Directorys
[*] create Backup File
[-] Copy the original AVD ramdisk.img into Magisk DIR
[*] /Users/newbit/Library/Android/sdk/system-images/android-S/google_apis/x86_64/ramdisk.img: 1 file pushed, 0 skipped. 286.9 MB/s (2507370 bytes in 0.008s)
[-] Copy rootAVD Script into Magisk DIR
[*] rootAVD.sh: 1 file pushed, 0 skipped. 82.8 MB/s (22575 bytes in 0.000s)
[-] Convert Script to Unix Ending
[-] run the actually Boot/Ramdisk/Kernel Image Patch Script
[*] from Magisk by topjohnwu and modded by NewBit XDA
[!] We are in an emulator shell
[-] Switch to the location of the script file
[*] Extracting busybox and Magisk.zip ...
[-] Checking AVDs Internet connection...
[!] AVD is online
[!] Checking available Magisk Versions
[?] Choose a Magisk Version to install and make it local
[1] Local '22.1' (ENTER)
[2] Canary e136fb3a(22102)
[3] Stable 22.1

[1] You choose Magisk Local Version '22.1'
[*] Re-Run rootAVD in Magisk Busybox STANDALONE (D)ASH
[!] We are in an emulator shell
[-] We are now in Magisk Busybox STANDALONE (D)ASH
[*] rootAVD with Magisk '22.1' Installer
[-] Get Flags
[*] System-as-root, keep dm/avb-verity
[-] Encrypted data, keep forceencrypt
[*] RECOVERYMODE=false
[-] KEEPVERITY=true
[*] KEEPFORCEENCRYPT=true
[-] Api Level Arch Detect
[-] Device Platform: x64
[-] Device SDK API: 30
[-] ARCH32 x86
[-] First API Level: 31
[*] copy all files from /data/data/com.android.shell/Magisk/lib/x86 to /data/data/com.android.shell/Magisk
[*] Detecting ramdisk.img compression
[!] Ramdisk.img uses lz4_legacy compression
[-] taken from shakalaca's MagiskOnEmulator/process.sh
[*] executing ramdisk splitting / extraction / repacking
[-] API level greater then 30
[*] Check if we need to repack ramdisk before patching ..
[-] Multiple cpio archives detected
[*] Unpacking ramdisk ..
[-] Dumping from 0 to 1603441 ..
Detected format: [lz4_legacy]
[-] Dumping from 1603441 to 2507370 ..
Detected format: [lz4_legacy]
[*] Repacking ramdisk ..
[-] Test patch status and do restore
[-] Checking ramdisk status
[-] STATUS=0
[-] Stock boot image detected
[-] Patching ramdisk
[!] PATCHFSTAB=false
[!] Skipping fstab.ranchu patch with /dev/block/sda
[?] If you want fstab.ranchu patched, set PATCHFSTAB=true
[!] patching the ramdisk with Magisk Init
Loading cpio: [ramdisk.cpio]
Add entry [init] (0750)
Create directory [overlay.d] (0750)
Create directory [overlay.d/sbin] (0750)
Add entry [overlay.d/sbin/magisk32.xz] (0644)
Add entry [overlay.d/sbin/magisk64.xz] (0644)
Patch with flag KEEPVERITY=[true] KEEPFORCEENCRYPT=[true]
Loading cpio: [ramdisk.cpio.orig]
Backup mismatch entry: [init] -> [.backup/init]
Record new entry: [overlay.d] -> [.backup/.rmlist]
Record new entry: [overlay.d/sbin] -> [.backup/.rmlist]
Record new entry: [overlay.d/sbin/magisk32.xz] -> [.backup/.rmlist]
Record new entry: [overlay.d/sbin/magisk64.xz] -> [.backup/.rmlist]
Create directory [.backup] (0000)
Add entry [.backup/.magisk] (0000)
Dump cpio: [ramdisk.cpio]
[*] repacking back to ramdisk.img format
[!] Rename Magisk.zip to Magisk.apk
[-] After the ramdisk.img file is patched and compressed,
[*] pull it back in the Magisk DIR
[*] /data/data/com.android.shell/Magisk/ramdiskpatched4AVD.img: 1 file pulled, 0 skipped. 209.3 MB/s (2918094 bytes in 0.013s)
[-] pull Magisk.apk to Apps/
[*] /data/data/com.android.shell/Magisk/Magisk.apk: 1 file pulled, 0 skipped. 236.2 MB/s (6720493 bytes in 0.027s)
[-] pull Magisk.zip to Apps/
[*] adb: error: failed to stat remote object '/data/data/com.android.shell/Magisk/Magisk.zip': No such file or directory
[-] Clean up the ADB working space
[*] Move and rename the patched ramdisk.img to the original AVD DIR
[-] Install all APKs placed in the Apps folder
[*] Trying to install Apps/Magisk.apk
Performing Streamed Install
Success
[-] Shut-Down & Reboot the AVD and see if it worked
[-] Root and Su with Magisk for Android Studio AVDs
[-] Modded by NewBit XDA - Jan. 2021
[!] Huge Credits and big Thanks to topjohnwu and shakalaca
Code:
./rootAVD.sh ~/Library/Android/sdk/system-images/android-S/google_apis/x86_64/ramdisk.img
[!] and we are NOT in an emulator shell
[-] Test if ADB SHELL is working
[-] In any AVD via ADB, you can execute code without root in /data/data/com.android.shell
[-] Magisk installer Zip exists already
[*] Cleaning up the ADB working space
[*] Creating the ADB working space
[-] Copy Magisk installer Zip
[*] ./Magisk.zip: 1 file pushed, 0 skipped. 50.7 MB/s (6720493 bytes in 0.126s)
[*] Set Directorys
[-] Backup exists already
[-] Copy the original AVD ramdisk.img into Magisk DIR
[*] /Users/newbit/Library/Android/sdk/system-images/android-S/google_apis/x86_64/ramdisk.img: 1 file pushed, 0 skipped. 339.1 MB/s (2918094 bytes in 0.008s)
[-] Copy rootAVD Script into Magisk DIR
[*] rootAVD.sh: 1 file pushed, 0 skipped. 104.1 MB/s (22575 bytes in 0.000s)
[-] Convert Script to Unix Ending
[-] run the actually Boot/Ramdisk/Kernel Image Patch Script
[*] from Magisk by topjohnwu and modded by NewBit XDA
[!] We are in an emulator shell
[-] Switch to the location of the script file
[*] Extracting busybox and Magisk.zip ...
[-] Checking AVDs Internet connection...
[!] AVD is online
[!] Checking available Magisk Versions
[?] Choose a Magisk Version to install and make it local
[1] Local '22.1' (ENTER)
[2] Canary e136fb3a(22102)
[3] Stable 22.1

[1] You choose Magisk Local Version '22.1'
[*] Re-Run rootAVD in Magisk Busybox STANDALONE (D)ASH
[!] We are in an emulator shell
[-] We are now in Magisk Busybox STANDALONE (D)ASH
[*] rootAVD with Magisk '22.1' Installer
[-] Get Flags
[*] System-as-root, keep dm/avb-verity
[-] Encrypted data, keep forceencrypt
[*] RECOVERYMODE=false
[-] KEEPVERITY=true
[*] KEEPFORCEENCRYPT=true
[-] Api Level Arch Detect
[-] Device Platform: x64
[-] Device SDK API: 30
[-] ARCH32 x86
[-] First API Level: 31
[*] copy all files from /data/data/com.android.shell/Magisk/lib/x86 to /data/data/com.android.shell/Magisk
[*] Detecting ramdisk.img compression
[!] Ramdisk.img uses lz4_legacy compression
[-] taken from shakalaca's MagiskOnEmulator/process.sh
[*] executing ramdisk splitting / extraction / repacking
[-] API level greater then 30
[*] Check if we need to repack ramdisk before patching ..
[*] After decompressing ramdisk.img, magiskboot will work
Detected format: [lz4_legacy]
[-] Test patch status and do restore
[-] Checking ramdisk status
[-] STATUS=1
[-] Magisk patched boot image detected
[-] Constructing environment - PAY ATTENTION to AVDs Screen
[!] we are root

Also, before you ask, please answer your self the following questions:
  • Did I read AND understood the README.md ?
  • Is my question as detailed and simple as possible couched ?
Also, please include my Username in your Salutation to make sure I will get notice of it.
I love to help, but asking all the time where to pick you up, just increases the time period to get
your issues fixed.
@newbit
I am new to this but I really need to get root access on an android studio device, I have searched a lot of information and read but I don't understand how to do the process. I wonder if you do not have a video tutorial where the process is shown to see the steps to follow. I will be very grateful with your answer.
 

newbit

Senior Member
Nov 16, 2008
141
61
@newbit
I am new to this but I really need to get root access on an android studio device, I have searched a lot of information and read but I don't understand how to do the process. I wonder if you do not have a video tutorial where the process is shown to see the steps to follow. I will be very grateful with your answer.
Hi @michaelspz,
they are too few steps, and they are too simple for a video. Depending on your host system, you just have to
Code:
git clone https://github.com/newbit1/rootAVD.git
or download the script directly and run it.

The new comprehensive Help Menu will guide you through the rest.
 

michaelspz

New member
May 3, 2021
2
1
Hi @michaelspz,
they are too few steps, and they are too simple for a video. Depending on your host system, you just have to
Code:
git clone https://github.com/newbit1/rootAVD.git
or download the script directly and run it.

The new comprehensive Help Menu will guide you through the rest.
@newbit
Thanks for answering, but I still can't do it, what happens is that my previous knowledge in terms of android studio is very little and that's why it has been difficult for me to achieve the process.
My purpose with all this is to create android devices with different fingerprints, different imei, different mac, and I guess I must first have root access on the device.
 
  • Like
Reactions: newbit
Hi newbit, your work is amazing! Sorry for being off-topic and I would like to ask if you have managed to get arm translation working on these AVD images. I'm currently running Android 10, "system-images;android-29;google_apis_playstore;x86_64" and based on the blog post from source.android.com, it seems that they had started adding arm translation into these AVD images from Android 11 and onwards. Any ideas? I would really appreciate to know your side of the story.
 

newbit

Senior Member
Nov 16, 2008
141
61
Hi newbit, your work is amazing! Sorry for being off-topic and I would like to ask if you have managed to get arm translation working on these AVD images. I'm currently running Android 10, "system-images;android-29;google_apis_playstore;x86_64" and based on the blog post from source.android.com, it seems that they had started adding arm translation into these AVD images from Android 11 and onwards. Any ideas? I would really appreciate to know your side of the story.
Hi @Growtopia Jaw,
I am not so sure what exactly you mean by arm translation?! Could you please provide a direct link to that source?

They might be a little confusion regarding the whole ARM AVD situation. So far how I understood it, Google built ARM AVD Images since
the beginning of the Studio with its Emulator. I also had once a Nougat Arm Image that run on my old Macbook 2011, but on
a "newer" one from 2015, it didn't run anymore. And then I've read, that in general the ARM AVD Images were depreciated.

And now it gets even more spongie, with the newer generations of Macbooks, with this M1 Chip, Google generated these new ARM AVD Images,
which are supposed to run only on M1 Devices. With these special images also comes another Issue, that only pure 64 Bit Software can be executed. @shakalaca from the MagiskOnEmulator Script, build especially for that M1 case, arm64 versions of magisk and busybox.
And it worked!

Cheers
NewBit
 
Hi @Growtopia Jaw,
I am not so sure what exactly you mean by arm translation?! Could you please provide a direct link to that source?

And now it gets even more spongie, with the newer generations of Macbooks, with this M1 Chip, Google generated these new ARM AVD Images,
which are supposed to run only on M1 Devices. With these special images also comes another Issue, that only pure 64 Bit Software can be executed. @shakalaca from the MagiskOnEmulator Script, build especially for that M1 case, arm64 versions of magisk and busybox.
And it worked!

Cheers
NewBit

Sorry for the unclear post. What I meant was that Google never added an "official" way to run arm binaries on x86_64 based AVD images. It seems that based on some work by others, Google only added official arm native bridge support to the Nexus Player which runs on an Intel Atom Z3560. This meant that even though it had an x86_64 processor, it could run arm binaries without any issue.

Beginning with Android 11, Google announced that they would add support for arm native bridge on x86_64 based AVD images here.

Some people have managed to integrate these arm native bridge libraries into an x86_64 Android image by using a system partition overlay.

From anbox-image-gapps-magisk,

Bash:
    # set processors
    sed -i '/^ro.product.cpu.abilist=x86_64,x86/ s/$/,arm64-v8a,armeabi-v7a,armeabi/' ./squashfs-root/system/build.prop
    sed -i '/^ro.product.cpu.abilist32=x86/ s/$/,armeabi-v7a,armeabi/' ./squashfs-root/system/build.prop
    sed -i '/^ro.product.cpu.abilist64=x86_64/ s/$/,arm64-v8a/' ./squashfs-root/system/build.prop

arm binary translation is added to x86_64 Android images with support for armv5 all the way to armv8.

I have tried different methods of integrating these libraries into Google's Android 10 x86_64 AVD image but still haven't managed to do so successfully. I hope this post would clarify the post I made above.

They might be a little confusion regarding the whole ARM AVD situation. So far how I understood it, Google built ARM AVD Images since
the beginning of the Studio with its Emulator. I also had once a Nougat Arm Image that run on my old Macbook 2011, but on
a "newer" one from 2015, it didn't run anymore. And then I've read, that in general the ARM AVD Images were depreciated.

From my recollection, I think I had never succeeded in running Google built arm AVD images on my laptop, it might be because I used an old version of the emulator or something as the last time I tested an arm AVD image was about 3 years ago? 😅

Thanks!
 
Last edited:

newbit

Senior Member
Nov 16, 2008
141
61
Sorry for the unclear post. What I meant was that Google never added an "official" way to run arm binaries on x86_64 based AVD images. It seems that based on some work by others, Google only added official arm native bridge support to the Nexus Player which runs on an Intel Atom Z3560. This meant that even though it had an x86_64 processor, it could run arm binaries without any issue.

Beginning with Android 11, Google announced that they would add support for arm native bridge on x86_64 based AVD images here.

Some people have managed to integrate these arm native bridge libraries into an x86_64 Android image by using a system partition overlay.

From anbox-image-gapps-magisk,

Bash:
    # set processors
    sed -i '/^ro.product.cpu.abilist=x86_64,x86/ s/$/,arm64-v8a,armeabi-v7a,armeabi/' ./squashfs-root/system/build.prop
    sed -i '/^ro.product.cpu.abilist32=x86/ s/$/,armeabi-v7a,armeabi/' ./squashfs-root/system/build.prop
    sed -i '/^ro.product.cpu.abilist64=x86_64/ s/$/,arm64-v8a/' ./squashfs-root/system/build.prop

arm binary translation is added to x86_64 Android images with support for armv5 all the way to armv8.

I have tried different methods of integrating these libraries into Google's Android 10 x86_64 AVD image but still haven't managed to do so successfully. I hope this post would clarify the post I made above.



From my recollection, I think I had never succeeded in running Google built arm AVD images on my laptop, it might be because I used an old version of the emulator or something as the last time I tested an arm AVD image was about 3 years ago? 😅

Thanks!
No need to sorry, I have to apologise. I had no clue about this at all. So in short, it is an emulator within an emulator which is called
a translator. Well, who had thought about that?!

Your goal is to "transfer" this arm translator capabilities from an AVD which has it already build in, to another one that doesn't?
This is bit out of the scope of rootAVD, but it is very interesting though. My first look would be into the image sources of that AVD, to see
If I can find some sort of isolated packages regarding that topic. If it is really "just" some configs plus libs, I would create a Magisk Module
for that task. But talking between architectures, I would expect that the Kernel of that engine has a lot to say as well. So there might
be some digging necessary to figure out what exactly is needed to accomplish this.

I took a little look into three running AVDs, Android 10 (Q) API 29, Android 11 (R) API 30 and Android 12 (preview rev 3) API S
Bash:
generic_x86_64:/ # getprop | grep abi
[ro.odm.product.cpu.abilist]: [x86_64,x86]
[ro.odm.product.cpu.abilist32]: [x86]
[ro.odm.product.cpu.abilist64]: [x86_64]
[ro.product.cpu.abi]: [x86_64]
[ro.product.cpu.abilist]: [x86_64,x86]
[ro.product.cpu.abilist32]: [x86]
[ro.product.cpu.abilist64]: [x86_64]
[ro.vendor.product.cpu.abilist]: [x86_64,x86]
[ro.vendor.product.cpu.abilist32]: [x86]
[ro.vendor.product.cpu.abilist64]: [x86_64]

Bash:
generic_x86_64_arm64:/ # getprop | grep abi                                                                                                         
[ro.odm.product.cpu.abilist]: [x86_64,x86,arm64-v8a,armeabi-v7a,armeabi]
[ro.odm.product.cpu.abilist32]: [x86,armeabi-v7a,armeabi]
[ro.odm.product.cpu.abilist64]: [x86_64,arm64-v8a]
[ro.product.cpu.abi]: [x86_64]
[ro.product.cpu.abilist]: [x86_64,x86,arm64-v8a,armeabi-v7a,armeabi]
[ro.product.cpu.abilist32]: [x86,armeabi-v7a,armeabi]
[ro.product.cpu.abilist64]: [x86_64,arm64-v8a]
[ro.vendor.product.cpu.abilist]: [x86_64,x86,arm64-v8a,armeabi-v7a,armeabi]
[ro.vendor.product.cpu.abilist32]: [x86,armeabi-v7a,armeabi]
[ro.vendor.product.cpu.abilist64]: [x86_64,arm64-v8a]

Bash:
emulator64_x86_64_arm64:/ # getprop | grep abi
[ro.odm.product.cpu.abilist]: [x86_64,arm64-v8a]
[ro.odm.product.cpu.abilist32]: []
[ro.odm.product.cpu.abilist64]: [x86_64,arm64-v8a]
[ro.product.cpu.abi]: [x86_64]
[ro.product.cpu.abilist]: [x86_64,arm64-v8a]
[ro.product.cpu.abilist32]: []
[ro.product.cpu.abilist64]: [x86_64,arm64-v8a]
[ro.system.product.cpu.abilist]: [x86_64,arm64-v8a]
[ro.system.product.cpu.abilist32]: []
[ro.system.product.cpu.abilist64]: [x86_64,arm64-v8a]
[ro.vendor.product.cpu.abilist]: [x86_64,arm64-v8a]
[ro.vendor.product.cpu.abilist32]: []
[ro.vendor.product.cpu.abilist64]: [x86_64,arm64-v8a]

I did not even notice these difference before. A quick test also showed,
that APKs build for armeabi-v7a and arm64-v8a,
could be installed and run on Android 11 (R), but not on Android 10 (Q).
APKs build for arm64-v8a could be installed and run on Android 12 (S).

But, when I extracted the busybox for armeabi-v7a, it doesn't run and gives me an error:
Bash:
generic_x86_64_arm64:/data/data/com.android.shell/Magisk $ ./busybox                                                                                     
Error running ./busybox: couldn\'t reserve 1277952 bytes of address space at 0x8000 for "/data/data/com.android.shell/Magisk/busybox"
255|generic_x86_64_arm64:/data/data/com.android.shell/Magisk $

Bash:
emulator64_x86_64_arm64:/data/data/com.android.shell/Magisk # ./busybox                                                                                             
/system/bin/sh: ./busybox: No such file or directory
126|emulator64_x86_64_arm64:/data/data/com.android.shell/Magisk # ls -l
total 16892
-rwxr-xr-x 1 shell shell   13116 2021-05-08 13:33 AndroidManifest.xml
drwxr-xr-x 4 shell shell    4096 2021-05-08 13:33 META-INF
-rwxr-xr-x 1 shell shell 6720493 2021-05-07 20:05 Magisk.zip
drwxr-xr-x 3 shell shell    4096 2021-05-08 13:33 assets
-rwxr-xr-x 1 shell shell 1248676 2021-05-08 13:33 busybox
-rwxr-xr-x 1 shell shell 3064400 2021-05-08 13:33 classes.dex
drwxr-xr-x 6 shell shell    4096 2021-05-08 13:33 lib
drwxr-xr-x 3 shell shell    4096 2021-05-08 13:33 org
-rwxr-xr-x 1 shell shell 2799673 2021-05-08 13:26 ramdisk.img
drwxr-xr-x 7 shell shell   24576 2021-05-08 13:33 res
-rwxr-xr-x 1 shell shell 1346756 2021-05-08 13:33 resources.arsc
-rwxr-xr-x 1 shell shell 1994828 2021-05-08 13:33 rootAVD.sh
emulator64_x86_64_arm64:/data/data/com.android.shell/Magisk #

May I ask, why you want to port that feature to a lower Android Version? It looks pretty convenient to me that it already works in Android 11 and 12.

Cheers NewBit
 
No need to sorry, I have to apologise. I had no clue about this at all. So in short, it is an emulator within an emulator which is called
a translator. Well, who had thought about that?!

Well, I had never thought of the translator as an emulator per se. But now that you've mentioned it, it might probably be an emulator!

To be honest, I only noticed that such a "translator" existed when I first used an Android OS on my laptop known as the Android-x86.org project. Some people do run Android OS on their computers and I think they might be the first (don't quote me on this) to implement such a "translator" onto x86_64 based Android OSes. Maybe sometime we wouldn't notice such things but the translator played a big role in the x86_64 Android space.

Your goal is to "transfer" this arm translator capabilities from an AVD which has it already build in, to another one that doesn't?
This is bit out of the scope of rootAVD, but it is very interesting though. My first look would be into the image sources of that AVD, to see
If I can find some sort of isolated packages regarding that topic. If it is really "just" some configs plus libs, I would create a Magisk Module
for that task. But talking between architectures, I would expect that the Kernel of that engine has a lot to say as well. So there might
be some digging necessary to figure out what exactly is needed to accomplish this.

Not to say that transferring the arm native bridge capabilities from an AVD image that already has this capability was my goal but I would think of it as adding arm support to Google's AVD image as proven by the Android-x86.org project, Genymotion Android Emulator and other emulators that it could be done. It seems trying different methods of integrating these "libs" wouldn't work for now.

I took a little look into three running AVDs, Android 10 (Q) API 29, Android 11 (R) API 30 and Android 12 (preview rev 3) API S


Bash:
generic_x86_64:/ # getprop | grep abi
[ro.odm.product.cpu.abilist]: [x86_64,x86]
[ro.odm.product.cpu.abilist32]: [x86]
[ro.odm.product.cpu.abilist64]: [x86_64]
[ro.product.cpu.abi]: [x86_64]
[ro.product.cpu.abilist]: [x86_64,x86]
[ro.product.cpu.abilist32]: [x86]
[ro.product.cpu.abilist64]: [x86_64]
[ro.vendor.product.cpu.abilist]: [x86_64,x86]
[ro.vendor.product.cpu.abilist32]: [x86]
[ro.vendor.product.cpu.abilist64]: [x86_64]


Bash:
generic_x86_64_arm64:/ # getprop | grep abi                                                                                                        
[ro.odm.product.cpu.abilist]: [x86_64,x86,arm64-v8a,armeabi-v7a,armeabi]
[ro.odm.product.cpu.abilist32]: [x86,armeabi-v7a,armeabi]
[ro.odm.product.cpu.abilist64]: [x86_64,arm64-v8a]
[ro.product.cpu.abi]: [x86_64]
[ro.product.cpu.abilist]: [x86_64,x86,arm64-v8a,armeabi-v7a,armeabi]
[ro.product.cpu.abilist32]: [x86,armeabi-v7a,armeabi]
[ro.product.cpu.abilist64]: [x86_64,arm64-v8a]
[ro.vendor.product.cpu.abilist]: [x86_64,x86,arm64-v8a,armeabi-v7a,armeabi]
[ro.vendor.product.cpu.abilist32]: [x86,armeabi-v7a,armeabi]
[ro.vendor.product.cpu.abilist64]: [x86_64,arm64-v8a]



Bash:
emulator64_x86_64_arm64:/ # getprop | grep abi
[ro.odm.product.cpu.abilist]: [x86_64,arm64-v8a]
[ro.odm.product.cpu.abilist32]: []
[ro.odm.product.cpu.abilist64]: [x86_64,arm64-v8a]
[ro.product.cpu.abi]: [x86_64]
[ro.product.cpu.abilist]: [x86_64,arm64-v8a]
[ro.product.cpu.abilist32]: []
[ro.product.cpu.abilist64]: [x86_64,arm64-v8a]
[ro.system.product.cpu.abilist]: [x86_64,arm64-v8a]
[ro.system.product.cpu.abilist32]: []
[ro.system.product.cpu.abilist64]: [x86_64,arm64-v8a]
[ro.vendor.product.cpu.abilist]: [x86_64,arm64-v8a]
[ro.vendor.product.cpu.abilist32]: []
[ro.vendor.product.cpu.abilist64]: [x86_64,arm64-v8a]

I did not even notice these difference before. A quick test also showed,
that APKs build for armeabi-v7a and arm64-v8a,
could be installed and run on Android 11 (R), but not on Android 10 (Q).
APKs build for arm64-v8a could be installed and run on Android 12 (S).

But, when I extracted the busybox for armeabi-v7a, it doesn't run and gives me an error:


Bash:
generic_x86_64_arm64:/data/data/com.android.shell/Magisk $ ./busybox                                                                                    
Error running ./busybox: couldn\'t reserve 1277952 bytes of address space at 0x8000 for "/data/data/com.android.shell/Magisk/busybox"
255|generic_x86_64_arm64:/data/data/com.android.shell/Magisk 
$


Bash:
emulator64_x86_64_arm64:/data/data/com.android.shell/Magisk # ./busybox                                                                                            
/system/bin/sh: ./busybox: No such file or directory
126|emulator64_x86_64_arm64:/data/data/com.android.shell/Magisk # ls -l
total 16892
-rwxr-xr-x 1 shell shell   13116 2021-05-08 13:33 AndroidManifest.xml
drwxr-xr-x 4 shell shell    4096 2021-05-08 13:33 META-INF
-rwxr-xr-x 1 shell shell 6720493 2021-05-07 20:05 Magisk.zip
drwxr-xr-x 3 shell shell    4096 2021-05-08 13:33 assets
-rwxr-xr-x 1 shell shell 1248676 2021-05-08 13:33 busybox
-rwxr-xr-x 1 shell shell 3064400 2021-05-08 13:33 classes.dex
drwxr-xr-x 6 shell shell    4096 2021-05-08 13:33 lib
drwxr-xr-x 3 shell shell    4096 2021-05-08 13:33 org
-rwxr-xr-x 1 shell shell 2799673 2021-05-08 13:26 ramdisk.img
drwxr-xr-x 7 shell shell   24576 2021-05-08 13:33 res
-rwxr-xr-x 1 shell shell 1346756 2021-05-08 13:33 resources.arsc
-rwxr-xr-x 1 shell shell 1994828 2021-05-08 13:33 rootAVD.sh
emulator64_x86_64_arm64:/data/data/com.android.shell/Magisk #

Yeah, I've noticed this exact behaviour at least on my Android 10 AVD image. I never had the chance to test these behaviour on Android 11 and 12. Your findings would definitely be useful to others and myself. I really appreciate it!

May I ask, why you want to port that feature to a lower Android Version? It looks pretty convenient to me that it already works in Android 11 and 12.

My main reason is that Android 11 and 12 is considered to be "too new" for now. Most physical Android smartphones and tablets still run Android 10. There might be some Android 11 smartphones out there but the market share might currently be below 1%. Based on past experiences, newer Android versions might not work well even with some apps that are actively being developed. I think developers tend to target Android API levels that are most being used currently on the market. Android 10 seems to be the latest and safest Android version to use right now.

I guess I have to use Android 11 if I'm going to need arm translation built into these AVD images to run arm APKs.

I would like to thank you for your time and I truly appreciate it!
 
  • Like
Reactions: newbit

newbit

Senior Member
Nov 16, 2008
141
61
Well, I had never thought of the translator as an emulator per se. But now that you've mentioned it, it might probably be an emulator!

To be honest, I only noticed that such a "translator" existed when I first used an Android OS on my laptop known as the Android-x86.org project. Some people do run Android OS on their computers and I think they might be the first (don't quote me on this) to implement such a "translator" onto x86_64 based Android OSes. Maybe sometime we wouldn't notice such things but the translator played a big role in the x86_64 Android space.



Not to say that transferring the arm native bridge capabilities from an AVD image that already has this capability was my goal but I would think of it as adding arm support to Google's AVD image as proven by the Android-x86.org project, Genymotion Android Emulator and other emulators that it could be done. It seems trying different methods of integrating these "libs" wouldn't work for now.



Yeah, I've noticed this exact behaviour at least on my Android 10 AVD image. I never had the chance to test these behaviour on Android 11 and 12. Your findings would definitely be useful to others and myself. I really appreciate it!



My main reason is that Android 11 and 12 is considered to be "too new" for now. Most physical Android smartphones and tablets still run Android 10. There might be some Android 11 smartphones out there but the market share might currently be below 1%. Based on past experiences, newer Android versions might not work well even with some apps that are actively being developed. I think developers tend to target Android API levels that are most being used currently on the market. Android 10 seems to be the latest and safest Android version to use right now.

I guess I have to use Android 11 if I'm going to need arm translation built into these AVD images to run arm APKs.

I would like to thank you for your time and I truly appreciate it!

As a quick & dirty solution, I've created a Magisk Module.
libndk_translation_Module repo
Inside you will find a *.rc file, ndk_translation_arm64.rc , which needs to be installed into the
ramdisk with magisk. I've updated rootAVD accordingly.
After both, I can install now armeabi-v7a and arm64-v8a APKs on an Android 10 AVD.
But the arm64-v8a runs very slow and crashes. The armeabi-v7a works fine.
It might not be perfect, but a good start. I've noticed that odm and vendor props are now missing.
So there is definitely some space to play open.

All credits go actually to remote-android with its native_bridge repo
He published a nice oneliner to gather all files for the magisk module.

[Update 10.05.2021]
My apologies again, I made a mistake. I did not notice that I accidentally ran Android 11 to test the libndk Module.
I noticed this already a few times, that If another AVD is marked, but a different AVD is clicked on Play, it still does
run the marked AVD. I've added an If ro.build.version.release=10 to the customize.sh, to make sure it gets not installed on the wrong AVD.

With the right AVD, Android 10 API 29, it turns out not to run at all in this base setup. There were some permissions and
executions issue with the .rc script. Hence, I put this also inside the module in service.sh. It was just one mount and 4 copies.

After this, the 2 runner binaries gave me the error:
cannot locate symbol "__android_log_set_logger"

The __android_log_set_logger symbol belongs to the liblog.so, and is available since API level 30.
I've added the two liblog.so in the libndk module as well, and finally the error is gone, and armeabi-v7a and arm64-v8a APKs
can be installed, but only the armeabi-v7a does not crash.
Unfortunately due to this newer liblog.so, it breaks the ADB connection, again because of some symbols are missing in the adbd
binaries. To test your arm APKs you have to push them to the AVD before you enable the module. And then install them from within
the running AVD.

In short: libndk translation module works now, with armeabi-v7a, but it breaks the ADB.

Cheers
NewBit
 
Last edited:
  • Like
Reactions: Growtopia Jaw

Top Liked Posts

  • There are no posts matching your filters.
  • 1
    Hi @michaelspz,
    they are too few steps, and they are too simple for a video. Depending on your host system, you just have to
    Code:
    git clone https://github.com/newbit1/rootAVD.git
    or download the script directly and run it.

    The new comprehensive Help Menu will guide you through the rest.
    @newbit
    Thanks for answering, but I still can't do it, what happens is that my previous knowledge in terms of android studio is very little and that's why it has been difficult for me to achieve the process.
    My purpose with all this is to create android devices with different fingerprints, different imei, different mac, and I guess I must first have root access on the device.
    1
    No need to sorry, I have to apologise. I had no clue about this at all. So in short, it is an emulator within an emulator which is called
    a translator. Well, who had thought about that?!

    Well, I had never thought of the translator as an emulator per se. But now that you've mentioned it, it might probably be an emulator!

    To be honest, I only noticed that such a "translator" existed when I first used an Android OS on my laptop known as the Android-x86.org project. Some people do run Android OS on their computers and I think they might be the first (don't quote me on this) to implement such a "translator" onto x86_64 based Android OSes. Maybe sometime we wouldn't notice such things but the translator played a big role in the x86_64 Android space.

    Your goal is to "transfer" this arm translator capabilities from an AVD which has it already build in, to another one that doesn't?
    This is bit out of the scope of rootAVD, but it is very interesting though. My first look would be into the image sources of that AVD, to see
    If I can find some sort of isolated packages regarding that topic. If it is really "just" some configs plus libs, I would create a Magisk Module
    for that task. But talking between architectures, I would expect that the Kernel of that engine has a lot to say as well. So there might
    be some digging necessary to figure out what exactly is needed to accomplish this.

    Not to say that transferring the arm native bridge capabilities from an AVD image that already has this capability was my goal but I would think of it as adding arm support to Google's AVD image as proven by the Android-x86.org project, Genymotion Android Emulator and other emulators that it could be done. It seems trying different methods of integrating these "libs" wouldn't work for now.

    I took a little look into three running AVDs, Android 10 (Q) API 29, Android 11 (R) API 30 and Android 12 (preview rev 3) API S


    Bash:
    generic_x86_64:/ # getprop | grep abi
    [ro.odm.product.cpu.abilist]: [x86_64,x86]
    [ro.odm.product.cpu.abilist32]: [x86]
    [ro.odm.product.cpu.abilist64]: [x86_64]
    [ro.product.cpu.abi]: [x86_64]
    [ro.product.cpu.abilist]: [x86_64,x86]
    [ro.product.cpu.abilist32]: [x86]
    [ro.product.cpu.abilist64]: [x86_64]
    [ro.vendor.product.cpu.abilist]: [x86_64,x86]
    [ro.vendor.product.cpu.abilist32]: [x86]
    [ro.vendor.product.cpu.abilist64]: [x86_64]


    Bash:
    generic_x86_64_arm64:/ # getprop | grep abi                                                                                                        
    [ro.odm.product.cpu.abilist]: [x86_64,x86,arm64-v8a,armeabi-v7a,armeabi]
    [ro.odm.product.cpu.abilist32]: [x86,armeabi-v7a,armeabi]
    [ro.odm.product.cpu.abilist64]: [x86_64,arm64-v8a]
    [ro.product.cpu.abi]: [x86_64]
    [ro.product.cpu.abilist]: [x86_64,x86,arm64-v8a,armeabi-v7a,armeabi]
    [ro.product.cpu.abilist32]: [x86,armeabi-v7a,armeabi]
    [ro.product.cpu.abilist64]: [x86_64,arm64-v8a]
    [ro.vendor.product.cpu.abilist]: [x86_64,x86,arm64-v8a,armeabi-v7a,armeabi]
    [ro.vendor.product.cpu.abilist32]: [x86,armeabi-v7a,armeabi]
    [ro.vendor.product.cpu.abilist64]: [x86_64,arm64-v8a]



    Bash:
    emulator64_x86_64_arm64:/ # getprop | grep abi
    [ro.odm.product.cpu.abilist]: [x86_64,arm64-v8a]
    [ro.odm.product.cpu.abilist32]: []
    [ro.odm.product.cpu.abilist64]: [x86_64,arm64-v8a]
    [ro.product.cpu.abi]: [x86_64]
    [ro.product.cpu.abilist]: [x86_64,arm64-v8a]
    [ro.product.cpu.abilist32]: []
    [ro.product.cpu.abilist64]: [x86_64,arm64-v8a]
    [ro.system.product.cpu.abilist]: [x86_64,arm64-v8a]
    [ro.system.product.cpu.abilist32]: []
    [ro.system.product.cpu.abilist64]: [x86_64,arm64-v8a]
    [ro.vendor.product.cpu.abilist]: [x86_64,arm64-v8a]
    [ro.vendor.product.cpu.abilist32]: []
    [ro.vendor.product.cpu.abilist64]: [x86_64,arm64-v8a]

    I did not even notice these difference before. A quick test also showed,
    that APKs build for armeabi-v7a and arm64-v8a,
    could be installed and run on Android 11 (R), but not on Android 10 (Q).
    APKs build for arm64-v8a could be installed and run on Android 12 (S).

    But, when I extracted the busybox for armeabi-v7a, it doesn't run and gives me an error:


    Bash:
    generic_x86_64_arm64:/data/data/com.android.shell/Magisk $ ./busybox                                                                                    
    Error running ./busybox: couldn\'t reserve 1277952 bytes of address space at 0x8000 for "/data/data/com.android.shell/Magisk/busybox"
    255|generic_x86_64_arm64:/data/data/com.android.shell/Magisk 
    $


    Bash:
    emulator64_x86_64_arm64:/data/data/com.android.shell/Magisk # ./busybox                                                                                            
    /system/bin/sh: ./busybox: No such file or directory
    126|emulator64_x86_64_arm64:/data/data/com.android.shell/Magisk # ls -l
    total 16892
    -rwxr-xr-x 1 shell shell   13116 2021-05-08 13:33 AndroidManifest.xml
    drwxr-xr-x 4 shell shell    4096 2021-05-08 13:33 META-INF
    -rwxr-xr-x 1 shell shell 6720493 2021-05-07 20:05 Magisk.zip
    drwxr-xr-x 3 shell shell    4096 2021-05-08 13:33 assets
    -rwxr-xr-x 1 shell shell 1248676 2021-05-08 13:33 busybox
    -rwxr-xr-x 1 shell shell 3064400 2021-05-08 13:33 classes.dex
    drwxr-xr-x 6 shell shell    4096 2021-05-08 13:33 lib
    drwxr-xr-x 3 shell shell    4096 2021-05-08 13:33 org
    -rwxr-xr-x 1 shell shell 2799673 2021-05-08 13:26 ramdisk.img
    drwxr-xr-x 7 shell shell   24576 2021-05-08 13:33 res
    -rwxr-xr-x 1 shell shell 1346756 2021-05-08 13:33 resources.arsc
    -rwxr-xr-x 1 shell shell 1994828 2021-05-08 13:33 rootAVD.sh
    emulator64_x86_64_arm64:/data/data/com.android.shell/Magisk #

    Yeah, I've noticed this exact behaviour at least on my Android 10 AVD image. I never had the chance to test these behaviour on Android 11 and 12. Your findings would definitely be useful to others and myself. I really appreciate it!

    May I ask, why you want to port that feature to a lower Android Version? It looks pretty convenient to me that it already works in Android 11 and 12.

    My main reason is that Android 11 and 12 is considered to be "too new" for now. Most physical Android smartphones and tablets still run Android 10. There might be some Android 11 smartphones out there but the market share might currently be below 1%. Based on past experiences, newer Android versions might not work well even with some apps that are actively being developed. I think developers tend to target Android API levels that are most being used currently on the market. Android 10 seems to be the latest and safest Android version to use right now.

    I guess I have to use Android 11 if I'm going to need arm translation built into these AVD images to run arm APKs.

    I would like to thank you for your time and I truly appreciate it!
    1
    Well, I had never thought of the translator as an emulator per se. But now that you've mentioned it, it might probably be an emulator!

    To be honest, I only noticed that such a "translator" existed when I first used an Android OS on my laptop known as the Android-x86.org project. Some people do run Android OS on their computers and I think they might be the first (don't quote me on this) to implement such a "translator" onto x86_64 based Android OSes. Maybe sometime we wouldn't notice such things but the translator played a big role in the x86_64 Android space.



    Not to say that transferring the arm native bridge capabilities from an AVD image that already has this capability was my goal but I would think of it as adding arm support to Google's AVD image as proven by the Android-x86.org project, Genymotion Android Emulator and other emulators that it could be done. It seems trying different methods of integrating these "libs" wouldn't work for now.



    Yeah, I've noticed this exact behaviour at least on my Android 10 AVD image. I never had the chance to test these behaviour on Android 11 and 12. Your findings would definitely be useful to others and myself. I really appreciate it!



    My main reason is that Android 11 and 12 is considered to be "too new" for now. Most physical Android smartphones and tablets still run Android 10. There might be some Android 11 smartphones out there but the market share might currently be below 1%. Based on past experiences, newer Android versions might not work well even with some apps that are actively being developed. I think developers tend to target Android API levels that are most being used currently on the market. Android 10 seems to be the latest and safest Android version to use right now.

    I guess I have to use Android 11 if I'm going to need arm translation built into these AVD images to run arm APKs.

    I would like to thank you for your time and I truly appreciate it!

    As a quick & dirty solution, I've created a Magisk Module.
    libndk_translation_Module repo
    Inside you will find a *.rc file, ndk_translation_arm64.rc , which needs to be installed into the
    ramdisk with magisk. I've updated rootAVD accordingly.
    After both, I can install now armeabi-v7a and arm64-v8a APKs on an Android 10 AVD.
    But the arm64-v8a runs very slow and crashes. The armeabi-v7a works fine.
    It might not be perfect, but a good start. I've noticed that odm and vendor props are now missing.
    So there is definitely some space to play open.

    All credits go actually to remote-android with its native_bridge repo
    He published a nice oneliner to gather all files for the magisk module.

    [Update 10.05.2021]
    My apologies again, I made a mistake. I did not notice that I accidentally ran Android 11 to test the libndk Module.
    I noticed this already a few times, that If another AVD is marked, but a different AVD is clicked on Play, it still does
    run the marked AVD. I've added an If ro.build.version.release=10 to the customize.sh, to make sure it gets not installed on the wrong AVD.

    With the right AVD, Android 10 API 29, it turns out not to run at all in this base setup. There were some permissions and
    executions issue with the .rc script. Hence, I put this also inside the module in service.sh. It was just one mount and 4 copies.

    After this, the 2 runner binaries gave me the error:
    cannot locate symbol "__android_log_set_logger"

    The __android_log_set_logger symbol belongs to the liblog.so, and is available since API level 30.
    I've added the two liblog.so in the libndk module as well, and finally the error is gone, and armeabi-v7a and arm64-v8a APKs
    can be installed, but only the armeabi-v7a does not crash.
    Unfortunately due to this newer liblog.so, it breaks the ADB connection, again because of some symbols are missing in the adbd
    binaries. To test your arm APKs you have to push them to the AVD before you enable the module. And then install them from within
    the running AVD.

    In short: libndk translation module works now, with armeabi-v7a, but it breaks the ADB.

    Cheers
    NewBit
  • 4
    Hello Fellows,

    here is a little script, rootAVD, I wrote to root Android Studio Virtual Devices with Magisk.
    It is actually just a modified boot_patch.sh from @topjohnwu, which didn't work
    for Android 11 (R), so I tried the script from @shakalaca MagiskOnEmulator.
    Which didn't work for Android 11 (R) either, so I used his decompression routine to
    modify my rootAVD script and now it works with Android 11 (R), Android 10 (Q)
    and Android 7 (Nougat) with all the Google Play Store API Versions.
    Successfully tested with Stock Kernels on Linux, MacOS and Windows.
    All credits go to both of them.

    I hope this might come in handy.

    Cheers
    NewBit

    [Update 03.03.2021]
    Updated to Magisk App v22.0 and Android 12 (S) Support

    [Update 25.03.2021]
    Added a Menu to choose the Magisk version to support Android 12 (S) rev 2.

    [Update 29.03.2021]
    Added Download Manager Function for bad TLS record
    Please check out the README.md for "up to date" information.

    Requesting for Help!

    Please provide the following information If you are asking for support:
    • Host System
    • Android Studio Version
    • AVD Version
    • Magisk Version
    • Terminal input & output
    Example Templates:
    Host System:
    sw_vers
    ProductName: Mac OS X
    ProductVersion: 10.15.7
    Android Studio Version: 4.1.3
    AVD Version: Google APIs Intel x86 Atom_64 System Image (revision: 2)
    Magisk Version: Stable 22.1
    Terminal input & output:
    Code:
    ./rootAVD.sh ~/Library/Android/sdk/system-images/android-S/google_apis/x86_64/ramdisk.img
    [!] and we are NOT in an emulator shell
    [-] Test if ADB SHELL is working
    [-] In any AVD via ADB, you can execute code without root in /data/data/com.android.shell
    [-] Magisk installer Zip exists already
    [*] Cleaning up the ADB working space
    [*] Creating the ADB working space
    [-] Copy Magisk installer Zip
    [*] ./Magisk.zip: 1 file pushed, 0 skipped. 153.2 MB/s (6720493 bytes in 0.042s)
    [*] Set Directorys
    [*] create Backup File
    [-] Copy the original AVD ramdisk.img into Magisk DIR
    [*] /Users/newbit/Library/Android/sdk/system-images/android-S/google_apis/x86_64/ramdisk.img: 1 file pushed, 0 skipped. 286.9 MB/s (2507370 bytes in 0.008s)
    [-] Copy rootAVD Script into Magisk DIR
    [*] rootAVD.sh: 1 file pushed, 0 skipped. 82.8 MB/s (22575 bytes in 0.000s)
    [-] Convert Script to Unix Ending
    [-] run the actually Boot/Ramdisk/Kernel Image Patch Script
    [*] from Magisk by topjohnwu and modded by NewBit XDA
    [!] We are in an emulator shell
    [-] Switch to the location of the script file
    [*] Extracting busybox and Magisk.zip ...
    [-] Checking AVDs Internet connection...
    [!] AVD is online
    [!] Checking available Magisk Versions
    [?] Choose a Magisk Version to install and make it local
    [1] Local '22.1' (ENTER)
    [2] Canary e136fb3a(22102)
    [3] Stable 22.1
    
    [1] You choose Magisk Local Version '22.1'
    [*] Re-Run rootAVD in Magisk Busybox STANDALONE (D)ASH
    [!] We are in an emulator shell
    [-] We are now in Magisk Busybox STANDALONE (D)ASH
    [*] rootAVD with Magisk '22.1' Installer
    [-] Get Flags
    [*] System-as-root, keep dm/avb-verity
    [-] Encrypted data, keep forceencrypt
    [*] RECOVERYMODE=false
    [-] KEEPVERITY=true
    [*] KEEPFORCEENCRYPT=true
    [-] Api Level Arch Detect
    [-] Device Platform: x64
    [-] Device SDK API: 30
    [-] ARCH32 x86
    [-] First API Level: 31
    [*] copy all files from /data/data/com.android.shell/Magisk/lib/x86 to /data/data/com.android.shell/Magisk
    [*] Detecting ramdisk.img compression
    [!] Ramdisk.img uses lz4_legacy compression
    [-] taken from shakalaca's MagiskOnEmulator/process.sh
    [*] executing ramdisk splitting / extraction / repacking
    [-] API level greater then 30
    [*] Check if we need to repack ramdisk before patching ..
    [-] Multiple cpio archives detected
    [*] Unpacking ramdisk ..
    [-] Dumping from 0 to 1603441 ..
    Detected format: [lz4_legacy]
    [-] Dumping from 1603441 to 2507370 ..
    Detected format: [lz4_legacy]
    [*] Repacking ramdisk ..
    [-] Test patch status and do restore
    [-] Checking ramdisk status
    [-] STATUS=0
    [-] Stock boot image detected
    [-] Patching ramdisk
    [!] PATCHFSTAB=false
    [!] Skipping fstab.ranchu patch with /dev/block/sda
    [?] If you want fstab.ranchu patched, set PATCHFSTAB=true
    [!] patching the ramdisk with Magisk Init
    Loading cpio: [ramdisk.cpio]
    Add entry [init] (0750)
    Create directory [overlay.d] (0750)
    Create directory [overlay.d/sbin] (0750)
    Add entry [overlay.d/sbin/magisk32.xz] (0644)
    Add entry [overlay.d/sbin/magisk64.xz] (0644)
    Patch with flag KEEPVERITY=[true] KEEPFORCEENCRYPT=[true]
    Loading cpio: [ramdisk.cpio.orig]
    Backup mismatch entry: [init] -> [.backup/init]
    Record new entry: [overlay.d] -> [.backup/.rmlist]
    Record new entry: [overlay.d/sbin] -> [.backup/.rmlist]
    Record new entry: [overlay.d/sbin/magisk32.xz] -> [.backup/.rmlist]
    Record new entry: [overlay.d/sbin/magisk64.xz] -> [.backup/.rmlist]
    Create directory [.backup] (0000)
    Add entry [.backup/.magisk] (0000)
    Dump cpio: [ramdisk.cpio]
    [*] repacking back to ramdisk.img format
    [!] Rename Magisk.zip to Magisk.apk
    [-] After the ramdisk.img file is patched and compressed,
    [*] pull it back in the Magisk DIR
    [*] /data/data/com.android.shell/Magisk/ramdiskpatched4AVD.img: 1 file pulled, 0 skipped. 209.3 MB/s (2918094 bytes in 0.013s)
    [-] pull Magisk.apk to Apps/
    [*] /data/data/com.android.shell/Magisk/Magisk.apk: 1 file pulled, 0 skipped. 236.2 MB/s (6720493 bytes in 0.027s)
    [-] pull Magisk.zip to Apps/
    [*] adb: error: failed to stat remote object '/data/data/com.android.shell/Magisk/Magisk.zip': No such file or directory
    [-] Clean up the ADB working space
    [*] Move and rename the patched ramdisk.img to the original AVD DIR
    [-] Install all APKs placed in the Apps folder
    [*] Trying to install Apps/Magisk.apk
    Performing Streamed Install
    Success
    [-] Shut-Down & Reboot the AVD and see if it worked
    [-] Root and Su with Magisk for Android Studio AVDs
    [-] Modded by NewBit XDA - Jan. 2021
    [!] Huge Credits and big Thanks to topjohnwu and shakalaca
    Code:
    ./rootAVD.sh ~/Library/Android/sdk/system-images/android-S/google_apis/x86_64/ramdisk.img
    [!] and we are NOT in an emulator shell
    [-] Test if ADB SHELL is working
    [-] In any AVD via ADB, you can execute code without root in /data/data/com.android.shell
    [-] Magisk installer Zip exists already
    [*] Cleaning up the ADB working space
    [*] Creating the ADB working space
    [-] Copy Magisk installer Zip
    [*] ./Magisk.zip: 1 file pushed, 0 skipped. 50.7 MB/s (6720493 bytes in 0.126s)
    [*] Set Directorys
    [-] Backup exists already
    [-] Copy the original AVD ramdisk.img into Magisk DIR
    [*] /Users/newbit/Library/Android/sdk/system-images/android-S/google_apis/x86_64/ramdisk.img: 1 file pushed, 0 skipped. 339.1 MB/s (2918094 bytes in 0.008s)
    [-] Copy rootAVD Script into Magisk DIR
    [*] rootAVD.sh: 1 file pushed, 0 skipped. 104.1 MB/s (22575 bytes in 0.000s)
    [-] Convert Script to Unix Ending
    [-] run the actually Boot/Ramdisk/Kernel Image Patch Script
    [*] from Magisk by topjohnwu and modded by NewBit XDA
    [!] We are in an emulator shell
    [-] Switch to the location of the script file
    [*] Extracting busybox and Magisk.zip ...
    [-] Checking AVDs Internet connection...
    [!] AVD is online
    [!] Checking available Magisk Versions
    [?] Choose a Magisk Version to install and make it local
    [1] Local '22.1' (ENTER)
    [2] Canary e136fb3a(22102)
    [3] Stable 22.1
    
    [1] You choose Magisk Local Version '22.1'
    [*] Re-Run rootAVD in Magisk Busybox STANDALONE (D)ASH
    [!] We are in an emulator shell
    [-] We are now in Magisk Busybox STANDALONE (D)ASH
    [*] rootAVD with Magisk '22.1' Installer
    [-] Get Flags
    [*] System-as-root, keep dm/avb-verity
    [-] Encrypted data, keep forceencrypt
    [*] RECOVERYMODE=false
    [-] KEEPVERITY=true
    [*] KEEPFORCEENCRYPT=true
    [-] Api Level Arch Detect
    [-] Device Platform: x64
    [-] Device SDK API: 30
    [-] ARCH32 x86
    [-] First API Level: 31
    [*] copy all files from /data/data/com.android.shell/Magisk/lib/x86 to /data/data/com.android.shell/Magisk
    [*] Detecting ramdisk.img compression
    [!] Ramdisk.img uses lz4_legacy compression
    [-] taken from shakalaca's MagiskOnEmulator/process.sh
    [*] executing ramdisk splitting / extraction / repacking
    [-] API level greater then 30
    [*] Check if we need to repack ramdisk before patching ..
    [*] After decompressing ramdisk.img, magiskboot will work
    Detected format: [lz4_legacy]
    [-] Test patch status and do restore
    [-] Checking ramdisk status
    [-] STATUS=1
    [-] Magisk patched boot image detected
    [-] Constructing environment - PAY ATTENTION to AVDs Screen
    [!] we are root

    Also, before you ask, please answer your self the following questions:
    • Did I read AND understood the README.md ?
    • Is my question as detailed and simple as possible couched ?
    Also, please include my Username in your Salutation to make sure I will get notice of it.
    I love to help, but asking all the time where to pick you up, just increases the time period to get
    your issues fixed.
    2
    Nice, thanks for your feedback.
    I've never tried to get pass through the SafetyNet Check.
    But If you want to go further, you can try to change your devices fingerprint with MagiskHidePropsConf from @Didgeridoohan.
    So you could pass basicintegrety, and for ctsprofile you can try Universal SafetyNet Fix from @kdrag0n
    Both modules are just awesome and I have them both on my real phone for the same purpose.


    What do you mean by that? If you can't drag and drop the apk to Emulators Display to install it, there is something wrong
    with your ADB connection. I had this quite a lot, but booting the AVD up over the SDK fixed it mostly for me.


    THX , i will test it.
    I test to install Magisk and spoof with Pokemon Go

    Magisk install - Check
    Smalipatcher install - Check
    Pokemon Go install - not check (cant install)
    Joystick install - not check (cant install)

    But i will test more first
    1
    hi, I'am glade it works for you and grateful for your feedback.
    Do you mind telling me on which system and AVD you let the script run?

    My work System:
    OS: MacOS Catalina 10.15.6
    Android Studio 4.0.1
    AVD: Pixel 2 API 30 Android 10.0+ x86_64

    I restart AVD into safemode, then exec

    ./rootAVD.sh ~/Library/Android/sdk/system-images/android-30/google_apis_playstore/x86_64/ramdisk.img

    restart and follow the magisk to fix problem.
    1
    My work System:
    OS: Windows 10
    Android Studio 4.0.1
    AVD: Pixel 2 API 29 Android 10.0+ x86_64

    BUT
    basicintegrity: False
    ctsProfile: False

    And i cant install lot of Apps.
    But root look like the Picture above me
    1
    Well, you don't have to restart the entire Studio, just the AVD. And yes, shutdown and start is mandatory, only rebooting
    doesn't pick up the patched ramdisk.img
    I am glade it worked eventually.

    Just for improvement purposes.

    Did I hint it not well enough? What was missing?
    Or was it just a misreading/misunderstanding on your side?
    I would like to keep the Notes for the script as clear as possible.
    Also, there is always some space to the top left.

    Cheers
    NewBit
    you explained it correctly when I consulted you because the steps you gave me were not included from the beginning and maybe for someone who does not understand a lot, they are lost like me but I hope that with the answer to my question someone else can understand the process and I think it was my mistake, maybe I was writing something wrong, maybe I misspelled the ramdisk path
Our Apps
Get our official app!
The best way to access XDA on your phone
Nav Gestures
Add swipe gestures to any Android
One Handed Mode
Eases uses one hand with your phone