yashsingh1/xdaforums huggingface dataset:
[Android Studio] Spuqui:
About this "mounting a SAR partition writable is not possible by definition."... I know this is a security restriction, but I don't know much about the details behind it. I'm not too much a dev myself, only web dev, but I assume that this restriction was implemented in API 31, because up to API 30 I could mount root writable in FX, and it works great. FX was the only one I could find able to do so nowadays. I used to use ES File Explorer, but it got banned. xplore was one I tested and it was not able to browse the subfolders of /data/data, even with root. It could see only 2 folders in there, one of the FX application itself and the other I think is playstore services or something like that, while there actually are numerous folders in /data/data.

The shell solution proved much more interesting in my case as instead of having to browse through the system partition manually to copy a file, now the script does that, faster and reliably, so the automation is even better.

The only reason I wanted a visual interface involved was because the files I work on are images, and the ones in the system side have auto generated names which are unrelated to the content, so to actually identify the right file I need, I need to preview the image. Right now I am using the rooted shell to copy a candidate from the system partition to the /storage/emulated/0/Download folder where my native Android file manager can see it and preview it, and with that I can confirm it is the right file, otherwise I go for next candidate. When I was using API 30, I could just browse in FX to the system partition folder and it would preview all images there as thumbnails, so I did not have to copy candidates to Download for preview.

Anyway, even though it was nice to have that option to mount root writable, I do not think I will miss it that much. What I could not do without is the root itself, which I have due to your script, so again, thanks!
[Android Studio] newbit:
ah no, this comes from something else.

X-plore can only display files that belong to its userid. This is another new restriction from android it self. Cant recall how it ia called again. But yes this is a known issue nowadays. Only root shell can see it. Sry.
[Android Studio] newbit:
you can see all your files in data/data if you jump to the mirror folders of magisk. typ in a shell magisk --path to get the dir, and in there look for .magisk and then mirror dir. In there is the whole system mirrored, and data/data has all its file, even for x-plore. Ive just tested it.
[Android Studio] DOUGHBOY126:
im getting

C:\Users\HP\Desktop\tools\rootAVD-master>rootAVD.bat system-images\android-34\google_apis_playstore\x86_64\ramdisk.img

[*] Set Directorys

[-] Test IF ADB SHELL is working

[-] ADB connection possible

[-] In any AVD via ADB, you can execute code without root in /data/data/com.android.shell

[*] Testing the ADB working space

[!] /data/data/com.android.shell is available

[*] Cleaning up the ADB working space

[*] Creating the ADB working space

[*] looking for Magisk installer Zip

[*] Push Magisk.zip into /data/data/com.android.shell/Magisk

[-] C:\Users\HP\Desktop\tools\rootAVD-master\Magisk.zip: 1 file pushed, 0 skipped. 78.6 MB/s (11278270 bytes in 0.137s)

[-] Backup exists already

[*] Push ramdisk.img into /data/data/com.android.shell/Magisk/ramdisk.img

[-] C:\Users\HP\AppData\Local\Android\Sdk\system-images\android-34\google_apis_playstore\x86_64\ramdisk.img: 1 file pushed, 0 skipped. 133.8 MB/s (1566438 bytes in 0.011s)

[-] Copy rootAVD Script into Magisk DIR

rootAVD.sh: 1 file pushed, 0 skipped. 51.8 MB/s (82110 bytes in 0.002s)

[-] run the actually Boot/Ramdisk/Kernel Image Patch Script

[*] from Magisk by topjohnwu and modded by NewBit XDA

[!] We are in a BlueStacks emulator shell

[-] Api Level Arch Detect

[-] Device Platform: x64

[-] ARCH32 x86

[-] Device SDK API: 25

[-] First API Level:

[-] The AVD runs on Android 7.1.1

[-] Switch to the location of the script file

[*] Looking for an unzip binary

[-] unzip binary found

[*] Extracting busybox and Magisk.zip via unzip ...

[!] unzip binary does not support extracting Magisk.zip // when i try to use on bluestacks can u give any spefics i need to do when trying achive using with bluestacks please
[Android Studio] tusharraj:
Will this work for Android TV emulators?
[Android Studio] newbit:
it did when i tried a while ago. Cant recall which one i've tested though.
[Android Studio] tusharraj:
I am trying this for Television (720p) API 34, which isn't working. I don't get any error but the device is not rooted.
[Android Studio] newbit:
perhapa you have to switch user.

Check the automotive notes on how to do this.
[Android Studio] tusharraj:
I tried finding the notes, but couldn't find it. Can you please provide me a link for the same?
[Android Studio] newbit:
first page! readme
[Android Studio] pac123123:
Hi @newbit ,

I'm trying to run and I'm stuck in the following, maybe you'd be able to help me?

ProductName: Windows 11

Android Studio Iguana | 2023.2.1 Patch 1

API 30, android 11.0 R (tried with API34 as well, same)

latest gitlab download
[Android Studio] newbit:
Hi @pac123123

no Magisk.zip found, hmm. Strange.

Lets see if I can repdroduce the same issue...

on a second thought, I am seeing some weird symbols in your path.

Perhaps this causes some copy issues. Can you start the script from

a different folder? Without spaces and special characters in it?

you are running the script from CMD, right? Or is it PS?
[Android Studio] pac123123:
Just in case I did something wrong let me tell exactly what I did,

downloaded the zip

added C:\Users\eduar\AppData\Local\Android\Sdk\platform-tools to system variables PATH

opened adm cmd

tried this: adb devices

which returns me:

List of devices attached
emulator-5554 device

then I used "cd" to move to the folder, then ran .\rootAVD.bat

then rootAVD.bat ListAllAVDs

and rootAVD.bat system-images\android-30\google_apis\x86\ramdisk.img

Before this I also tried "rootAVD.bat InstallApps"

But I get this,

[*] Set Directorys

[*] Testing for write permissions

[-] creating TEMPFILE File

[!] elevated write permissions are needed to access $ANDROID_HOME

[-] Test IF ADB SHELL is working

[-] ADB connection possible

[-] Install all APKs placed in the Apps folder
[Android Studio] newbit:
you don't need the rootAVD.bat InstallApps

and you don't need to open CMD as admin, unless you need

admin rights to write to your ramdisk location. But the script

should tell you that, if it is needed to run CMD as admin.

The script runs fine so far, it even copies the magisk.zip, but can't find

it later on.

I still think your issue lies in the path, check out the markings:
[Android Studio] pac123123:
That's the ´ in Área, somehow got messed up probably because I had my windows in Japanese at some point. Will see if I can fix the font issue.
[Android Studio] pac123123:
@newbit You were spot on, since I changed my windows to Japanese it was conflicting, should be working now. Thanks a lot!!
[Android Studio] Wakoki:
can this be applied to an Android that is running in VMware ?
[Android Studio] orlando23:
My question is after you installed Magisk, you need to find boot.img to patch and then use the patched image to boot for your system. Is it possible on AVD?
[Android Studio] yvza:
thats workin, tested recently on m2 pro using android api 33 emu
[Android Studio] Anubhav001:
Hi, please guide me. I have AVD running but when I ran script it does nothing, no error or success message.
[Android Studio] qounik:
Hey did you make any progress? I am planning to do the same thing and was researching about it.
[Android Studio] newbit:
Hi Anubhav001,

sounds like you are either in a vacuum or in a super position of two states :cool:

Could you please send me more informations about your situation? I have

added some little basic infos what would be very helpful to start with. Check out

the

Requesting for Help!

on the first page.
[Android Studio] VD171:
Wow

Very very nice job, my friend.

Thank you very much for contribution
[Android Studio] bibliotekarz:
I have a problem with installing the root:

Host system: Windows 10

Android studio Version: newest

AVD version - S

I have installed the root One time successfully, turned off the studio (by killing the process, then doing the cold boot now) And now im stuck on black screen on my AVD. Any fixes for that? Should I just install one more time and it will be good?
[Android Studio] newbit:
So you had actually already root? And after killing the AVD process you stuck on a black boot screen?

Not sure If this is rootAVD related or caused by it. Sometimes after crashes, there are some lock files remaining

in the AVD directory. Those files can block the boot process. Try to clean them, or wipe data, or delete the AVD at once and recreate it. Restore the backup ramdisk and start rootAVD over. I doubt, if you stuck on a black screen,

that you can re-run the rootAVD script.
[Android Studio] bibliotekarz:
After killing the AVD process and starting again from Cold boot I had black screen. I will try what you said above and tell you If it worked.
[Android Studio] bibliotekarz:
Okay - I got it fixed. If you are wondering what you should do - restart PC, delete all files and uninstall android studio (\Android\ Files, SDK too) Now I'll test out if everything works and will tell ya
[Android Studio] bibliotekarz:
Okay I see progress but not there yet. I just did the double patch of the file (First did it. Then shutdown, open again - Magisk Manager opened - I had the popup to Install new package version. [First time I did it, after install the root "disappeared". Then I ignored it and patched root again - Nothing happened after it.]) I don't know what's the cause of it. I have tried giving adb shell, su and then shutdown and power on again, but nothing changed. Any fixes to that?

Same version - I'm using target: google API and not google Play, if that matters.
[Android Studio] newbit:
It doesn't matter If you use it with the Google Play Store Api or without it. Since Magisk V22.1, you can use this version to install it on Android S revision 2.

After the first run, Shutdown and Restart the AVD was correct. No Root found is shown in the Magisk APP.

Then, running the script just a second time, should pop up the Grant Su Permissions to Shell 2 times,

and then the AVD restarts, triggered by the script. That's it.

I've just tested it my self, with Google APIs Intel x86 Atom_64 System Image (revision: 2)

Once the ramdisk.img is patched, you can run the script again and again, it just deletes the directory/data/adb/magisk

and re-installs the binarys to that folder. This is what Magisk does on a real device. But it gets

triggered from itself and shows up that Info: Additional Setup Required.

If you can, send me the input and output of the script when you run it the first time, and second time. It might

shows me more informations what went wrong. The minimal Start-Over point is, restore the ramdisk.img backup

and wipe data.
[Android Studio] bibliotekarz:
@newbit Okay. I have update the software to new one, so I don't need to update it. Now when I patch it first time. I select canary version (2). Then I patch second time and press enter (to patch local file - same as canary version) And Open Magisk (Didn't do adb shell -> su because it shows "/system/bin/sh: su: inaccessible or not found". On the magisk App after the two patches it looks like this: (Btw do i need to do a Cold Boot after first patch?)
[Android Studio] newbit:
In my AVD Configs, I have always the cold boot checked.

/system/bin/sh: su: inaccessible or not found Actually means the installation didn't work.

The v22.1 shown in your pic implies that it is NOT a Canary Version you have installed. Perhaps there is a mix up.

Re-download the rootAVD script at once. On your 1st run, check if v22.1 is your local version, and hit Enter.

The same on the 2nd run. If you have more than one AVD/System Platform installed, double check if you are pointing to the

right ramdisk.img and not to a different one. Which could explain that you don't have access to su!
[Android Studio] bibliotekarz:
@newbit Okay I installed once again fresh. Now when I start I get that "Magisk App stopped running" After hitting enter, and It's stuck on [-] Constructing environment - PAY ATTENTION to AVDs Screen for a good minute now. What should I do? press close app or what?
[Android Studio] bibliotekarz:
Here's the console output for that.

C:\Users\konto\Desktop\rootAVD-master>adb shell

emulator64_x86_64_arm64:/ $ exit

C:\Users\konto\Desktop\rootAVD-master>rootAVD.bat %LOCALAPPDATA%\Android\Sdk\system-images\android-S\google_apis_playstore\x86_64\ramdisk.img

The directory name is invalid.

"[-] Backup exists already"

"[-] In any AVD via ADB, you can execute code without root in /data/data/com.android.shell"

"[-] ADB connectoin possible"

"[*] looking for Magisk installer Zip"

"[*] Cleaning up the ADB working space"

"[*] Creating the ADB working space"

"[-] Copy Magisk installer Zip"

C:\Users\konto\Desktop\rootAVD-master\Magisk.zip: 1 file pushed, 0 skipped. 133.5 MB/s (6720493 bytes in 0.048s)

"[*] Copy the original AVD ramdisk.img into Magisk DIR"

C:\Users\konto\AppData\Local\Android\Sdk\system-images\and...le pushed, 0 skipped. 190.5 MB/s (2732968 bytes in 0.014s)

"[-] Copy rootAVD Script into Magisk DIR"

rootAVD.sh: 1 file pushed, 0 skipped. 2.7 MB/s (22575 bytes in 0.008s)

"[-] 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
[Android Studio] newbit:
Well, as it says: PAY ATTENTION to AVDs Screen

There you should see, on the AVDs Screen, that you can Grant Shell root permissions.

Grant it 2 times and after the next reboot you should have root installed.
[Android Studio] bibliotekarz:
I don't get any popups about the SU. What could be the cause of it? @newbit
[Android Studio] newbit:
Don't know. Never had this issue before. Perhabs you did wait to long? After 10s of nothing, the popup

disappears. Try it again. Or try this time canary version from the 1st run on.

Even If you are just in the adb shell, and hit su, the same pop up should show up.

Your log also shows that you did it all right so far.
[Android Studio] bibliotekarz:
When I do adb shell and then su it shows

127|emulator64_x86_64_arm64:/ $ su

forever, never completes my request. I don't get the prompt on my screen. I tried with canary (still 22.1 on local file) but it was waiting for grant access....... I honestly have no idea where to go from here. @newbit
[Android Studio] newbit:
hmm, forever? That is so weird. 10s tops!!

I am running out of ideas as well. You can try to figure out on which state your magisk deamon is.

In the shell, type just magisk, and than magisk su. And see what it shows.
[Android Studio] bibliotekarz:
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. I used Canary now. No errors, don't need to grant permissions and any popups. Didn't get stuck on the Constructing Environment thingy. Now I'm actually confused what to do. Restart device, patch 2nd time, Canary version, what next?
[Android Studio] bibliotekarz:
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:
[Android Studio] newbit:
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.
[Android Studio] bibliotekarz:
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.
[Android Studio] bibliotekarz:
Yup. Did the quick app check and everything seems to be looking good. You really are amazing.
[Android Studio] newbit:
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
[Android Studio] Apalon3709:
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
[Android Studio] Apalon3709:
The script ran 1 and 2 times. Nothing helps
[Android Studio] newbit:
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.
[Android Studio] michaelspz:
@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.
[Android Studio] newbit:
Hi @michaelspz,

they are too few steps, and they are too simple for a video. Depending on your host system, you just have to

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.
[Android Studio] michaelspz:
@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.
[Android Studio] Growtopia Jaw:
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.
[Android Studio] 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?

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
[Android Studio] Growtopia Jaw:
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,

# 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!