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

stuck always #61

Closed
revolta opened this issue Apr 10, 2023 · 21 comments
Closed

stuck always #61

revolta opened this issue Apr 10, 2023 · 21 comments

Comments

@revolta
Copy link

revolta commented Apr 10, 2023

hello sir,
i must be doing something not goot. the script doesnt work at all. i am using newest android studio and newst emulator. every time i create a new virtual device (no matter its armv7a or armv8a, old or new images/api versions) i got stuck here (any help or advice would be appreciated, thank you):

[] Set Directorys
[-] Test if ADB SHELL is working
[-] ADB connectoin possible
[-] In any AVD via ADB, you can execute code without root in /data/data/com.android.shell
[
] looking for Magisk installer Zip
[] Cleaning up the ADB working space
[
] Creating the ADB working space
[] Push Magisk.zip into /data/data/com.android.shell/Magisk
[-] rootAVD-master\Magisk.zip: 1 file pushed, 0 skipped. 62.3 MB/s (11278270 bytes in 0.173s)
[
] create Backup File
[] Push ramdisk.img into /data/data/com.android.shell/Magisk
[-] Android\Sdk\system-images\android-23\google_apis\armeabi-v7a\ramdisk.img: 1 file pushed, 0 skipped. 1126.7 MB/s (890197 bytes in 0.001s)
[-] Copy rootAVD Script into Magisk DIR
rootAVD.sh: 1 file pushed, 0 skipped. 81.1 MB/s (7855800 bytes in 0.092s)
[-] 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 arm only
[-] Device SDK API: 23
[-] First API Level:
[-] The AVD runs on Android 6.0
[-] Switch to the location of the script file
[] Extracting busybox from script ...
[!] There is no busybox behind the script
[
] Trying to Download the Up-To-Date Script Version
[!] Temporarily installing Magisk
[!] Removing Temporarily installed Magisk
[-] Checking AVDs Internet connection...
[!] AVD is offline
[] Extracting Magisk.zip ...
/data/data/com.android.shell/Magisk/rootAVD.sh[2608]: /data/data/com.android.shell/Magisk/busybox: can't execute: Permission denied
[
] Extracting busybox from script ...
[!] There is no busybox behind the script
[] Trying to Download the Up-To-Date Script Version
[!] Temporarily installing Magisk
[!] Removing Temporarily installed Magisk
[
] Re-Run rootAVD in Magisk Busybox STANDALONE (D)ASH**

@newbit1
Copy link
Owner

newbit1 commented Apr 10, 2023

Hi,
how do you start the script?
And how did you download it?

@revolta
Copy link
Author

revolta commented Apr 14, 2023

start like this (the avd is androidapiversion 23, armv7a):
rootAVD.bat C:\xxxx\xxxx\AppData\Local\Android\Sdk\system-images\android-23\google_apis\armeabi-v7a\ramdisk.img

the second question, i am not sure what you mean. simply i downloaded the whole git - went here: https://github.com/newbit1/rootAVD, and then there is a CODE button, then press DOWNLOAD ZIP. thats it.

@newbit1
Copy link
Owner

newbit1 commented Apr 15, 2023

Ok i see.

In your log it says:

[] Extracting busybox from script ...
[!] There is no busybox behind the script

Which means the busybox is missing, which is embedded at the end of the script. So this indicates
your script file is corrupt.

Usually this is not a big issue, the script trys to download the complete script, but your log also says:

[!] AVD is offline

Which is also not a big issue, the script trys to install magisk temporally to get it hands on the busybox
inside the magisk apk. It copies the busybox from that installation to its own working dir.

From this point on, it should be able to execute the busybox binary, but your log says:

[] Extracting Magisk.zip ...
/data/data/com.android.shell/Magisk/rootAVD.sh[2608]: /data/data/com.android.shell/Magisk/busybox: can't execute: Permission denied

Which indicates the execute permissions are not set correctly.
it seems this is the actually issue.

I've changed something in that routine, and it did work for me.
Please re download the script and try again.

Btw: Magisk doesn't support Android 6 anymore, I think minimum Version is Android 7.

If I run a working script with busybox embedded, I got this log:

