Skip to content
This repository has been archived by the owner on Oct 24, 2023. It is now read-only.

The command runs, but the avd is not rooted - Linux #30

Closed
Garry3064 opened this issue Jun 10, 2022 · 14 comments
Closed

The command runs, but the avd is not rooted - Linux #30

Garry3064 opened this issue Jun 10, 2022 · 14 comments

Comments

@Garry3064
Copy link

garry@garry-OptiPlex-3070:~/Downloads/rootAVD$ ./rootAVD.sh ~/Android/Sdk/system-images/android-28/google_apis/x86_64/ramdisk.img
[!] and we are NOT in an emulator shell
[*] Set Directorys
[-] Test if ADB SHELL is working
[-] In any AVD via ADB, you can execute code without root in /data/data/com.android.shell
[*] Cleaning up the ADB working space
[*] Creating the ADB working space
[-] Magisk installer Zip exists already
[*] Push Magisk.zip into /data/data/com.android.shell/Magisk
[-] ./Magisk.zip: 1 file pushed, 0 skipped. 195.1 MB/s (10641074 bytes in 0.052s)
[*] create Backup File of ramdisk.img
[*] Push ramdisk.img into /data/data/com.android.shell/Magisk
[-] /home/garry/Android/Sdk/system-images/android-28/google_apis/x86_64/ramdisk.img: 1 file pushed, 0 skipped. 723.5 MB/s (1745298 bytes in 0.002s)
[*] Push rootAVD.sh into /data/data/com.android.shell/Magisk
[-] rootAVD.sh: 1 file pushed, 0 skipped. 192.2 MB/s (7847625 bytes in 0.039s)
[-] run the actually Boot/Ramdisk/Kernel Image Patch Script
[*] from Magisk by topjohnwu and modded by NewBit XDA
[!] We are in a ranchu emulator shell
[-] Api Level Arch Detect
[-] Device Platform is x64 only
[-] Device SDK API: 31
[-] First API Level: 31
[-] 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
[!] (s)how all available Magisk Versions
[1] local stable '24.1' (ENTER)
[2] stable 24.3
[3] canary cacf8736(25001)
[4] alpha cae58c87-alpha(25001)
[-] You choose Magisk stable Version '24.1'
[*] Re-Run rootAVD in Magisk Busybox STANDALONE (D)ASH
[-] We are now in Magisk Busybox STANDALONE (D)ASH
[*] rootAVD with Magisk '24.1' Installer
[-] Get Flags
[*] System-as-root, keep dm/avb-verity
[-] Encrypted data, keep forceencrypt
[*] RECOVERYMODE=false
[-] KEEPVERITY=true
[*] KEEPFORCEENCRYPT=true
[-] copy all x86_64 files from /data/data/com.android.shell/Magisk/lib/x86_64 to /data/data/com.android.shell/Magisk
[*] Detecting ramdisk.img compression
[!] Ramdisk.img uses gzip 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: [gzip]
[-] Test patch status and do restore
[-] Checking ramdisk status
[-] STATUS=0
[-] Stock boot image detected
[-] Patching ramdisk
[*] adding overlay.d/sbin folders to ramdisk
Loading cpio: [ramdisk.cpio]
Create directory [overlay.d] (0750)
Create directory [overlay.d/sbin] (0750)
Dump cpio: [ramdisk.cpio]
[!] PATCHFSTAB=false
[!] Skipping fstab.ranchu patch with /dev/block/sda
[?] If you want fstab.ranchu patched, Call rootAVD with PATCHFSTAB
[!] AddRCscripts=false
[!] Skip adding *.rc scripts into ramdisk.img/sbin/*.rc
[?] If you want *.rc scripts added into ramdisk.img/sbin/*.rc, Call rootAVD with AddRCscripts
[!] patching the ramdisk with Magisk Init
Loading cpio: [ramdisk.cpio]
Add entry [init] (0750)
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/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
[*] Pull ramdiskpatched4AVD.img into ramdisk.img
[-] /data/data/com.android.shell/Magisk/ramdiskpatched4AVD.img: 1 file pulled, 0 skipped. 237.5 MB/s (2175189 bytes in 0.009s)
[*] Pull Magisk.apk into 
[-] /data/data/com.android.shell/Magisk/Magisk.apk: 1 file pulled, 0 skipped. 199.9 MB/s (10641074 bytes in 0.051s)
[-] Clean up the ADB working space
[-] Install all APKs placed in the Apps folder
[*] Trying to install Apps/Magisk.apk
[*] Performing Streamed Install
[*] Success
[-] Shut-Down & Reboot (Cold Boot Now) the AVD and see if it worked
[-] Root and Su with Magisk for Android Studio AVDs
[-] Trying to shut down the AVD
[!] If the AVD doesn't shut down, try it manually!
[-] Modded by NewBit XDA - Jan. 2021
[!] Huge Credits and big Thanks to topjohnwu, shakalaca, vvb2060 and HuskyDG
garry@garry-OptiPlex-3070:~/Downloads/rootAVD$ 

When I check the emulator. There is a Magisk app, but no Zygisk option. Also somehow I don't need to use the 'export path' command.
If I click on install Magisk there is only one option 'select and patch a file'. Please help.

@newbit1
Copy link
Owner

newbit1 commented Jun 10, 2022

did the avd shut down / a cold boot? Or just a reboot?

@Garry3064
Copy link
Author

did the avd shut down / a cold boot? Or just a reboot?

Cold boot. Moreover I have set my avd to cold boot everytime

@Garry3064
Copy link
Author

@newbit1
Copy link
Owner

newbit1 commented Jun 10, 2022

Perfekt, I do the same with the cold boot. All good, A12 is supported and it should work. And it did.

@Garry3064
Copy link
Author

Garry3064 commented Jun 10, 2022

Tried it again:

garry@garry-OptiPlex-3070:~/Downloads/rootAVD$ ./rootAVD.sh ~/Android/Sdk/system-images/android-28/google_apis/x86_64/ramdisk.img restore
[!] and we are NOT in an emulator shell
[*] Set Directorys
[!] Restoring ramdisk.img.backup to ramdisk.img
[*] Backups still remain in place
garry@garry-OptiPlex-3070:~/Downloads/rootAVD$ ./rootAVD.sh ~/Android/Sdk/system-images/android-28/google_apis/x86_64/ramdisk.img
[!] and we are NOT in an emulator shell
[*] Set Directorys
[-] Test if ADB SHELL is working
[-] In any AVD via ADB, you can execute code without root in /data/data/com.android.shell
[*] Cleaning up the ADB working space
[*] Creating the ADB working space
[-] Magisk installer Zip exists already
[*] Push Magisk.zip into /data/data/com.android.shell/Magisk
[-] ./Magisk.zip: 1 file pushed, 0 skipped. 309.2 MB/s (10641074 bytes in 0.033s)
[-] ramdisk.img Backup exists already
[*] Push ramdisk.img into /data/data/com.android.shell/Magisk
[-] /home/garry/Android/Sdk/system-images/android-28/google_apis/x86_64/ramdisk.img: 1 file pushed, 0 skipped. 859.2 MB/s (1745298 bytes in 0.002s)
[*] Push rootAVD.sh into /data/data/com.android.shell/Magisk
[-] rootAVD.sh: 1 file pushed, 0 skipped. 209.5 MB/s (7847625 bytes in 0.036s)
[-] run the actually Boot/Ramdisk/Kernel Image Patch Script
[*] from Magisk by topjohnwu and modded by NewBit XDA
[!] We are in a ranchu emulator shell
[-] Api Level Arch Detect
[-] Device Platform is x64 only
[-] Device SDK API: 31
[-] First API Level: 31
[-] 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
[!] (s)how all available Magisk Versions
[1] local stable '24.1' (ENTER)
[2] stable 24.3
[3] canary cacf8736(25001)
[4] alpha cae58c87-alpha(25001)
[-] You choose Magisk stable Version '24.1'
[*] Re-Run rootAVD in Magisk Busybox STANDALONE (D)ASH
[-] We are now in Magisk Busybox STANDALONE (D)ASH
[*] rootAVD with Magisk '24.1' Installer
[-] Get Flags
[*] System-as-root, keep dm/avb-verity
[-] Encrypted data, keep forceencrypt
[*] RECOVERYMODE=false
[-] KEEPVERITY=true
[*] KEEPFORCEENCRYPT=true
[-] copy all x86_64 files from /data/data/com.android.shell/Magisk/lib/x86_64 to /data/data/com.android.shell/Magisk
[*] Detecting ramdisk.img compression
[!] Ramdisk.img uses gzip 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: [gzip]
[-] Test patch status and do restore
[-] Checking ramdisk status
[-] STATUS=0
[-] Stock boot image detected
[-] Patching ramdisk
[*] adding overlay.d/sbin folders to ramdisk
Loading cpio: [ramdisk.cpio]
Create directory [overlay.d] (0750)
Create directory [overlay.d/sbin] (0750)
Dump cpio: [ramdisk.cpio]
[!] PATCHFSTAB=false
[!] Skipping fstab.ranchu patch with /dev/block/sda
[?] If you want fstab.ranchu patched, Call rootAVD with PATCHFSTAB
[!] AddRCscripts=false
[!] Skip adding *.rc scripts into ramdisk.img/sbin/*.rc
[?] If you want *.rc scripts added into ramdisk.img/sbin/*.rc, Call rootAVD with AddRCscripts
[!] patching the ramdisk with Magisk Init
Loading cpio: [ramdisk.cpio]
Add entry [init] (0750)
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/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
[*] Pull ramdiskpatched4AVD.img into ramdisk.img
[-] /data/data/com.android.shell/Magisk/ramdiskpatched4AVD.img: 1 file pulled, 0 skipped. 220.7 MB/s (2175189 bytes in 0.009s)
[*] Pull Magisk.apk into 
[-] /data/data/com.android.shell/Magisk/Magisk.apk: 1 file pulled, 0 skipped. 209.9 MB/s (10641074 bytes in 0.048s)
[-] Clean up the ADB working space
[-] Install all APKs placed in the Apps folder
[*] Trying to install Apps/Magisk.apk
[*] Performing Streamed Install
[*] Success
[-] Shut-Down & Reboot (Cold Boot Now) the AVD and see if it worked
[-] Root and Su with Magisk for Android Studio AVDs
[-] Trying to shut down the AVD
[!] If the AVD doesn't shut down, try it manually!
[-] Modded by NewBit XDA - Jan. 2021
[!] Huge Credits and big Thanks to topjohnwu, shakalaca, vvb2060 and HuskyDG
garry@garry-OptiPlex-3070:~/Downloads/rootAVD$ 

Screenshot_1654854710
This is what I see in Magisk after running the script and restarting the emulator.

Screenshot_1654854715
Settings in Magisk

Screenshot_1654854729
What can I do?

@newbit1
Copy link
Owner

newbit1 commented Jun 10, 2022

Hmm, the script should actually complain one the second run that the ramdisk is already patched. Is it possible that you have more than one AVD and that you mix it up between running it and pointing the script to it?

@newbit1
Copy link
Owner

newbit1 commented Jun 10, 2022

Also, API 28 seems like Pie, which is not supported at all!

@Garry3064
Copy link
Author

Also, API 28 seems like Pie, which is not supported at all!

Uhhh.. I am running API 31.
Also, I checked using adb devices, indeed I am running only one emulator.

@newbit1
Copy link
Owner

newbit1 commented Jun 10, 2022

But both your logs are showing
~/Android/Sdk/system-images/android-28/google_apis/x86_64/ramdisk.img

@Garry3064
Copy link
Author

Garry3064 commented Jun 10, 2022

Hmmmm... I don't know what caused that. I check in Settings>About, and the android version is showing 12.

I think I know what is the issue. I did use an API 28 avd before, but I removed it afterwards. The sdk-system-image for that is still there. Let me delete that (~/Android/Sdk/system-images/android-28) and try again.

@newbit1
Copy link
Owner

newbit1 commented Jun 10, 2022

Happened to me too. Use the listallavds parameter to get all your images available.

@Garry3064
Copy link
Author

Did that and now it works perfectly. Thanks for your help.
Screenshot_1654868970

@Garry3064
Copy link
Author

If possible do you know how to disable serial console? Somehow any avd I start it is enabled. Any links would be helpful, thanks. Will close this issue in a few hours:)

@newbit1
Copy link
Owner

newbit1 commented Jun 10, 2022

Great! Not sure about the console. Could be Kernel Boot parameter related.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants