newbit1 / rootAVD

Script to root AVDs running with QEMU Emulator from Android Studio
GNU General Public License v3.0
1.45k stars 186 forks source link

Problem installing with Pixel_3a_XL_API_25 and android 7 #83

Closed flazouh closed 1 year ago

flazouh commented 1 year ago

I'm trying to execute $ ./rootAVD.sh system-images/android-34/google_apis_playstore/arm64-v8a/ramdisk.img FAKEBOOTIMG

But I get

$ ./rootAVD.sh system-images/android-34/google_apis_playstore/arm64-v8a/ramdisk.img FAKEBOOTIMG
[!] and we are NOT in an emulator shell
[*] Set Directorys
[-] source.properties file exist
[*] AVD system-image Pkg.Revision=7
[-] 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
[-] Magisk installer Zip exists already
[*] Push Magisk.zip into /data/data/com.android.shell/Magisk
[-] ./Magisk.zip: 1 file pushed, 0 skipped. 188.6 MB/s (11278270 bytes in 0.057s)
[-] ramdisk.img Backup exists already
[*] Push ramdisk.img into /data/data/com.android.shell/Magisk/ramdisk.img
[-] /Users/alex/Library/Android/sdk/system-images/android-34/google_apis_playstore/arm64-v8a/ramdisk.img: 1 file pushed, 0 skipped. 510.1 MB/s (1941988 bytes in 0.004s)
[*] Push rootAVD.sh into /data/data/com.android.shell/Magisk
[-] rootAVD.sh: 1 file pushed, 0 skipped. 559.6 MB/s (79634 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 arm64 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
[*] Searching for pre installed Magisk Apps
[!] Temporarily installing Magisk
[*] Copy Magisk Lib Files to workdir
[!] Removing Temporarily installed Magisk
[*] Finding a working Busybox Version
[*] Testing Busybox /data/data/com.android.shell/Magisk/lib/arm64/libbusybox.so
[!] Found a working Busybox Version
[!] BusyBox v1.34.1-Magisk (2022-03-22 04:11:29 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 '25.2' (ENTER)
[2] stable 26.1
[3] canary d390ca2f(26104)
[4] alpha 46770db1-alpha(26103)
[-] You choose Magisk local stable Version '25.2'
[*] Re-Run rootAVD in Magisk Busybox STANDALONE (D)ASH
[-] We are now in Magisk Busybox STANDALONE (D)ASH
[*] rootAVD with Magisk '25.2' Installer
[-] Get Flags
[*] RECOVERYMODE=false
[-] KEEPVERITY=false
[*] KEEPFORCEENCRYPT=false
[-] copy all arm64-v8a files from /data/data/com.android.shell/Magisk/lib/arm64-v8a 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
[*] After decompressing ramdisk.img, magiskboot will work
Detected format: [lz4_legacy]
[*] Processing fake Boot.img
[*] Creating a fake Boot.img
[-] removing old /sdcard/Download/fakeboot.img
[!] Only a minimal header is required for Magisk to repack the ramdisk
[*] repacking ramdisk.img into /sdcard/Download/fakeboot.img
[*] Searching for pre installed Magisk Apps
[!] Temporarily installing Magisk
[*] Detecting current user
[-] Current user 0
[-] Starting Magisk
[*] Install/Patch /sdcard/Download/fakeboot.img and hit Enter when done(max. 60s)

[!] Removing Temporarily installed Magisk
[!] No magisk_patched file could be found!
[!] aborting the script
(base)

It seems that it can't write the fakebook.img to the device, even though I'm launching it with :

/Users/alex/Library/Android/sdk/emulator/emulator @Pixel_3a_XL_API_25 -memory 4096 -writable-system

flazouh commented 1 year ago

I tried :

adb root adb shell avbctl disable-verification adb reboot adb root adb remount

But I get

$ adb shell avbctl disable-verification
/system/bin/sh: avbctl: not found

But I don't get any popups such as "Requires additionnal setup" ...

newbit1 commented 1 year ago

I tried :

adb root adb shell avbctl disable-verification adb reboot adb root adb remount

But I get

$ adb shell avbctl disable-verification
/system/bin/sh: avbctl: not found

But I don't get any popups such as "Requires additionnal setup" ...

You don't need these commands.

android-34 is not Android 7. Use the same ramdisk from the running avd.

[*] Install/Patch /sdcard/Download/fakeboot.img and hit Enter when done(max. 60s)

[!] Removing Temporarily installed Magisk
[!] No magisk_patched file could be found!

It seems you didn't patched the fake boot.img. Didn`t the Magisk App pop up after

[*] Install/Patch /sdcard/Download/fakeboot.img and hit Enter when done(max. 60s)
flazouh commented 1 year ago

where do I find this boot.img? I don't see the instructions about that in the README.MD

newbit1 commented 1 year ago

/sdcard/Download/fakeboot.img

There is a video/gif and a passage about the fakeboot.img in the readme. Also some hints appear in the script, when it waits for you to patch it in Magisk. The script even openes Magisk for you, very simple, i thought.

realyukii commented 1 year ago

Hi @newbit1 I tried your script again, but this time I couldn't find fakeboot.img. is there something that must be done so that fakeboot.img appears? I have tried the fakeboot argument: .\rootAVD.bat system-images\android-31\google_apis\x86_64\ramdisk.img FAKEBOOTIMG

and while [*] Install/Patch /sdcard/Download/fakeboot.img and hit Enter when done(max. 60s) I try to emulator64_x86_64_arm64:/ $ ls /sdcard/Download/ but the directory is still empty

I use the canary version of magisk

newbit1 commented 1 year ago

no nothing special is needed. If the script says it is under /sdcard/Download/fakeboot.img

it should be there.

Can you post the full log? Perhaps there is a different issue before.

realyukii commented 1 year ago

here's the full log:

PS C:\Users\Kyouma\Desktop\rootAVD> .\rootAVD.bat system-images\android-31\google_apis\x86_64\ramdisk.img FAKEBOOTIMG
[*] 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\Kyouma\Desktop\rootAVD\Magisk.zip: 1 file pushed, 0 skipped. 261.2 MB/s (12514269 bytes in 0.046s)
[-] Backup exists already
[*] Push ramdisk.img into /data/data/com.android.shell/Magisk/ramdisk.img
[-] C:\Android\system-images\android-31\google_apis\x86_64\ramdisk.img: 1 file pushed, 0 skipped. 267.5 MB/s (3689317 bytes in 0.013s)
[-] Copy rootAVD Script into Magisk DIR
rootAVD.sh: 1 file pushed, 0 skipped. 66.2 MB/s (79822 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 x64 only
[-] Device SDK API: 31
[-] First API Level: 31
[-] The AVD runs on Android 12
[-] Switch to the location of the script file
[*] Looking for an unzip binary
[-] unzip binary found
[*] Extracting busybox and Magisk.zip via unzip ...
[*] Finding a working Busybox Version
[*] Testing Busybox /data/data/com.android.shell/Magisk/lib/arm64-v8a/libbusybox.so
[*] Testing Busybox /data/data/com.android.shell/Magisk/lib/x86/libbusybox.so
[!] Found a working Busybox Version
[!] BusyBox v1.34.1-Magisk (2022-08-19 10:51:18 PDT) multi-call binary.
[*] Move busybox from lib to workdir
[-] Checking AVDs Internet connection...
[-] Checking AVDs Internet connection another way...
[!] AVD is online
[!] Checking available Magisk Versions
wget: can't connect to remote host: Network is unreachable
/data/data/com.android.shell/Magisk/rootAVD.sh[2838]: can't open canary.json: No such file or directory
/data/data/com.android.shell/Magisk/rootAVD.sh[2838]: can't open canary.json: No such file or directory
/data/data/com.android.shell/Magisk/rootAVD.sh[2838]: can't open canary.json: No such file or directory
wget: short read, have only 30
[?] Choose a Magisk Version to install and make it local
[s] (s)how all available Magisk Versions
[1] local stable 'ee34f775'(26105) (ENTER)
[2] stable 26.1
[3] canary ()
[4] alpha 82903582-alpha(26105)
[-] You choose Magisk local stable Version 'ee34f775'(26105)
[*] Re-Run rootAVD in Magisk Busybox STANDALONE (D)ASH
[-] We are now in Magisk Busybox STANDALONE (D)ASH
[*] rootAVD with Magisk 'ee34f775'(26105) 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
[-] copy 'stub.apk' from /data/data/com.android.shell/Magisk/assets 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 ..
[*] Searching for the real End of the 1st Archive
[-] Dumping from 0 to 1691779 ..
Detected format: [lz4_legacy]
[-] Dumping from 1691779 to 3689298 ..
Detected format: [lz4_legacy]
[*] Repacking ramdisk ..
[*] Processing fake Boot.img
[*] Creating a fake Boot.img
[!] Only a minimal header is required for Magisk to repack the ramdisk
[*] repacking ramdisk.img into /sdcard/Download/fakeboot.img
[*] Searching for pre installed Magisk Apps
[!] Temporarily installing Magisk
[*] Detecting current user
[-] Current user 0
[-] Starting Magisk
[*] Install/Patch /sdcard/Download/fakeboot.img and hit Enter when done(max. 60s)

[!] Removing Temporarily installed Magisk
[!] No magisk_patched file could be found!
[!] aborting the script
newbit1 commented 1 year ago

hm, it seems they are two but unrelated issues. First PS indicates you run the script with powershell, use cmd instead.

second, there is an wget issue, which doesn't break the script. Seems weird this way.

But you have put your canary version already as local, so no issue there.

realyukii commented 1 year ago

Okay, I will give it a shoot on cmd:

C:\Users\Kyouma\Desktop\rootAVD> .\rootAVD.bat system-images\android-31\google_apis\x86_64\ramdisk.img FAKEBOOTIMG
[*] 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\Kyouma\Desktop\rootAVD\Magisk.zip: 1 file pushed, 0 skipped. 308.7 MB/s (12514269 bytes in 0.039s)
[-] Backup exists already
[*] Push ramdisk.img into /data/data/com.android.shell/Magisk/ramdisk.img
[-] C:\Android\system-images\android-31\google_apis\x86_64\ramdisk.img: 1 file pushed, 0 skipped. 278.8 MB/s (3689317 bytes in 0.013s)
[-] Copy rootAVD Script into Magisk DIR
rootAVD.sh: 1 file pushed, 0 skipped. 94.5 MB/s (79822 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 x64 only
[-] Device SDK API: 31
[-] First API Level: 31
[-] The AVD runs on Android 12
[-] Switch to the location of the script file
[*] Looking for an unzip binary
[-] unzip binary found
[*] Extracting busybox and Magisk.zip via unzip ...
[*] Finding a working Busybox Version
[*] Testing Busybox /data/data/com.android.shell/Magisk/lib/arm64-v8a/libbusybox.so
[*] Testing Busybox /data/data/com.android.shell/Magisk/lib/x86/libbusybox.so
[!] Found a working Busybox Version
[!] BusyBox v1.34.1-Magisk (2022-08-19 10:51:18 PDT) multi-call binary.
[*] 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 'ee34f775'(26105) (ENTER)
[2] stable 26.1
[3] canary ee34f775(26105)
[4] alpha 82903582-alpha(26105)

[-] You choose Magisk local stable Version 'ee34f775'(26105)
[*] Re-Run rootAVD in Magisk Busybox STANDALONE (D)ASH
[-] We are now in Magisk Busybox STANDALONE (D)ASH
[*] rootAVD with Magisk 'ee34f775'(26105) 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
[-] copy 'stub.apk' from /data/data/com.android.shell/Magisk/assets 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 ..
[*] Searching for the real End of the 1st Archive
[-] Dumping from 0 to 1691779 ..
Detected format: [lz4_legacy]
[-] Dumping from 1691779 to 3689298 ..
Detected format: [lz4_legacy]
[*] Repacking ramdisk ..
[*] Processing fake Boot.img
[*] Creating a fake Boot.img
[!] Only a minimal header is required for Magisk to repack the ramdisk
[*] repacking ramdisk.img into /sdcard/Download/fakeboot.img
[*] Searching for pre installed Magisk Apps
[!] Temporarily installing Magisk
[*] Detecting current user
[-] Current user 0
[-] Starting Magisk
[*] Install/Patch /sdcard/Download/fakeboot.img and hit Enter when done(max. 60s)

[!] Removing Temporarily installed Magisk
[!] No magisk_patched file could be found!
[!] aborting the script

and inside adb shell with a 60s timeout:

emulator64_x86_64_arm64:/ $ ls /sdcard/Download/
emulator64_x86_64_arm64:/ $
newbit1 commented 1 year ago

as i said, unrelated issues.

this needs more investigation...