newbit@rootAVD % ./rootAVD.sh ~/Library/Android/sdk/system-images/android-23/google_apis/armeabi-v7a/ramdisk.img DEBUG
[!] We are in Debug Mode
[!] 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. 14.2 MB/s (11278270 bytes in 0.756s)
[-] ramdisk.img Backup exists already
[*] Push ramdisk.img into /data/data/com.android.shell/Magisk/ramdisk.img
[-] /Users/newbit/Library/Android/sdk/system-images/android-23/google_apis/armeabi-v7a/ramdisk.img: 1 file pushed, 0 skipped. 467.1 MB/s (890197 bytes in 0.002s)
[*] Push rootAVD.sh into /data/data/com.android.shell/Magisk
[-] rootAVD.sh: 1 file pushed, 0 skipped. 14.5 MB/s (7855986 bytes in 0.517s)
[-] 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 arm only
[-] Device SDK API: 23
[-] First API Level: 
[-] The AVD runs on Android 6.0
[-] Switch to the location of the script file
[*] Extracting busybox from script ...
[!] Found a working busybox Binary: 
[!] BusyBox v1.33.1-Magisk (2021-05-08 15:20:41 PDT) multi-call binary.
[*] Extracting Magisk.zip ...
[-] Checking AVDs Internet connection...
[!] AVD is offline
[*] Re-Run rootAVD in Magisk Busybox STANDALONE (D)ASH
[-] We are now in Magisk Busybox STANDALONE (D)ASH
[*] rootAVD with Magisk MAGISK_VER='25.2' Installer
[-] Get Flags
[*] RECOVERYMODE=false
[-] KEEPVERITY=false
[*] KEEPFORCEENCRYPT=false
[-] copy all armeabi-v7a files from /data/data/com.android.shell/Magisk/lib/armeabi-v7a 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
[*] After decompressing ramdisk.img, magiskboot will work
Detected format: [gzip]
[-] Checking ramdisk STATUS=0
[-] Stock boot image detected
[*] Verifying Boot Image by its Kernel Release number:
[-] This AVD = 3.10.0+
[-] 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]
[!] patching the ramdisk with Magisk Init
Loading cpio: [ramdisk.cpio]
Add entry [init] (0750)
Add entry [overlay.d/sbin/magisk32.xz] (0644)
Patch with flag KEEPVERITY=[false] KEEPFORCEENCRYPT=[false]
Found fstab file [fstab.goldfish]
Found fstab file [fstab.ranchu]
Found fstab file [fstab.ranchu-encrypt]
Remove pattern [,forceencrypt=/dev/block/vdd]
Loading cpio: [ramdisk.cpio.orig]
Backup mismatch entry: [fstab.ranchu-encrypt] -> [.backup/fstab.ranchu-encrypt]
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]
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

If I run a working script without busybox embedded, I got this log:

newbit@rootAVD % ./rootAVD.sh ~/Library/Android/sdk/system-images/android-23/google_apis/armeabi-v7a/ramdisk.img DEBUG
[!] We are in Debug Mode
[!] 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. 15.9 MB/s (11278270 bytes in 0.678s)
[-] ramdisk.img Backup exists already
[*] Push ramdisk.img into /data/data/com.android.shell/Magisk/ramdisk.img
[-] /Users/newbit/Library/Android/sdk/system-images/android-23/google_apis/armeabi-v7a/ramdisk.img: 1 file pushed, 0 skipped. 441.8 MB/s (890197 bytes in 0.002s)
[*] Push rootAVD.sh into /data/data/com.android.shell/Magisk
[-] rootAVD.sh: 1 file pushed, 0 skipped. 338.2 MB/s (74196 bytes in 0.000s)
[-] 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 arm only
[-] Device SDK API: 23
[-] First API Level: 
[-] The AVD runs on Android 6.0
[-] Switch to the location of the script file
[!] There is no busybox behind the script
[*] Trying to Download the Up-To-Date Script Version
[!] Temporarily installing Magisk
[!] Removing Temporarily installed Magisk
[*] Copy busybox from lib to workdir
[-] Checking AVDs Internet connection...
[!] AVD is online
[!] Downloading File rootAVD.sh complete!
[*] Extracting Magisk.zip ...
[*] Move busybox from lib to workdir
[!] Checking available Magisk Versions
[?] Choose a Magisk Version to install and make it local
[s] (s)how all available Magisk Versions
[1] local stable MAGISK_VER='25.2' (ENTER)
[2] stable 26.1
[3] canary d0c93842(26101)
[4] alpha 709f25f6-alpha(26101)
[-] You choose Magisk local stable Version MAGISK_VER='25.2'
[*] Re-Run rootAVD in Magisk Busybox STANDALONE (D)ASH
[-] We are now in Magisk Busybox STANDALONE (D)ASH
[*] rootAVD with Magisk MAGISK_VER='25.2' Installer
[-] Get Flags
[*] RECOVERYMODE=false
[-] KEEPVERITY=false
[*] KEEPFORCEENCRYPT=false
[-] copy all armeabi-v7a files from /data/data/com.android.shell/Magisk/lib/armeabi-v7a 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
[*] After decompressing ramdisk.img, magiskboot will work
Detected format: [gzip]
[-] Checking ramdisk STATUS=0
[-] Stock boot image detected
[*] Verifying Boot Image by its Kernel Release number:
[-] This AVD = 3.10.0+
[-] 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]
[!] patching the ramdisk with Magisk Init
Loading cpio: [ramdisk.cpio]
Add entry [init] (0750)
Add entry [overlay.d/sbin/magisk32.xz] (0644)
Patch with flag KEEPVERITY=[false] KEEPFORCEENCRYPT=[false]
Found fstab file [fstab.goldfish]
Found fstab file [fstab.ranchu]
Found fstab file [fstab.ranchu-encrypt]
Remove pattern [,forceencrypt=/dev/block/vdd]
Loading cpio: [ramdisk.cpio.orig]
Backup mismatch entry: [fstab.ranchu-encrypt] -> [.backup/fstab.ranchu-encrypt]
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]
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

@revolta
Copy link
Author

revolta commented May 1, 2023

i have downloaded the updated script. it seems it was successful. when i try "adb shell --- then: su", it seems rooted (????):

C:\xxxx\xxxx\xxxx\ADB>adb shell
generic:/ $ id
uid=2000(shell) gid=2000(shell) groups=2000(shell),1004(input),1007(log),1011(adb),1015(sdcard_rw),1028(sdcard_r),3001(net_bt_admin),3002(net_bt),3003(inet),3006(net_bw_stats),3009(readproc) context=u:r:shell:s0
generic:/ $ su
generic:/ # id
uid=0(root) gid=0(root) groups=0(root),1004(input),1007(log),1011(adb),1015(sdcard_rw),1028(sdcard_r),3001(net_bt_admin),3002(net_bt),3003(inet),3006(net_bw_stats),3009(readproc) context=u:r:su:s0
generic:/ #

BUT, the app ROOT CHECKER PRO shows not rooted. i dont know.

yes, here is the log (i had to shut down avd manually) (avd is api level 25, android 7.1.1):

rootAVD.bat C:\xxx\xxxx\AppData\Local\Android\Sdk\system-images\android-25\google_apis\armeabi-v7a\ramdisk.img
[] Set Directorys
[-] Test if ADB SHELL is working
[-] ADB connectoin possible
[-] In any AVD via ADB, you can execute code without root in /data/data/com.android.shell
[
] looking for Magisk installer Zip
[] Cleaning up the ADB working space
[
] Creating the ADB working space
[] Push Magisk.zip into /data/data/com.android.shell/Magisk
[-] C:\xxxxxx\xxxxx\Magisk.zip: 1 file pushed, 0 skipped. 61.7 MB/s (11278270 bytes in 0.174s)
[-] Backup exists already
[
] Push ramdisk.img into /data/data/com.android.shell/Magisk
[-] C:\xxxx\xxxx\AppData\Local\Android\Sdk\system-images\android-25\google_apis\armeabi-v7a\ramdisk.img: 1 file pushed, 0 skipped. 185.8 MB/s (1274384 bytes in 0.007s)
[-] Copy rootAVD Script into Magisk DIR
rootAVD.sh: 1 file pushed, 0 skipped. 77.9 MB/s (7856319 bytes in 0.096s)
[-] 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 arm only
[-] Device SDK API: 25
[-] First API Level:
[-] The AVD runs on Android 7.1.1
[-] Switch to the location of the script file
[
] Extracting busybox from script ...
[!] There is no busybox behind the script
[] Trying to Download the Up-To-Date Script Version
[!] Temporarily installing Magisk
[!] Removing Temporarily installed Magisk
[
] Copy busybox from lib to workdir
[-] Checking AVDs Internet connection...
[!] AVD is offline
[] Extracting Magisk.zip ...
/data/data/com.android.shell/Magisk/rootAVD.sh[2621]: /data/data/com.android.shell/Magisk/busybox: can't execute: Permission denied
[
] Move busybox from lib to workdir
[] Re-Run rootAVD in Magisk Busybox STANDALONE (D)ASH
[-] We are now in Magisk Busybox STANDALONE (D)ASH
[
] rootAVD with Magisk Installer
[-] Get Flags
[] RECOVERYMODE=false
[-] KEEPVERITY=false
[
] KEEPFORCEENCRYPT=false
/data/data/com.android.shell/Magisk/rootAVD.sh: cd: line 81: can't cd to /data/data/com.android.shell/Magisk/lib/armeabi-v7a: No such file or directory
mv: can't rename 'lib*.so': No such file or directory
[-] copy all armeabi-v7a files from /data/data/com.android.shell/Magisk/lib/armeabi-v7a 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
[] After decompressing ramdisk.img, magiskboot will work
/data/data/com.android.shell/Magisk/rootAVD.sh: line 1335: /data/data/com.android.shell/Magisk/magiskboot: not found
[-] Stock A only system-as-root
[-] Stock boot image detected
[
] Verifying Boot Image by its Kernel Release number:
[-] This AVD = 3.10.0+
cat: can't open '/data/data/com.android.shell/Magisk/ramdisk.cpio': No such file or directory
[-] Patching ramdisk
/data/data/com.android.shell/Magisk/rootAVD.sh: line 1462: /data/data/com.android.shell/Magisk/magiskboot: not found
[] adding overlay.d/sbin folders to ramdisk
/data/data/com.android.shell/Magisk/rootAVD.sh: line 1482: /data/data/com.android.shell/Magisk/magiskboot: not found
[!] patching the ramdisk with Magisk Init
/data/data/com.android.shell/Magisk/rootAVD.sh: line 1489: /data/data/com.android.shell/Magisk/magiskboot: not found
[
] repacking back to ramdisk.img format
/data/data/com.android.shell/Magisk/rootAVD.sh: line 1519: /data/data/com.android.shell/Magisk/magiskboot: not found
[!] Rename Magisk.zip to Magisk.apk
[] Pull Magisk.apk into
[-] /data/data/com.android.shell/Magisk/Magisk.apk: 1 file pulled, 0 skipped. 33.5 MB/s (11278270 bytes in 0.321s
[-] 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 and Reboot [Cold Boot Now] 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, shakalaca and vvb2060
[-] Trying to shut down the AVD
[!] If the AVD doesnt shut down, try it manually!

@newbit1
Copy link
Owner

newbit1 commented May 6, 2023

Thanks, still the script doesn't work proper in your situation.
Don't know why.

/data/data/com.android.shell/Magisk/rootAVD.sh[2621]: /data/data/com.android.shell/Magisk/busybox: can't execute: Permission denied

could mean, that busybox doesn't have the execution rights.

I can't fully reproduce your issue. I don't understand, why your rootAVD.sh file, doesn't have
the busyboxes in it. Did you edit this file?

To get more information, could you please add a debug command in your script?
Change Line 1074 and 1075 from:

RemoveTemporarilyMagisk
CopyBusyBox

to:

RemoveTemporarilyMagisk
ls -l $BASEDIR/lib/*
set -x
CopyBusyBox

and then post everything after

[!] Removing Temporarily installed Magisk

Also, please use the fanced code block to post your log.

If you are on a Windows machine, wouldn't it make more sense, to use a x86 or x86_64 image?
the arm images don't run well anyway, if your host isn't already an arm as well.

Can you please upload your rootavd.sh file? So I can see if there is anything wrong with it?

@revolta
Copy link
Author

revolta commented May 13, 2023

no files were edited by me, all are the original ones from this github.

no, i doesnt make sense for me (the x86). i would like to use this emulator for native arm coding a do some research of android/linux (arm version). yes, this emulation (based on qemu) is really slow (even when you have a fast pc).

upload my rootavd.sh? does it have any sense?? i didn't made any changes, so the file is the same as the one uploaded in this github repo.

changed the lines, here is the cmd output:

[!] Removing Temporarily installed Magisk
total 4640
-rwxr-xr-x 1 shell shell 1461400 2023-05-13 06:52 libbusybox.so
-rwxr-xr-x 1 shell shell  154452 2023-05-13 06:52 libmagisk32.so
-rwxr-xr-x 1 shell shell  323320 2023-05-13 06:52 libmagiskboot.so
-rwxr-xr-x 1 shell shell  210128 2023-05-13 06:52 libmagiskinit.so
-rwxr-xr-x 1 shell shell  218220 2023-05-13 06:52 libmagiskpolicy.so
+ CopyBusyBox
+ echo '[*] Copy busybox from lib to workdir'
[*] Copy busybox from lib to workdir
+ '[' -e /data/data/com.android.shell/Magisk/lib ']'
+ chmod -R 755 /data/data/com.android.shell/Magisk/lib
+ >/dev/null
+ 2>&1
+ cp -f /data/data/com.android.shell/Magisk/lib/armeabi-v7a/libbusybox.so /data/data/com.android.shell/Magisk/busybox
+ >/dev/null
+ 2>&1
+ /data/data/com.android.shell/Magisk/busybox
+ >/dev/null
+ 2>&1
+ cp -f /data/data/com.android.shell/Magisk/lib/armeabi-v7a/libbusybox.so /data/data/com.android.shell/Magisk/busybox
+ >/dev/null
+ 2>&1
+ /data/data/com.android.shell/Magisk/busybox
+ >/dev/null
+ 2>&1
+ cp -f /data/data/com.android.shell/Magisk/lib/arm/libbusybox.so /data/data/com.android.shell/Magisk/busybox
+ DownLoadFile https://github.com/newbit1/rootAVD/raw/master/ rootAVD.sh
+ CheckAVDIsOnline
+ '[' -z ']'
+ echo '[-] Checking AVDs Internet connection...'
[-] Checking AVDs Internet connection...
+ AVDIsOnline=false
+ >/dev/null
+ 2>&1
+ /data/data/com.android.shell/Magisk/busybox timeout 3 /data/data/com.android.shell/Magisk/busybox wget -q --spider --no-check-certificate http://github.com
+ '[' 126 -eq 0 ']'
+ false
+ echo '[!] AVD is offline'
[!] AVD is offline
+ export AVDIsOnline
+ false
[*] Extracting Magisk.zip ...
/data/data/com.android.shell/Magisk/rootAVD.sh[2623]: /data/data/com.android.shell/Magisk/busybox: can't execute: Permission denied
[*] Move busybox from lib to workdir
[*] Re-Run rootAVD in Magisk Busybox STANDALONE (D)ASH
[-] We are now in Magisk Busybox STANDALONE (D)ASH
[*] rootAVD with Magisk  Installer
[-] Get Flags
[*] RECOVERYMODE=false
[-] KEEPVERITY=false
[*] KEEPFORCEENCRYPT=false
/data/data/com.android.shell/Magisk/rootAVD.sh: cd: line 81: can't cd to /data/data/com.android.shell/Magisk/lib/armeabi-v7a: No such file or directory
mv: can't rename 'lib*.so': No such file or directory
[-] copy all armeabi-v7a files from /data/data/com.android.shell/Magisk/lib/armeabi-v7a 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
[*] After decompressing ramdisk.img, magiskboot will work
/data/data/com.android.shell/Magisk/rootAVD.sh: line 1337: /data/data/com.android.shell/Magisk/magiskboot: not found
[-] Stock A only system-as-root
[-] Stock boot image detected
[*] Verifying Boot Image by its Kernel Release number:
[-] This AVD = 3.10.0+
cat: can't open '/data/data/com.android.shell/Magisk/ramdisk.cpio': No such file or directory
[-] Patching ramdisk
/data/data/com.android.shell/Magisk/rootAVD.sh: line 1464: /data/data/com.android.shell/Magisk/magiskboot: not found
[*] adding overlay.d/sbin folders to ramdisk
/data/data/com.android.shell/Magisk/rootAVD.sh: line 1484: /data/data/com.android.shell/Magisk/magiskboot: not found
[!] patching the ramdisk with Magisk Init
/data/data/com.android.shell/Magisk/rootAVD.sh: line 1491: /data/data/com.android.shell/Magisk/magiskboot: not found
[*] repacking back to ramdisk.img format
/data/data/com.android.shell/Magisk/rootAVD.sh: line 1521: /data/data/com.android.shell/Magisk/magiskboot: not found
[!] Rename Magisk.zip to Magisk.apk
[*] Pull Magisk.apk into
[-] /data/data/com.android.shell/Magisk/Magisk.apk: 1 file pulled, 0 skipped. 36.8 MB/s (11278270 bytes in 0.292s
[-] 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 and Reboot [Cold Boot Now] 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, shakalaca and vvb2060
[-] Trying to shut down the AVD
[!] If the AVD doesnt shut down, try it manually!

@newbit1
Copy link
Owner

newbit1 commented May 13, 2023

no files were edited by me, all are the original ones from this github.
upload my rootavd.sh? does it have any sense?? i didn't made any changes, so the file is the same as the one uploaded in this github repo.

Well, this is what we expect, and what is normally the case, yes! But the observations clearly indicates, that there
must be something wrong with the script. Otherwise, it wouldn't say, there is no busybox behind the script.
Plus, as you can clearly see -rwxr-xr-x 1 shell shell 1461400 2023-05-13 06:52 libbusybox.so
busybox has execution permits, as the script is setting it. But it still says: data/data/com.android.shell/Magisk/rootAVD.sh[2623]: /data/data/com.android.shell/Magisk/busybox: can't execute: Permission denied

So please, upload it for me If you can. So I can further investigate the issue.

Did you really put in ls -l $BASEDIR/lib/*this command should list you all sub directories as well, not only one.

no, i doesnt make sense for me (the x86). i would like to use this emulator for native arm coding a do some research of > android/linux (arm version). yes, this emulation (based on qemu) is really slow (even when you have a fast pc).

Yeah performance in this case doesn't bring you much, you need a similar host architecture.
But why do you need Android 7 for it? If you use an Android 11 AVD, it has the libndk_translation built in,
and translates natively arm code for you. -> Run ARM apps on the Android Emulator

@newbit1
Copy link
Owner

newbit1 commented May 14, 2023

I have changed the whole unzip and busybox routines, also I removed the busybox behind the
script entirely. Please give it a try, and see if this works now for your use case.

@revolta
Copy link
Author

revolta commented May 21, 2023

the file rootAVD.sh, is uploaded. the old one, and the new new one modified by you few days ago (i had to add .txt extension, just remove it).
rootAVD-new.sh.txt
rootAVD-old.sh.txt

yes, i made the exact modification as you wrote:

RemoveTemporarilyMagisk
ls -l $BASEDIR/lib/*
set -x
CopyBusyBox

thank you, i didn't know that. i tried to use all major emulators, but none of them was able to run any armv7a/armv8 native binary (even the genymotion with ARM TRANSLATION using libhoudini could't do that). so the only option for me was to use a qemu based emulator (which could possibly run a native binary). i thought that, you must use a armv7a/armv8a image/avd to run a native arm binary. BUT, thank you for your advice, it seems like you are right, i tried ANDROID 11 avd... and, surprise, IT DID WORK! lul and more important thing, the android 11 avd runs really fast, and another more important thing is, that rootavd is working!! i have root access. so, i have to tell you, i am really grateful for your advice. now i can play with (debug binaries, hope that debugging will also work, i didn't tried it yet, uff!!) fast running avd (x86/64) which seems to work with arm binaries.

also i tried the new rootavd, the new modified, on the arm avd/image, still not working:

[*] Set Directorys
[-] Test if ADB SHELL is working
[-] ADB connectoin possible
[-] In any AVD via ADB, you can execute code without root in /data/data/com.android.shell
[*] looking for Magisk installer Zip
[*] Cleaning up the ADB working space
[*] Creating the ADB working space
[*] Push Magisk.zip into /data/data/com.android.shell/Magisk
[-] rootAVD-master\Magisk.zip: 1 file pushed, 0 skipped. 48.2 MB/s (11278270 bytes in 0.223s)
[-] Backup exists already
[*] Push ramdisk.img into /data/data/com.android.shell/Magisk
[-] AppData\Local\Android\Sdk\system-images\android-25\google_apis\armeabi-v7a\ramdisk.img: 1 file pushed, 0 skipped. 157.4 MB/s (1274384 bytes in 0.008s)
[-] Copy rootAVD Script into Magisk DIR
rootAVD.sh: 1 file pushed, 0 skipped. 63.4 MB/s (76222 bytes in 0.001s)
[-] 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 arm only
[-] 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
[-] No unzip binary found
[!] Temporarily installing Magisk
[*] Copy Magisk Lib Files to workdir
[!] Removing Temporarily installed Magisk
[*] Finding a working Busybox Version
ls: /data/data/com.android.shell/Magisk/lib/armeabi-v7a/*busybox*: No such file or directory
[*] Copy busybox from lib to workdir
chmod: /data/data/com.android.shell/Magisk/busybox: No such file or directory
[*] Extracting Magisk.zip via Busybox ...
[!] Busybox binary does not support extracting Magisk.zip

@revolta
Copy link
Author

revolta commented May 27, 2023

aaaah, shit! i thought that it would be possible to debug arm code, but no it is not. the debug server arm binary works on the x86/64 avd (android 11), it can run. but the debugging itself doesn't work. it is maybe because of the libhoudini translation library, who knows. so, it's look like that the only hope is to use one of the VEEERY slow ARM images/avds - but the root still doesn't work.

@newbit1
Copy link
Owner

newbit1 commented May 28, 2023

Interesting, so debugging doesnt work with the ndk libtranslation.

I dont get why the script acts different on your machine, while tested it with the same configuration.

You can try to add the debug commands again, and show me the log files.

RemoveTemporarilyMagisk
ls -l $BASEDIR/lib/*
set -x
CopyBusyBox

You could also delete your system-image, and re download it. While it is downloading, it shows you the complete download link. Copy and paste it here please. Perhaps you system image has a difference to mine. With that download link i can try to use it and see how it works on my machine.

@revolta
Copy link
Author

revolta commented May 31, 2023

i don' know if i am doing it right (the rootAVD.sh file has changed), the right place for the debug commands is here:

DownloadUptoDateSript() {
	echo "[*] Trying to Download the Up-To-Date Script Version"
	
	local DLL_URL="https://github.com/newbit1/rootAVD/raw/master/"
	local DLL_SCRIPT="rootAVD.sh"
	local DLL_ROOTAVD_ZIP="https://github.com/newbit1/rootAVD/archive/refs/heads/master.zip"
	local PKG_PATH=""
	
	ExtractMagiskViaPM
	FindWorkingBusyBox
	CopyBusyBox	
	DownLoadFile $DLL_URL $DLL_SCRIPT

changed it to:

DownloadUptoDateSript() {
	echo "[*] Trying to Download the Up-To-Date Script Version"
	
	local DLL_URL="https://github.com/newbit1/rootAVD/raw/master/"
	local DLL_SCRIPT="rootAVD.sh"
	local DLL_ROOTAVD_ZIP="https://github.com/newbit1/rootAVD/archive/refs/heads/master.zip"
	local PKG_PATH=""
	
	ExtractMagiskViaPM
	FindWorkingBusyBox
	RemoveTemporarilyMagisk ----->>> NEW
	ls -l $BASEDIR/lib/* ----->>> NEW
	set -x ----->>> NEW
	CopyBusyBox ----->>> NEW
	DownLoadFile $DLL_URL $DLL_SCRIPT

is that place right?

anyways, it doesn't work, here's the latest log:

[*] Set Directorys
[-] Test if ADB SHELL is working
[-] ADB connectoin possible
[-] In any AVD via ADB, you can execute code without root in /data/data/com.android.shell
[*] looking for Magisk installer Zip
[*] Cleaning up the ADB working space
[*] Creating the ADB working space
[*] Push Magisk.zip into /data/data/com.android.shell/Magisk
[-] x:\xxx\rootAVD-master\Magisk.zip: 1 file pushed, 0 skipped. 68.4 MB/s (11278270 bytes in 0.157s)
[*] create Backup File
[*] Push ramdisk.img into /data/data/com.android.shell/Magisk
[-] x:\xxxx\xxxx\AppData\Local\Android\Sdk\system-images\android-25\google_apis\armeabi-v7a\ramdisk.img: 1 file pushed, 0 skipped. 1323.9 MB/s (1274384 bytes in 0.001s)
[-] Copy rootAVD Script into Magisk DIR
rootAVD.sh: 1 file pushed, 0 skipped. 54.1 MB/s (76272 bytes in 0.001s)
[-] 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 arm only
[-] 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
[-] No unzip binary found
[!] Temporarily installing Magisk
[*] Copy Magisk Lib Files to workdir
[!] Removing Temporarily installed Magisk
[*] Finding a working Busybox Version
[*] Copy busybox from lib to workdir
[*] Extracting Magisk.zip via Busybox ...
[!] Busybox binary does not support extracting Magisk.zip

for example i chose this system image, here is the info:

Packages to install: - Google APIs ARM EABI v7a System Image (system-images;android-25;google_apis;armeabi-v7a)

Nougat 25 armeabi-v7a Android 7.1.1 (Google APIs)

https://dl.google.com/android/repository/sys-img/google_apis/armeabi-v7a-25_r18.zip

@newbit1
Copy link
Owner

newbit1 commented May 31, 2023

Yes, add the lines in the rootavd.sh
Sorry, my bad. Between lines 1107 and 1108

	FindWorkingBusyBox
	CopyBusyBox

insert:

	ls -l $BASEDIR/lib/*
	set -x

to:

	FindWorkingBusyBox
	ls -l $BASEDIR/lib/*
	set -x
	CopyBusyBox

These commands are for debugging, not for fixing.
Make sure, if you save the file, to keep the file ending LF.

Thanks for the download link, i will have a look into it.

@revolta
Copy link
Author

revolta commented Jun 3, 2023

here's the log:

x:\xxx\rootAVD-master>x:\xxx\rootAVD-master\rootAVD.bat x:\xxx\xxx\AppData\Local\Android\Sdk\system-images\android-25\google_apis\armeabi-v7a\ramdisk.img
[*] Set Directorys
[-] Test if ADB SHELL is working
[-] ADB connectoin possible
[-] In any AVD via ADB, you can execute code without root in /data/data/com.android.shell
[*] looking for Magisk installer Zip
[*] Cleaning up the ADB working space
[*] Creating the ADB working space
[*] Push Magisk.zip into /data/data/com.android.shell/Magisk
[-] x:\xxx\rootAVD-master\Magisk.zip: 1 file pushed, 0 skipped. 68.5 MB/s (11278270 bytes in 0.157s)
[-] Backup exists already
[*] Push ramdisk.img into /data/data/com.android.shell/Magisk
[-] x\xxx\xxx\AppData\Local\Android\Sdk\system-images\android-25\google_apis\armeabi-v7a\ramdisk.img: 1 file pushed, 0 skipped. 1500.6 MB/s (1274384 bytes in 0.001s)
[-] Copy rootAVD Script into Magisk DIR
rootAVD.sh: 1 file pushed, 0 skipped. 24.4 MB/s (76253 bytes in 0.003s)
[-] 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 arm only
[-] 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
[-] No unzip binary found
[!] Temporarily installing Magisk
[*] Copy Magisk Lib Files to workdir
[!] Removing Temporarily installed Magisk
[*] Finding a working Busybox Version
ls: /data/data/com.android.shell/Magisk/lib/armeabi-v7a/*busybox*: No such file or directory
[*] Copy busybox from lib to workdir
chmod: /data/data/com.android.shell/Magisk/busybox: No such file or directory
[*] Extracting Magisk.zip via Busybox ...
[!] Busybox binary does not support extracting Magisk.zip

@newbit1
Copy link
Owner

newbit1 commented Jun 3, 2023

ok great, thanks. Somehow, the just copied busybox is not there.

@revolta
Copy link
Author

revolta commented Jun 4, 2023

hm, i was reading the output, and this seems interesting to me:

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

the sentence tell's it all. so i tried it. i pushed a debugging server to that directory "/data/data/com.android.shell", and it worked homehow (as root??). but unfortunately i wasn't able to attach to any process (only the system process was shown). so maybe the server isn't doing what it should.

that was just an sudden idea.. anyways, hope you will make the root run!

@Anugrahsr
Copy link

I am getting the same issue, surprisingly I did root a device with this prior, but after using the updated version I'm getting similar error.
Screenshot 2023-06-17 at 1 07 16 AM

@newbit1
Copy link
Owner

newbit1 commented Jun 18, 2023

Hey @revolta,
I tried your provided AVD image and I could reproduce the issue, finally.
I improved the finding busybox routine, and it seems to work now. Please try and report back.
@Anugrahsr
same for you too.

@Anugrahsr
Copy link

Hey @revolta
The fix worked like a charm!

Screenshot 2023-06-19 at 9 43 27 AM

@revolta
Copy link
Author

revolta commented Jul 2, 2023

yes, i think it works. maybe.

there is a problem, but, apparently only on my side. i am not sure why is that happening. the rootavd.bat is running fine, but the avd itself is not responding after the process. it is somehow stuck (freezed), it takes not any input. it is not even possible to restart the avd (not byt clicking the little "x" in the corner of window, and not by using ADB). there is only one possibility to go to DEVICE MANAGER and push the little quadrangle associated to this avd (it is the STOP button), or from windows task manager and force to terminate the process/thread of the avd. but, when i use these two only possible solution (push STOP, or terminate process/thread), it always saves the current state of emulator - and maybe that's why the root isn't somehow "saved to the avd".

i don't really know why is this happening. maybe a performance issue? i run a new notebook, and i have to go with FULL PERFORMANCE with the cable of notebook plugged in the socket. then the cable is plugged in the performance of all avds are better, but maybe not enought to save the root on avd.

ps: newbit1 many thanks for your effort.

here is the log, this time i tried a lower android version (api level 23) (don't worry about the version, the freezing is the same on api level 25.. and so on):

x:\xxx\rootAVD-master>Cx:\xxx\rootAVD-master\rootAVD.bat \system-images\android-23\google_apis\armeabi-v7a\ramdisk.img
[*] Set Directorys
[-] Test IF ADB SHELL is working
[!] ADB is not in your Path, try to
set PATH=%LOCALAPPDATA%\Android\Sdk\platform-tools;%PATH%
[*] setting it, just during this session, for you
[-] 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
[*] 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
[-] x:\xxx\rootAVD-master\Magisk.zip: 1 file pushed, 0 skipped. 35.9 MB/s (11278270 bytes in 0.300s)
[-] Backup exists already
[*] Push ramdisk.img into /data/data/com.android.shell/Magisk/ramdisk.img
[-] x:\xxx\xxx\AppData\Local\Android\Sdk\\system-images\android-23\google_apis\armeabi-v7a\ramdisk.img: 1 file pushed, 0 skipped. 160.5 MB/s (890197 bytes in 0.005s)
[-] Copy rootAVD Script into Magisk DIR
rootAVD.sh: 1 file pushed, 0 skipped. 10.5 MB/s (77313 bytes in 0.007s)
[-] 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 arm only
[-] Device SDK API: 23
[-] First API Level:
[-] The AVD runs on Android 6.0
[-] Switch to the location of the script file
[*] Looking for an unzip binary
[-] No unzip binary found
[*] Searching for pre installed Magisk Apps
[!] Found a pre installed Magisk App, use it
[*] Copy Magisk Lib Files to workdir
[*] Finding a working Busybox Version
[*] Testing Busybox ...
[!] Found a working Busybox Version
[!] BusyBox v1.34.1-Magisk (2022-08-19 10:51:18 PDT) multi-call binary.
[*] Copy busybox from lib to workdir
[*] Extracting Magisk.zip via Busybox ...
[*] Move busybox from lib to workdir
[-] Checking AVDs Internet connection...
[!] AVD is online
[!] Checking available Magisk Versions
[?] Choose a Magisk Version to install and make it local
[s] (s)how all available Magisk Versions
[1] local stable MAGISK_VER='25.2' (ENTER)
[2] stable 26.1
[3] canary a8c4a33e(26103)
[4] alpha 46770db1-alpha(26103)
[-] You choose Magisk local stable Version MAGISK_VER='25.2'
[*] Re-Run rootAVD in Magisk Busybox STANDALONE (D)ASH
[-] We are now in Magisk Busybox STANDALONE (D)ASH
[*] rootAVD with Magisk MAGISK_VER='25.2' Installer
[-] Get Flags
[*] RECOVERYMODE=false
[-] KEEPVERITY=false
[*] KEEPFORCEENCRYPT=false
[-] copy all armeabi-v7a files from /data/data/com.android.shell/Magisk/lib/armeabi-v7a 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
[*] After decompressing ramdisk.img, magiskboot will work
Detected format: [gzip]
[-] Checking ramdisk STATUS=0
[-] Stock boot image detected
[*] Verifying Boot Image by its Kernel Release number:
[-] This AVD = 3.10.0+
[-] 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]
[!] patching the ramdisk with Magisk Init
Loading cpio: [ramdisk.cpio]
Add entry [init] (0750)
Add entry [overlay.d/sbin/magisk32.xz] (0644)
Patch with flag KEEPVERITY=[false] KEEPFORCEENCRYPT=[false]
Found fstab file [fstab.goldfish]
Found fstab file [fstab.ranchu]
Found fstab file [fstab.ranchu-encrypt]
Remove pattern [,forceencrypt=/dev/block/vdd]
Loading cpio: [ramdisk.cpio.orig]
Backup mismatch entry: [fstab.ranchu-encrypt] -> [.backup/fstab.ranchu-encrypt]
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]
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. 46.7 MB/s (1120698 bytes in 0.023s
[*] Pull Magisk.apk into
[-] /data/data/com.android.shell/Magisk/Magisk.apk: 1 file pulled, 0 skipped. 54.6 MB/s (11278270 bytes in 0.197s
[-] Clean up the ADB working space
[-] Install all APKs placed in the Apps folder
[*] Trying to install APPS\Magisk.apk
[-] Performing Push Install
[-] APPS\Magisk.apk: 1 file pushed, 0 skipped. 59.7 MB/s (11278270 bytes in 0.180s)
[-]     pkg: /data/local/tmp/Magisk.apk
[-] Success
[-] Shut-Down and Reboot [Cold Boot Now] 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, shakalaca and vvb2060
[-] Trying to shut down the AVD
[!] If the AVD doesnt shut down, try it manually!

@newbit1
Copy link
Owner

newbit1 commented Jul 2, 2023

Great, yeah the freezing comes from the qemu .exe
You have to kill it at worst case via task manager or avd manager.

You must cold boot your avd. Otherwise it is loading a snapshot!

@newbit1 newbit1 closed this as completed Jul 7, 2023
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

3 participants