Coder Social home page Coder Social logo

rootavd's Introduction

This Repo will be archived at the 24th of Oct 2023

Due to the forced 2FA Mumbo Jumbo from GitHub,

this Repo has moved to GitLab

A Script to...

  • root your Android Studio Virtual Device (AVD), with Magisk (Stable, Canary or Alpha)
  • patch its fstab
  • download and install the USB HOST Permissions Module for Magisk
  • install custom build Kernel and its Modules
  • download and install AOSP prebuilt Kernel and its Modules

...within seconds.

Install Magisk

Download rootAVD via

  • Click
  • git clone https://github.com/newbit1/rootAVD.git

Preconditions

  • the AVD is running
  • a working Internet connection for the Menu
  • a command prompt / terminal is opened
  • adb shell will connect to the running AVD

Use Case Examples

on MacOS

BlueStacks 4 on MacOS

on Windows

on Linux

Fake Boot.img on MacOS

How to Install ADB (Android SDK Platform-Tools)

  • Open Android Studio -> SDK Manager -> Android SDK -> SDK Tools -> Check on Android SDK Platform-Tools -> Apply

rootAVD Help Menu

rootAVD A Script to root AVD by NewBit XDA

Usage:  rootAVD [DIR/ramdisk.img] [OPTIONS] | [EXTRA ARGUMENTS]
or:     rootAVD [ARGUMENTS]

Arguments:
        ListAllAVDs                     Lists Command Examples for ALL installed AVDs

        InstallApps                     Just install all APKs placed in the Apps folder

Main operation mode:
        DIR                             a path to an AVD system-image
                                        - must always be the 1st Argument after rootAVD

ADB Path | Ramdisk DIR| ANDROID_HOME:
        [M]ac/Darwin:                   export PATH=~/Library/Android/sdk/platform-tools:$PATH
                                        export PATH=$ANDROID_HOME/platform-tools:$PATH
                                        system-images/android-$API/google_apis_playstore/x86_64/

        [L]inux:                        export PATH=~/Android/Sdk/platform-tools:$PATH
                                        export PATH=$ANDROID_HOME/platform-tools:$PATH
                                        system-images/android-$API/google_apis_playstore/x86_64/

        [W]indows:                      set PATH=%LOCALAPPDATA%\Android\Sdk\platform-tools;%PATH%
                                        system-images\android-$API\google_apis_playstore\x86_64\

        ANDROID_HOME:                   By default, the script uses %LOCALAPPDATA%, to set its Android Home
                                        directory, search for AVD system-images and ADB binarys. This behaviour
                                        can be overwritten by setting the ANDROID_HOME variable.
                                        e.g. set ANDROID_HOME=%USERPROFILE%\Downloads\sdk

        $API:                           25,29,30,31,32,33,34,UpsideDownCake,etc.

Options:
        restore                         restore all existing .backup files, but doesn't delete them
                                        - the AVD doesn't need to be running
                                        - no other Argument after will be processed

        InstallKernelModules            install custom build kernel and its modules into ramdisk.img
                                        - kernel (bzImage) and its modules (initramfs.img) are inside rootAVD
                                        - both files will be deleted after installation

        InstallPrebuiltKernelModules    download and install an AOSP prebuilt kernel and its modules into ramdisk.img
                                        - similar to InstallKernelModules, but the AVD needs to be online

Options are exclusive, only one at the time will be processed.

Extra Arguments:
        DEBUG                           Debugging Mode, prevents rootAVD to pull back any patched file

        PATCHFSTAB                      fstab.ranchu will get patched to automount Block Devices like /dev/block/sda1
                                        - other entries can be added in the script as well
                                        - a custom build Kernel might be necessary

        GetUSBHPmodZ                    The USB HOST Permissions Module Zip will be downloaded into /sdcard/Download

        FAKEBOOTIMG                     Creates a fake Boot.img file that can directly be patched from the Magisk APP
                                        - Magisk will be launched to patch the fake Boot.img within 60s
                                        - the fake Boot.img will be placed under /sdcard/Download/fakeboot.img

Extra Arguments can be combined, there is no particular order.

Notes: rootAVD will
- always create .backup files of ramdisk*.img and kernel-ranchu
- replace both when done patching
- show a Menu, to choose the Magisk Version (Stable || Canary || Alpha), if the AVD is online
- make the choosen Magisk Version to its local
- install all APKs placed in the Apps folder
- use %LOCALAPPDATA%\Android\Sdk to search for AVD system images

Linux & MacOS

Command Examples:
./rootAVD.sh
./rootAVD.sh ListAllAVDs
./rootAVD.sh InstallApps

./rootAVD.sh system-images/android-33/google_apis_playstore/x86_64/ramdisk.img
./rootAVD.sh system-images/android-33/google_apis_playstore/x86_64/ramdisk.img FAKEBOOTIMG
./rootAVD.sh system-images/android-33/google_apis_playstore/x86_64/ramdisk.img DEBUG PATCHFSTAB GetUSBHPmodZ
./rootAVD.sh system-images/android-33/google_apis_playstore/x86_64/ramdisk.img restore
./rootAVD.sh system-images/android-33/google_apis_playstore/x86_64/ramdisk.img InstallKernelModules
./rootAVD.sh system-images/android-33/google_apis_playstore/x86_64/ramdisk.img InstallPrebuiltKernelModules
./rootAVD.sh system-images/android-33/google_apis_playstore/x86_64/ramdisk.img InstallPrebuiltKernelModules GetUSBHPmodZ PATCHFSTAB DEBUG
./rootAVD.sh system-images/android-33/google_apis_playstore/x86_64/ramdisk.img AddRCscripts
Command Examples: for ALL installed AVDs
./rootAVD.sh
./rootAVD.sh ListAllAVDs
./rootAVD.sh InstallApps

./rootAVD.sh system-images/android-25/google_apis/armeabi-v7a/ramdisk.img
./rootAVD.sh system-images/android-25/google_apis/armeabi-v7a/ramdisk.img FAKEBOOTIMG
./rootAVD.sh system-images/android-25/google_apis/armeabi-v7a/ramdisk.img DEBUG PATCHFSTAB GetUSBHPmodZ
./rootAVD.sh system-images/android-25/google_apis/armeabi-v7a/ramdisk.img restore
./rootAVD.sh system-images/android-25/google_apis/armeabi-v7a/ramdisk.img InstallKernelModules
./rootAVD.sh system-images/android-25/google_apis/armeabi-v7a/ramdisk.img InstallPrebuiltKernelModules
./rootAVD.sh system-images/android-25/google_apis/armeabi-v7a/ramdisk.img InstallPrebuiltKernelModules GetUSBHPmodZ PATCHFSTAB DEBUG
./rootAVD.sh system-images/android-25/google_apis/armeabi-v7a/ramdisk.img AddRCscripts

./rootAVD.sh system-images/android-25/google_apis/x86_64/ramdisk.img
./rootAVD.sh system-images/android-25/google_apis/x86_64/ramdisk.img FAKEBOOTIMG
./rootAVD.sh system-images/android-25/google_apis/x86_64/ramdisk.img DEBUG PATCHFSTAB GetUSBHPmodZ
./rootAVD.sh system-images/android-25/google_apis/x86_64/ramdisk.img restore
./rootAVD.sh system-images/android-25/google_apis/x86_64/ramdisk.img InstallKernelModules
./rootAVD.sh system-images/android-25/google_apis/x86_64/ramdisk.img InstallPrebuiltKernelModules
./rootAVD.sh system-images/android-25/google_apis/x86_64/ramdisk.img InstallPrebuiltKernelModules GetUSBHPmodZ PATCHFSTAB DEBUG
./rootAVD.sh system-images/android-25/google_apis/x86_64/ramdisk.img AddRCscripts

./rootAVD.sh system-images/android-30/google_apis_playstore/x86/ramdisk.img
./rootAVD.sh system-images/android-30/google_apis_playstore/x86/ramdisk.img FAKEBOOTIMG
./rootAVD.sh system-images/android-30/google_apis_playstore/x86/ramdisk.img DEBUG PATCHFSTAB GetUSBHPmodZ
./rootAVD.sh system-images/android-30/google_apis_playstore/x86/ramdisk.img restore
./rootAVD.sh system-images/android-30/google_apis_playstore/x86/ramdisk.img InstallKernelModules
./rootAVD.sh system-images/android-30/google_apis_playstore/x86/ramdisk.img InstallPrebuiltKernelModules
./rootAVD.sh system-images/android-30/google_apis_playstore/x86/ramdisk.img InstallPrebuiltKernelModules GetUSBHPmodZ PATCHFSTAB DEBUG
./rootAVD.sh system-images/android-30/google_apis_playstore/x86/ramdisk.img AddRCscripts

./rootAVD.sh system-images/android-30/android-automotive-playstore/x86_64/ramdisk-qemu.img
./rootAVD.sh system-images/android-30/android-automotive-playstore/x86_64/ramdisk-qemu.img FAKEBOOTIMG
./rootAVD.sh system-images/android-30/android-automotive-playstore/x86_64/ramdisk-qemu.img DEBUG PATCHFSTAB GetUSBHPmodZ
./rootAVD.sh system-images/android-30/android-automotive-playstore/x86_64/ramdisk-qemu.img restore
./rootAVD.sh system-images/android-30/android-automotive-playstore/x86_64/ramdisk-qemu.img InstallKernelModules
./rootAVD.sh system-images/android-30/android-automotive-playstore/x86_64/ramdisk-qemu.img InstallPrebuiltKernelModules
./rootAVD.sh system-images/android-30/android-automotive-playstore/x86_64/ramdisk-qemu.img InstallPrebuiltKernelModules GetUSBHPmodZ PATCHFSTAB DEBUG
./rootAVD.sh system-images/android-30/android-automotive-playstore/x86_64/ramdisk-qemu.img AddRCscripts

./rootAVD.sh system-images/android-30/android-automotive-playstore/x86_64/ramdisk.img
./rootAVD.sh system-images/android-30/android-automotive-playstore/x86_64/ramdisk.img FAKEBOOTIMG
./rootAVD.sh system-images/android-30/android-automotive-playstore/x86_64/ramdisk.img DEBUG PATCHFSTAB GetUSBHPmodZ
./rootAVD.sh system-images/android-30/android-automotive-playstore/x86_64/ramdisk.img restore
./rootAVD.sh system-images/android-30/android-automotive-playstore/x86_64/ramdisk.img InstallKernelModules
./rootAVD.sh system-images/android-30/android-automotive-playstore/x86_64/ramdisk.img InstallPrebuiltKernelModules
./rootAVD.sh system-images/android-30/android-automotive-playstore/x86_64/ramdisk.img InstallPrebuiltKernelModules GetUSBHPmodZ PATCHFSTAB DEBUG
./rootAVD.sh system-images/android-30/android-automotive-playstore/x86_64/ramdisk.img AddRCscripts

./rootAVD.sh system-images/android-29/android-automotive-playstore/x86/ramdisk.img
./rootAVD.sh system-images/android-29/android-automotive-playstore/x86/ramdisk.img FAKEBOOTIMG
./rootAVD.sh system-images/android-29/android-automotive-playstore/x86/ramdisk.img DEBUG PATCHFSTAB GetUSBHPmodZ
./rootAVD.sh system-images/android-29/android-automotive-playstore/x86/ramdisk.img restore
./rootAVD.sh system-images/android-29/android-automotive-playstore/x86/ramdisk.img InstallKernelModules
./rootAVD.sh system-images/android-29/android-automotive-playstore/x86/ramdisk.img InstallPrebuiltKernelModules
./rootAVD.sh system-images/android-29/android-automotive-playstore/x86/ramdisk.img InstallPrebuiltKernelModules GetUSBHPmodZ PATCHFSTAB DEBUG
./rootAVD.sh system-images/android-29/android-automotive-playstore/x86/ramdisk.img AddRCscripts

Windows

Command Examples:
rootAVD.bat
rootAVD.bat ListAllAVDs
rootAVD.bat InstallApps

rootAVD.bat system-images\android-33\google_apis_playstore\x86_64\ramdisk.img
rootAVD.bat system-images\android-33\google_apis_playstore\x86_64\ramdisk.img FAKEBOOTIMG
rootAVD.bat system-images\android-33\google_apis_playstore\x86_64\ramdisk.img DEBUG PATCHFSTAB GetUSBHPmodZ
rootAVD.bat system-images\android-33\google_apis_playstore\x86_64\ramdisk.img restore
rootAVD.bat system-images\android-33\google_apis_playstore\x86_64\ramdisk.img InstallKernelModules
rootAVD.bat system-images\android-33\google_apis_playstore\x86_64\ramdisk.img InstallPrebuiltKernelModules
rootAVD.bat system-images\android-33\google_apis_playstore\x86_64\ramdisk.img InstallPrebuiltKernelModules GetUSBHPmodZ PATCHFSTAB DEBUG
Command Examples: for ALL installed AVDs
rootAVD.bat system-images\android-33\google_apis_playstore\x86_64\ramdisk.img
rootAVD.bat system-images\android-33\google_apis_playstore\x86_64\ramdisk.img FAKEBOOTIMG
rootAVD.bat system-images\android-33\google_apis_playstore\x86_64\ramdisk.img DEBUG PATCHFSTAB GetUSBHPmodZ
rootAVD.bat system-images\android-33\google_apis_playstore\x86_64\ramdisk.img restore
rootAVD.bat system-images\android-33\google_apis_playstore\x86_64\ramdisk.img InstallKernelModules
rootAVD.bat system-images\android-33\google_apis_playstore\x86_64\ramdisk.img InstallPrebuiltKernelModules
rootAVD.bat system-images\android-33\google_apis_playstore\x86_64\ramdisk.img InstallPrebuiltKernelModules GetUSBHPmodZ PATCHFSTAB DEBUG

rootAVD.bat system-images\android-25\google_apis_playstore\x86_64\ramdisk.img
rootAVD.bat system-images\android-25\google_apis_playstore\x86_64\ramdisk.img FAKEBOOTIMG
rootAVD.bat system-images\android-25\google_apis_playstore\x86_64\ramdisk.img DEBUG PATCHFSTAB GetUSBHPmodZ
rootAVD.bat system-images\android-25\google_apis_playstore\x86_64\ramdisk.img restore
rootAVD.bat system-images\android-25\google_apis_playstore\x86_64\ramdisk.img InstallKernelModules
rootAVD.bat system-images\android-25\google_apis_playstore\x86_64\ramdisk.img InstallPrebuiltKernelModules
rootAVD.bat system-images\android-25\google_apis_playstore\x86_64\ramdisk.img InstallPrebuiltKernelModules GetUSBHPmodZ PATCHFSTAB DEBUG

rootAVD.bat system-images\android-25\google_apis_playstore\armeabi-v7a\ramdisk.img
rootAVD.bat system-images\android-25\google_apis_playstore\armeabi-v7a\ramdisk.img FAKEBOOTIMG
rootAVD.bat system-images\android-25\google_apis_playstore\armeabi-v7a\ramdisk.img DEBUG PATCHFSTAB GetUSBHPmodZ
rootAVD.bat system-images\android-25\google_apis_playstore\armeabi-v7a\ramdisk.img restore
rootAVD.bat system-images\android-25\google_apis_playstore\armeabi-v7a\ramdisk.img InstallKernelModules
rootAVD.bat system-images\android-25\google_apis_playstore\armeabi-v7a\ramdisk.img InstallPrebuiltKernelModules
rootAVD.bat system-images\android-25\google_apis_playstore\armeabi-v7a\ramdisk.img InstallPrebuiltKernelModules GetUSBHPmodZ PATCHFSTAB DEBUG

Notes

  • 64 Bit Only Systems needs Magisk 23.x
  • In the Menu, you can choose between the newest Magisk, Canary, Stable and Alpha, Version.
  • With the new Option s, you can see and download any other Versions of Magisk
  • Once choosen, the script will make that Version to your local one.
  • Prebuilt Kernel and Modules will be pulled from AOSP
  • Starting Magisk from Terminal via adb shell monkey -p com.topjohnwu.magisk -c android.intent.category.LAUNCHER 1
  • API 28 (Pie) is not supported at all -> because
  • Magisk Versions >= 26.x can only be proper installed with the FAKEBOOTIMG argument
  • Android 14 needs Magisk Version >= 26.x to be rooted

ANDROID_HOME

  • Default location can be overwritten by setting the ANDROID_HOME variable
  • In both cases, the script will search in it for AVD system-images and adb binarys
  • ANDROID_HOME Sets the path to the SDK installation directory -> AOSP Variables reference

Notes for Apk Developers

Fake Boot.img Function

  • During runtime, the script will launch the Magisk APK so that you can patch the fake Boot.img within 60s
  • The script also detects if there is already a patched Boot.img present
  • This feature lets you also update and switch between Magisk Versions
    • Updating a patched ramdisk will delete the overlay.d folder, all mods are gone!
  • If Magisk can't open a file manager, i.e. on Automotive AVDs,
  • The script switches to user 0, so that you can see /sdcard/Download/fakeboot.img

2 Ways to boot the AVD into Safe Mode

  • 1st Way - If the AVD still boots normal:
    • Tap and Hold the Power Button until the 3 Options appear
    • Tap and Hold the Power Off Button until Reboot to safe mode appears
  • 2nd Way - If the AVD stuck while booting (black screen):
    • Tap and Hold the Volume Down Button
    • The Time Window is between the Launching Emulator Bar is approx half way until the Google Boot Screen appears
  • Confirmation
    • On the Bottom Left Corner reads: Safe mode

Automotive Notes

  • After patching the ramdisk.img and cycle power, switch to user 0 via adb shell am switch-user 0
    • open the Magisk App and the Requires Additional Setup pops up -> reboot AVD
    • switch again to user 0
      • open the Magisk App -> Settings -> Multiuser Mode -> User-Independent -> reboot AVD
  • Every time you want to Grant Su Permissions, switch to user 0 and then back to 10 adb shell am switch-user 10
  • Alternative, you can install the Module Magisk Single User Mod
    • and remove all user higher than 0 i.e. adb shell pm remove-user 13 or adb shell pm remove-user 10

BlueStacks 4 Notes on MacOs

  • Modules are working
  • Zygisk doesn't work
  • The Home Screen Apk closes as soon as Magisk APP is installed
    • but you can start Magisk from Terminal via adb shell monkey -p com.topjohnwu.magisk -c android.intent.category.LAUNCHER 1
    • and Hide the Magisk APP to Settings i.e.
  • ADB Connection is very buggy, adb kill-server is necessary quite often

Links

XDA [GUIDE] How to [Build|Mod|Update] a custom AVD Kernel and its Modules

How to root AVDs without Play Store (Google APIs) out of the box

Windows

  • open a terminal -> win + r cmd
    • add emulator to your PATH
    • find your AVD
    • launch your AVD with the -writable-system argument
     set PATH=%LOCALAPPDATA%\Android\Sdk\emulator;%PATH%
     emulator -list-avds
     	Pixel_4_API_29
     emulator -avd Pixel_4_API_29 -writable-system
    
  • open a 2nd terminal -> win + r cmd
    • enter the following commands one by one
     set PATH=%LOCALAPPDATA%\Android\Sdk\platform-tools;%PATH%
     adb root
     adb shell avbctl disable-verification
     adb disable-verity
     adb reboot
     adb root
     adb remount
     adb shell
     generic_x86_64:/ #
    
Archive ### Magisk v23.0 Alpha Successfully tested with Stock Kernel on * [[Oct. 2021] - Android 12 (S) API 32 Google Apis Play Store x86_64 Sv2 r01 Windows Production Build](https://dl.google.com/android/repository/sys-img/google_apis_playstore/x86_64-Sv2_r01-windows.zip) * [[Oct. 2021] - Android 12 (S) API 32 Google Apis Play Store x86_64 Sv2 r01 Darwin/MacOS Production Build](https://dl.google.com/android/repository/sys-img/google_apis_playstore/x86_64-Sv2_r01-darwin.zip) * [[Oct. 2021] - Android 12 (S) API 31 Google Apis Play Store ARM 64 v8a r08 (M1) Darwin/MacOS Production Build](https://dl.google.com/android/repository/sys-img/google_apis_playstore/arm64-v8a-31_r08-darwin.zip) * [[Oct. 2021] - Android 11 (R) API 30 Google Apis Play Store ARM 64 v8a r10 (M1) Darwin/MacOS Production Build](https://dl.google.com/android/repository/sys-img/google_apis_playstore/arm64-v8a-30_r10-darwin.zip) * [[Oct. 2021] - Android 12 (S) API 31 Google Apis Play Store x86_64 r08 Darwin/MacOS Production Build](https://dl.google.com/android/repository/sys-img/google_apis_playstore/x86_64-31_r08-darwin.zip) * [[Oct. 2021] - Android 11 (R) API 30 Google Apis Play Store x86 r09 Darwin/MacOS Production Build](https://dl.google.com/android/repository/sys-img/google_apis_playstore/x86-30_r09-darwin.zip) * [[Oct. 2021] - Android 11 (R) API 30 Google Apis Play Store x86_64 r10 Darwin/MacOS Production Build](https://dl.google.com/android/repository/sys-img/google_apis_playstore/x86_64-30_r10-darwin.zip)

Magisk v22.1+ Successfully tested with Stock Kernel on

Change Logs

[August 2023]

  • [rootAVD.sh] - Added Pagesize Padding in the fakeboot.img
  • [rootAVD.sh] - Updated the creation of the fakeboot.img
  • [rootAVD.sh] - Added another way of checking the AVDs Internet connection

[July 2023]

  • [rootAVD.bat] - Fixed file ListAllAVDs not found bug
  • [rootAVD.bat] - Fixed some errors with double spaces
  • [rootAVD.bat] - Added TestADBWORKDIR routine

[June 2023]

  • [rootAVD.sh] - improved finding BusyBox routine, and once again
  • [rootAVD.sh] - rewritten the file and folder handling entirely, Darwin and Linux
  • [rootAVD.sh] - improved finding BusyBox routine, again
  • [General] - Added .gitattributes with *.sh text eol=lf to force UNIX line ending on Windows
  • [rootAVD.bat] - rewritten the file and folder handling entirely
  • [rootAVD.bat] - fixed typos and bug fixes
  • [rootAVD.bat] - updated the TestADB routine, adb path will now be set automatically
  • [rootAVD.bat] - updated Exit calls
  • [General] - updated the README.md

[May 2023]

  • [rootAVD.sh] - removed Busybox from Script

[April 2023]

  • [General] - added link to X-plore file manager
  • [General] - added link to Magisk Single User Mod
  • [General] - added switching to user 0 when running FAKEBOOTIMG
  • [rootAVD.bat] - changed return 1 to return 0
  • [rootAVD.sh] - changed return 1 to return 0
  • [rootAVD.sh] - changed copy and move routine
  • [rootAVD.sh] - added support for ramdisk-qemu.img
Archive

Change Logs

[December 2022]

  • [rootAVD.sh] - Fixed arithmetic syntax error in decompress_ramdisk

[November 2022]

  • [General] - Bug fixes
  • [General] - Updated to Magisk Stable Version 25.2
  • [General] - Added FAKEBOOTIMG Use Case Examples as Gif
  • [rootAVD.sh] - Added support for adding the stub.apk if present
  • [General] - Added support for already patched ramdisk files
  • [General] - removed the EnvFixTask Argument
  • [General] - Bug fixes
  • [rootAVD.sh] - Added FAKEBOOTIMG Argument that creates a fake Boot.img which can be patched directed from the Magisk APK

[March 2022]

  • [rootAVD.sh] - Added toggleRamdisk Argument that toggles between patched and stock ramdisk
  • [rootAVD.sh] - Changed the need of a Magisk.zip file
  • [General] - Added Use Case Examples as Gif
  • [General] - Added Option to Download older Magisk Versions
  • [rootAVD.sh] - Added BlueStacks 4 Support on MacOS
  • [General] - Bug fixes

[February 2022]

  • [General] - Updated to Magisk Stable Version 24.1

[October 2021]

  • [rootAVD.sh] - Added get Up-To-Date Script Routine if Script is broken
  • [rootAVD.sh] - Updated LZ4 decompression Routine
  • [rootAVD.sh] - Updated InstallPrebuiltKernelModules Routine to support ARM64 Kernels
  • [rootAVD.sh] - Updated Busybox Extraction Routine
  • [General] - Added Multiarch Busybox Binarys and 64-Bit Only Support
  • [General] - Added Alpha Channel to the Menu
  • [rootAVD.bat] - Added Shut Down Feature
  • [rootAVD.sh] - Added Shut Down Feature
  • [General] - Added Android 12 (S) API 31 Status
  • [General] - Added Link to Android AppSecs Video about rootAVD

[July 2021]

  • [rootAVD.bat] - Changed TestADB
  • [General] - Added rootCROS Project to Links

[June 2021]

  • [General] - Android 12 (S) r05

[May 2021]

  • [General] - Updated to Magisk App v23.0
  • [rootAVD.sh] - Added "AddRCscripts" Argument that *install all custom .rc scripts, placed in the rootAVD folder, into ramdisk.img/overlay.d/sbin
  • [rootAVD.sh] - Added BusyBox Binary after the rootAVD script
  • [rootAVD.bat] - Added ListAllAVDs and InstallApps as Arguments
  • [rootAVD.sh] - Added "ListAllAVDs" Argument that Lists Command Examples for ALL installed AVDs
  • [rootAVD.sh] - Added "InstallApps" Argument to Just install all APKs placed in the Apps folder
  • [rootAVD.bat] - Added comprehensive Help Menu

[Apr. 2021]

  • [General] - Added comprehensive Help Menu
  • [rootAVD.sh] - Changed "DEBUG" "PATCHFSTAB" "GetUSBHPmodZ" to Arguments
  • [General] - Fixed some typos and functions
  • [rootAVD.sh] - Add a Menu to choose the prebuilt Kernel and Modules Version to install
  • [General] - Added "InstallPrebuiltKernelModules" download/update/install prebuilt kernel and modules
  • [General] - Added 2 Ways to boot the AVD into Safe Mode
  • [rootAVD.sh] - Added Android S rev 3 support
  • [General] - Added "InstallKernelModules" update/install custom build kernel and modules
  • [rootAVD.sh] - Added update_lib_modules function
  • [General] - Added "restore" to put back your backup files
  • [General] - Updated local Magisk App v22.1
  • [rootAVD.sh] - Added Option to Download the USB HOST Permissions Module

[Mar. 2021]

  • [General] - Add a Download Manager Function for bad TLS record using wget
  • [rootAVD.bat] - Adjustments to run with the updated rootAVD.sh
  • [General] - Add a Menu to choose the Magisk Version to install
  • [rootAVD.sh] - Added EnvFixTask Argument to fix Requires Additional Setup in Android S
  • [General] - Changed to BusyBox (D)ASH Standalone
  • [General] - Re-Structured Script
  • [rootAVD.sh] - Added "Additional Setup Required" manually for Android S
  • [rootAVD.sh] - Updated shakalaca's Ramdisk Repack Routine
  • [rootAVD.sh] - Added Compression Detection for LZ4 and GZ
  • [General] - Fixed some bugs and typos
  • [General] - Updated to Magisk App v22.0

Magisk v21.4 Successfully tested with Stock Kernel on

Credits

rootavd's People

Contributors

newbit1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rootavd's Issues

Request for latest version including the zip

I previously installed the 24.1 version provided in this repo but now unable to upgrade the zip to 25.2 version
I chose the latest version from the options in .sh file but still the magisk app is showing prev version
Also, upgrading from magisk app is not working somehow.
Therefore requesting a fix and an updated zip
thanks

APPLE SILICON(M1) MONTEREY ROOT ERROR

OS: macOS Monterey 12.0.1 arm64
CPU: Apple M1

When I run the program, I get the following error. Even though I tried version 30 and 31, I get the same error. How can I solve this problem?
After downloading the apk version of Magisk from its site, should I install it in the APP folder?
https://magiskmanager.com/downloading-magisk-manager/

Can you help with this?

1

USAGE COMMAND

sudo bash rootAVD.sh /Users/cmd/Library/Android/sdk/system-images/android-30/google_apis/arm64-v8a/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
[-] Magisk installer Zip exists already
[*] Cleaning up the ADB working space
[*] Creating the ADB working space
[*] Push Magisk.zip into /data/data/com.android.shell/Magisk
[-] ./Magisk.zip: 1 file pushed, 0 skipped. 225.3 MB/s (6874374 bytes in 0.029s)
[-] ramdisk.img Backup exists already
[*] Push ramdisk.img into /data/data/com.android.shell/Magisk
[-] /Users/cmd/Library/Android/sdk/system-images/android-30/google_apis/arm64-v8a/ramdisk.img: 1 file pushed, 0 skipped. 300.9 MB/s (1557267 bytes in 0.005s)
[*] Push rootAVD.sh into /data/data/com.android.shell/Magisk
[-] rootAVD.sh: 1 file pushed, 0 skipped. 220.1 MB/s (7826127 bytes in 0.034s)
[-] run the actually Boot/Ramdisk/Kernel Image Patch Script
[*] from Magisk by topjohnwu and modded by NewBit XDA
[!] We are in an emulator shell
[-] Api Level Arch Detect
[-] Device Platform is arm64 only
[-] Device SDK API: 30
[-] First API Level: 30
[-] Switch to the location of the script file
[*] Extracting busybox and Magisk.zip ...
[*] Extracting busybox from script ...
[!] Found a working busybox Binary:
[!] BusyBox v1.33.1-Magisk (2021-05-08 15:20:41 PDT) multi-call binary.
[-] Checking AVDs Internet connection...
[!] AVD is offline
[*] 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 '23.0' Installer
[-] Get Flags
[*] System-as-root, keep dm/avb-verity
[-] Encrypted data, keep forceencrypt
[*] RECOVERYMODE=false
[-] KEEPVERITY=true
[*] KEEPFORCEENCRYPT=true
[*] No 64-Bit Binarys found, please consider Magisk Alpha
[-] 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
[-] API level greater then 30
[*] Check if we need to repack ramdisk before patching ..
[-] Multiple cpio archives detected
[*] Unpacking ramdisk ..
[-] Dumping from 0 to 1832688 ..
[-] Dumping from 1832704 to 4632124 ..
[*] Repacking ramdisk ..
[-] Deleting system ramdisk build.prop
[-] Test patch status and do restore
[-] Checking ramdisk status
[-] STATUS=2
[!] Boot image patched by unsupported programs
[!] Please restore back to stock boot image
[!] aborting the script

mac m1 run rootAVD error

Hi, I use rootAVD run on my android virtual devices, and found the error as follow, I'm use mac m1, the avd is arm64, please help.
Thanks.

./rootAVD.sh ~/Library/Android/sdk/system-images/android-32/google_apis_playstore/arm64-v8a/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
[-] Magisk installer Zip exists already
[*] Cleaning up the ADB working space
[*] Creating the ADB working space
[*] Push Magisk.zip into /data/data/com.android.shell/Magisk
[-] ./Magisk.zip: 1 file pushed, 0 skipped. 184.5 MB/s (6874374 bytes in 0.036s)
[-] ramdisk.img Backup exists already
[*] Push ramdisk.img into /data/data/com.android.shell/Magisk
[-] /Users/zhaozhiming/Library/Android/sdk/system-images/android-32/google_apis_playstore/arm64-v8a/ramdisk.img: 1 file pushed, 0 skipped. 191.3 MB/s (4068420 bytes in 0.020s)
[*] Push rootAVD.sh into /data/data/com.android.shell/Magisk
[-] rootAVD.sh: 1 file pushed, 0 skipped. 248.7 MB/s (7826127 bytes in 0.030s)
[-] run the actually Boot/Ramdisk/Kernel Image Patch Script
[*] from Magisk by topjohnwu and modded by NewBit XDA
[!] We are in an emulator shell
[-] Api Level Arch Detect
[-] Device Platform is arm64 only
[-] Device SDK API: 32
[-] First API Level: 31
[-] Switch to the location of the script file
[*] Extracting busybox and Magisk.zip ...
[*] Extracting busybox from script ...
[!] Found a working busybox Binary:
[!] BusyBox v1.33.1-Magisk (2021-05-08 15:20:41 PDT) multi-call binary.
[-] Checking AVDs Internet connection...
[!] AVD is online
[!] Checking available Magisk Versions
[?] Choose a Magisk Version to install and make it local
[1] Local '23.0' (ENTER)
[2] Canary 1a1b346c(24102)
[3] Stable 24.1
[4] Alpha d021bca6-alpha(24102)
[1] You choose Magisk Local Version '23.0'
[*] 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 '23.0' Installer
[-] Get Flags
[*] System-as-root, keep dm/avb-verity
[-] Encrypted data, keep forceencrypt
[*] RECOVERYMODE=false
[-] KEEPVERITY=true
[*] KEEPFORCEENCRYPT=true
[*] No 64-Bit Binarys found, please consider Magisk Alpha
[-] 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 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 1379130 ..
/data/data/com.android.shell/Magisk/magiskboot: line 1: syntax error: unexpected word (expecting ")")
[-] Dumping from 1379130 to 4068401 ..
/data/data/com.android.shell/Magisk/magiskboot: line 1: syntax error: unexpected word (expecting ")")
[*] Repacking ramdisk ..
[-] Deleting system ramdisk build.prop
[-] Test patch status and do restore
[-] Checking ramdisk status
[-] STATUS=2
[!] Boot image patched by unsupported programs
[!] Please restore back to stock boot image
[!] aborting the script

rootAVD.bat does not install apps

rootAVD.bat C:\Android\system-images\android-33\google_apis\x86_64\ramdisk.img does not perform any visible change to the system

abd has been added to the PATH, the AVD is open and connected, adb shell works perfectly fine

Here is the output from attempting rootAVD.bat C:\Android\system-images\android-33\google_apis\x86_64\ramdisk.img :

[*] Set Directorys
[-] Test if ADB SHELL is working

This is the same output that occurs when providing the script with a ramdisk.img file

stuck at "Trying to install APPs/*" phase

macOS Big Sur 11.6.1, when executing all command lines in README.md, I'm stuck at "Trying to install APPs/*"

Specifically, this happends when executing command ./rootAVD.sh InstallApps.
image

Windows "unzip" command does not exist

On my first run through, trying to execute the batch file failed because the "unzip" command isn't native to Windows 10. If you want to make a requirement of Windows 10 build 17063 or later, you can use:

	md %ROOTAVD%\Magisk
tar -xf magisk.zip --directory %ROOTAVD%\Magisk

Otherwise you should add a requirement for getting some kind of "unzip" command first. I didn't submit this as a change b/c it will depend on your desire for how to handle prerequisites.

Black Screen after successful run

First need to say that I checked similar issues and it did not help

I am using Mac M1 and I tried to run the script with 2 different API 30 and 33, same results, after my emulator and adb closed due reloading I can't get into it, I see only a black screen and after 300 second it shot down

I tried to use restore argument did not help

Help please :)

Ask me any questions if needed, here is some screenshots of my last run with API 33 (Actually here i tried to run the script twice just in case maybe it will help)

Screenshot 2023-01-31 at 17 39 32

Screenshot 2023-01-31 at 17 39 38

Error with Magisk - INSTALL_FAILED_VERIFICATION_FAILURE

I have a specific use case wherein the system with the AVD is offline and cannot come online. I've tried running the script and it seems to work well until the end:

~rootAVD-master>.\rootAVD.bat \AppData\Local\Android\Sdk\system-images\android-30\google_apis_playstore\x86\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
[-]\rootAVD-master\Magisk.zip: 1 file pushed, 0 skipped. 257.2 MB/s (6874374 bytes in 0.025s)
[
] create Backup File
[] Push ramdisk.img into /data/data/com.android.shell/Magisk
[-] \AppData\Local\Android\Sdk\system-images\android-30\google_apis_playstore\x86\ramdisk.img: 1 file pushed, 0 skipped. 323.0 MB/s (1300381 bytes in 0.004s)
[-] Copy rootAVD Script into Magisk DIR
rootAVD.sh: 1 file pushed, 0 skipped. 120.9 MB/s (7826127 bytes in 0.062s)
[-] run the actually Boot/Ramdisk/Kernel Image Patch Script
[
] from Magisk by topjohnwu and modded by NewBit XDA
[!] We are in an emulator shell
[-] Api Level Arch Detect
[-] Device Platform is x86 only
[-] Device SDK API: 30
[-] First API Level: 30
[-] Switch to the location of the script file
[] Extracting busybox and Magisk.zip ...
[-] Checking AVDs Internet connection...
[!] AVD is offline
[
] 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 '23.0' Installer
[-] Get Flags
[
] System-as-root, keep dm/avb-verity
[-] Encrypted data, keep forceencrypt
[] RECOVERYMODE=false
[-] KEEPVERITY=true
[
] KEEPFORCEENCRYPT=true
[-] copy all x86 files from /data/data/com.android.shell/Magisk/lib/x86 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 ..
[-] Multiple cpio archives detected
[
] Unpacking ramdisk ..
[-] Dumping from 0 to 1729528 ..
[-] Dumping from 1729536 to 3858348 ..
[] Repacking ramdisk ..
[-] Deleting system ramdisk build.prop
[-] 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/magisk32.xz] (0644)
Patch with flag KEEPVERITY=[true] KEEPFORCEENCRYPT=[true]
Loading cpio: [ramdisk.cpio.orig]
Backup mismatch entry: [init] -> [.backup/init]
Record new entry: [overlay.d] -> [.backup/.rmlist]
Record new entry: [overlay.d/sbin] -> [.backup/.rmlist]
Record new entry: [overlay.d/sbin/magisk32.xz] -> [.backup/.rmlist]
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. 297.7 MB/s (1596324 bytes in 0.005s
[] Pull Magisk.apk into
[-] /data/data/com.android.shell/Magisk/Magisk.apk: 1 file pulled, 0 skipped. 361.2 MB/s (6874374 bytes in 0.018s
[-] Clean up the ADB working space
[-] Install all APKs placed in the Apps folder
[
] Trying to install APPS\Magisk.apk
[-] adb: failed to install APPS\Magisk.apk: Failure [INSTALL_FAILED_VERIFICATION_FAILURE]
[-] Performing Streamed Install
[-] 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!

Is there a way to get around this verification check offline?

arithmetic syntax error

Tried with latest magisk version and v24.3

/data/data/com.android.shell/Magisk/rootAVD.sh: line 1300: arithmetic syntax error

[!] 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. 426.2 MB/s (10878069 bytes in 0.024s)
[-] ramdisk.img Backup exists already
[*] Push ramdisk.img into /data/data/com.android.shell/Magisk
[-] /home/kiko/Android/Sdk/system-images/android-31/google_apis/x86_64/ramdisk.img: 1 file pushed, 0 skipped. 496.5 MB/s (3685297 bytes in 0.007s)
[*] Push rootAVD.sh into /data/data/com.android.shell/Magisk
[-] rootAVD.sh: 1 file pushed, 0 skipped. 226.4 MB/s (7855770 bytes in 0.033s)
[-] 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
[*] 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] (s)how all available Magisk Versions
[1] local stable '24.3' (ENTER)
[2] stable 25.2
[3] canary a468fd94(25205)
[4] alpha 44643ad7-alpha(25205)
1
[-] You choose Magisk local stable Version '24.3'
[*] Re-Run rootAVD in Magisk Busybox STANDALONE (D)ASH
[-] We are now in Magisk Busybox STANDALONE (D)ASH
[*] rootAVD with Magisk '24.3' 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 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 1691780 ..
Detected format: [lz4_legacy]
[-] Dumping from 1691780 to 3685278 ..
Detected format: [lz4_legacy]
/data/data/com.android.shell/Magisk/rootAVD.sh: line 1300: arithmetic syntax error

No root after Success

  1. try running it
  2. cold boot
  3. "Super User" still is grayed out in the Magisk app. No root access.

Any ideas?

C:\Users\Meerkov\source\repos\rootAVD>rootAVD.bat C:\Users\Meerkov\AppData\Local\Android\Sdk\system-images\android-28\google_apis_playstore\x86\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:\Users\Meerkov\source\repos\rootAVD\Magisk.zip: 1 file pushed, 0 skipped. 322.9 MB/s (10641074 bytes in 0.031s)
[*] create Backup File
[*] Push ramdisk.img into /data/data/com.android.shell/Magisk
[-] C:\Users\Meerkov\AppData\Local\Android\Sdk\system-images\android-28\google_apis_playstore\x86\ramdisk.img: 1 file pushed, 0 skipped. 351.9 MB/s (1701411 bytes in 0.005s)
[-] Copy rootAVD Script into Magisk DIR
rootAVD.sh: 1 file pushed, 0 skipped. 408.4 MB/s (7847772 bytes in 0.018s)
[-] 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 x86 only
[-] Device SDK API: 28
[-] First API Level: 28
[-] The AVD runs on Android 9
[-] 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
[-] Checking AVDs Internet connection...
[!] AVD is offline
[*] Extracting Magisk.zip ...
/data/data/com.android.shell/Magisk/rootAVD.sh[2312]: /data/data/com.android.shell/Magisk/busybox: can't execute: Permission denied
[*] Re-Run rootAVD in Magisk Busybox STANDALONE (D)ASH
[-] We are now in Magisk Busybox STANDALONE (D)ASH
[*] rootAVD with Magisk  Installer
[-] Get Flags
[*] System-as-root, keep dm/avb-verity
[-] Encrypted data, keep forceencrypt
[*] RECOVERYMODE=true
[-] KEEPVERITY=true
[*] KEEPFORCEENCRYPT=true
[-] copy all x86 files from /data/data/com.android.shell/Magisk/lib/x86 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]
[-] 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/magisk32.xz] (0644)
Patch with flag KEEPVERITY=[true] KEEPFORCEENCRYPT=[true]
Loading cpio: [ramdisk.cpio.orig]
Backup mismatch entry: [init] -> [.backup/init]
Record new entry: [overlay.d] -> [.backup/.rmlist]
Record new entry: [overlay.d/sbin] -> [.backup/.rmlist]
Record new entry: [overlay.d/sbin/magisk32.xz] -> [.backup/.rmlist]
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. 178.6 MB/s (2024654 bytes in 0.011s
[*] Pull Magisk.apk into
[-] /data/data/com.android.shell/Magisk/Magisk.apk: 1 file pulled, 0 skipped. 129.1 MB/s (10641074 bytes in 0.079s
[-] 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!

Script problem with Split APK's

The script seems to hang indefinitely when split APK's are brought into the equation. Any ideas to get around this?

  • I am using the following command: sudo ./rootAVD.sh ~/Library/Android/sdk/system-images/android-33/google_apis/arm64-v8a/ramdisk.img
  • I am also on Mac OS
  • The message that it is hanging on is "Trying to install Apps/split_config.arm64.apk"
  • The base APK is able to be transferred but not any of the APK's
  • I removed the split APK's from /App and the base APK was transferred. But, the moment I placed them back, the script would hang again

find: unknown predicate `-s'

It seems that starting from commit 374cd5d, the script is unable to automatically detect the ramdisk.img in ANDROID_SDK_ROOT (only occurs on Linux). Based on this manpage, the -s switch in find doesn't exist on Linux. This switch seems to be specific to BSD-like OSes (macOS).

line 1155:
for SI in $(find -s $SYSIM_DIR -type f -iname ramdisk.img); do

tput: unknown terminal "xterm-256color"
tput: unknown terminal "xterm-256color"
rootAVD A Script to root AVD by NewBit XDA

Usage:	rootAVD [DIR/ramdisk.img] [OPTIONS] | [EXTRA_CMDS]
or:	rootAVD [ARGUMENTS]

Arguments:
	ListAllAVDs			Lists Command Examples for ALL installed AVDs

	EnvFixTask			Requires Additional Setup fix
					- construct Magisk Environment manual
					- only works with an already Magisk patched ramdisk.img
					- without [DIR/ramdisk.img] [OPTIONS] [PATCHFSTAB]
					- needed since Android 12 (S) rev.1
					- Grant Shell Su Permissions will pop up a few times
					- the AVD will reboot automatically

	InstallApps			Just install all APKs placed in the Apps folder

Main operation mode:
	DIR				a path to an AVD system-image
					- must always be the 1st Argument after rootAVD
	
ADB Path | Ramdisk DIR:
	[M]ac/Darwin:			export PATH=~/Library/Android/sdk/platform-tools:$PATH
					~/Library/Android/sdk/system-images/android-$API/google_apis_playstore/x86_64/
	
	[L]inux:			export PATH=~/Android/Sdk/platform-tools:$PATH
					~/Android/Sdk/system-images/android-$API/google_apis_playstore/x86_64/
	
	[W]indows:			set PATH=%LOCALAPPDATA%\Android\Sdk\platform-tools;%PATH%
					%LOCALAPPDATA%\Android\Sdk\system-images\android-$API\google_apis_playstore\x86_64\
	
	$API:				25,29,30,S,etc.
	
Except for EnvFixTask, ramdisk.img must be untouched (stock).
	
Options:
	restore				restore all existing .backup files, but doesn't delete them
					- the AVD doesn't need to be running
					- no other Argument after will be processed
	
	InstallKernelModules		install custom build kernel and its modules into ramdisk.img
					- kernel (bzImage) and its modules (initramfs.img) are inside rootAVD
					- both files will be deleted after installation
	
	InstallPrebuiltKernelModules	download and install an AOSP prebuilt kernel and its modules into ramdisk.img
					- similar to InstallKernelModules, but the AVD needs to be online
	
	AddRCscripts			install all custom *.rc scripts, placed in the rootAVD folder, into ramdisk.img/overlay.d/sbin
	
Options are exclusive, only one at the time will be processed.
	
Extra Commands:
	DEBUG				Debugging Mode, prevents rootAVD to pull back any patched file
	
	PATCHFSTAB			fstab.ranchu will get patched to automount Block Devices like /dev/block/sda1
					- other entries can be added in the script as well
					- a custom build Kernel might be necessary
	
	GetUSBHPmodZ			The USB HOST Permissions Module Zip will be downloaded into /sdcard/Download
	
Extra Commands can be combined, there is no particular order.
	
Notes: rootAVD will
- always create .backup files of ramdisk.img and kernel-ranchu
- replace both when done patching
- show a Menu, to choose the Magisk Version (Stable || Canary), if the AVD is online
- make the choosen Magisk Version to its local
- install all APKs placed in the Apps folder
	
Command Examples:
find: unknown predicate `-s'
./rootAVD.sh
./rootAVD.sh ListAllAVDs
./rootAVD.sh EnvFixTask
./rootAVD.sh InstallApps

parameter not running

./rootAVD.sh ~/Library/Android/sdk/system-images/android-32/google_apis_playstore/arm64-v8a/ramdisk.img

i try to run this command, but it never works. Output;

 ./rootAVD.sh EnvFixTask //its working, but not working because I dont running above code
rootAVD A Script to root AVD by NewBit XDA

Usage:  rootAVD [DIR/ramdisk.img] [OPTIONS] | [EXTRA_CMDS]
or:     rootAVD [ARGUMENTS]

Arguments:
        ListAllAVDs                     Lists Command Examples for ALL installed AVDs

        EnvFixTask                      Requires Additional Setup fix
                                        - construct Magisk Environment manual
                                        - only works with an already Magisk patched ramdisk.img
                                        - without [DIR/ramdisk.img] [OPTIONS] [PATCHFSTAB]
                                        - needed since Android 12 (S) rev.1
                                        - not needed anymore since Android 12 (S) API 31 and Magisk Alpha
                                        - Grant Shell Su Permissions will pop up a few times
                                        - the AVD will reboot automatically

        InstallApps                     Just install all APKs placed in the Apps folder

Main operation mode:
        DIR                             a path to an AVD system-image
                                        - must always be the 1st Argument after rootAVD
        
ADB Path | Ramdisk DIR:
        [M]ac/Darwin:                   export PATH=~/Library/Android/sdk/platform-tools:$PATH
                                        ~/Library/Android/sdk/system-images/android-$API/google_apis_playstore/x86_64/
        
        [L]inux:                        export PATH=~/Android/Sdk/platform-tools:$PATH
                                        ~/Android/Sdk/system-images/android-$API/google_apis_playstore/x86_64/
        
        [W]indows:                      set PATH=%LOCALAPPDATA%\Android\Sdk\platform-tools;%PATH%
                                        %LOCALAPPDATA%\Android\Sdk\system-images\android-$API\google_apis_playstore\x86_64\
        
        $API:                           25,29,30,S,etc.
        
Except for EnvFixTask, ramdisk.img must be untouched (stock).
        
Options:
        restore                         restore all existing .backup files, but doesn't delete them
                                        - the AVD doesn't need to be running
                                        - no other Argument after will be processed
        
        InstallKernelModules            install custom build kernel and its modules into ramdisk.img
                                        - kernel (bzImage) and its modules (initramfs.img) are inside rootAVD
                                        - both files will be deleted after installation
        
        InstallPrebuiltKernelModules    download and install an AOSP prebuilt kernel and its modules into ramdisk.img
                                        - similar to InstallKernelModules, but the AVD needs to be online
        
        AddRCscripts                    install all custom *.rc scripts, placed in the rootAVD folder, into ramdisk.img/overlay.d/sbin
        
Options are exclusive, only one at the time will be processed.
        
Extra Commands:
        DEBUG                           Debugging Mode, prevents rootAVD to pull back any patched file
        
        PATCHFSTAB                      fstab.ranchu will get patched to automount Block Devices like /dev/block/sda1
                                        - other entries can be added in the script as well
                                        - a custom build Kernel might be necessary
        
        GetUSBHPmodZ                    The USB HOST Permissions Module Zip will be downloaded into /sdcard/Download
        
Extra Commands can be combined, there is no particular order.
        
Notes: rootAVD will
- always create .backup files of ramdisk.img and kernel-ranchu
- replace both when done patching
- show a Menu, to choose the Magisk Version (Stable || Canary || Alpha), if the AVD is online
- make the choosen Magisk Version to its local
- install all APKs placed in the Apps folder
        
Command Examples:
./rootAVD.sh
./rootAVD.sh ListAllAVDs
./rootAVD.sh EnvFixTask
./rootAVD.sh InstallApps

./rootAVD.sh ~/Library/Android/sdk/system-images/android-32/google_apis_playstore/arm64-v8a/ramdisk.img
./rootAVD.sh ~/Library/Android/sdk/system-images/android-32/google_apis_playstore/arm64-v8a/ramdisk.img DEBUG PATCHFSTAB GetUSBHPmodZ
./rootAVD.sh ~/Library/Android/sdk/system-images/android-32/google_apis_playstore/arm64-v8a/ramdisk.img restore
./rootAVD.sh ~/Library/Android/sdk/system-images/android-32/google_apis_playstore/arm64-v8a/ramdisk.img InstallKernelModules
./rootAVD.sh ~/Library/Android/sdk/system-images/android-32/google_apis_playstore/arm64-v8a/ramdisk.img InstallPrebuiltKernelModules
./rootAVD.sh ~/Library/Android/sdk/system-images/android-32/google_apis_playstore/arm64-v8a/ramdisk.img InstallPrebuiltKernelModules GetUSBHPmodZ PATCHFSTAB DEBUG
./rootAVD.sh ~/Library/Android/sdk/system-images/android-32/google_apis_playstore/arm64-v8a/ramdisk.img AddRCscripts

Mac m2 Android7.1.1 - Extracting busybox from script...

After the attempt to “Extracting busybox from script” I've got the following log output:
Then no longer continue the execution

(base) ➜ rootAVD ./rootAVD.sh ~/Library/Android/sdk/system-images/android-25/default/arm64-v8a/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. 294.2 MB/s (10641074 bytes in 0.034s)
[-] ramdisk.img Backup exists already
[] Push ramdisk.img into /data/data/com.android.shell/Magisk
[-] /Users/soibhan/Library/Android/sdk/system-images/android-25/default/arm64-v8a/ramdisk.img: 1 file pushed, 0 skipped. 515.8 MB/s (1463744 bytes in 0.003s)
[
] Push rootAVD.sh into /data/data/com.android.shell/Magisk
[-] rootAVD.sh: 1 file pushed, 0 skipped. 365.5 MB/s (7850453 bytes in 0.020s)
[-] 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
[
] Extracting busybox from script ...

Other Android versions 10,11,12 are very well supported, but 7!

does installing this ramkdisk.img allow us to call "su" runtime on Android?

I follow the instructions exactly the same, and I was able to get everything right correctly.

The proof is that when I run su inside adb shell I see the $ changes to # and see the toast on Android Emulator saying the rights have been granted:

Screen Shot 2022-12-07 at 4 44 39 PM

However, when I run the following piece of code in Java,

try {
    Process p = Runtime.getRuntime().exec("su");
    DataOutputStream dos = new DataOutputStream(p.getOutputStream());
    dos.writeBytes("mkdir /sdcard/testdir\n");
    dos.writeBytes("exit\n");
    dos.flush();
    dos.close();
    p.waitFor();

} catch (IOException | InterruptedException e) {
    Log.d("MyNotificationListenerService", "Error 1");
    e.printStackTrace();
}

While I do not get any error, I do not see the testdir created. I do not even see the toast message. Basically, everything's bypassed with no error thrown. While this co

The emulator used:
Screen Shot 2022-12-07 at 4 45 30 PM

Note it uses Google Play Store, not Google Play API.

I am not sure if this is possible in the first place, I see lots of mixed results, some people saying they got it, some people saying they didn't.

I would appreciate any help to get me out of this sick rabbithole!

Magisk Alpha not installing properly

Hi,

it looks like the latest 3 releases of Magisk Alpha (44643ad7, 68874bf5, 555a54ec) are not installing properly on the official Android emulators (API 30/31/32). I only got 25201 to install properly, but then even the "Direct Install" method is failing to update to a newer version.

Even though the logs below show a successful execution, the Alpha application is installed, but the root is not present on the device.

Is it a known issue? What would it be the way to proceed to attempt a fix?

The execution log is the following:

./rootAVD.sh ~/Android/Sdk/system-images/android-32/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. 223.1 MB/s (11954242 bytes in 0.051s)
[-] ramdisk.img Backup exists already
[*] Push ramdisk.img into /data/data/com.android.shell/Magisk
[-] /home/matteo/Android/Sdk/system-images/android-32/google_apis/x86_64/ramdisk.img: 1 file pushed. 223.0 MB/s (3642849 bytes in 0.016s)
[*] Push rootAVD.sh into /data/data/com.android.shell/Magisk
[-] rootAVD.sh: 1 file pushed. 259.5 MB/s (7847286 bytes in 0.029s)
[-] 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: 32
[-] First API Level: 31
[-] The AVD runs on Android 12
[-] 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] (s)how all available Magisk Versions
[1] local stable '555a54ec-alpha'(25203) (ENTER)
[2] stable 25.2
[3] canary a468fd94(25205)
[4] alpha 44643ad7-alpha(25205)
4
[-] You choose Magisk alpha Version 44643ad7-alpha(25205)
[*] Deleting local Magisk '555a54ec-alpha'(25203)
[*] Downloading Magisk alpha 44643ad7-alpha(25205)
[!] Downloading Magisk alpha 44643ad7-alpha(25205) complete!
[-] Switch to the location of the script file
[*] Extracting busybox and Magisk.zip ...
[*] Re-Run rootAVD in Magisk Busybox STANDALONE (D)ASH
[-] We are now in Magisk Busybox STANDALONE (D)ASH
[*] rootAVD with Magisk 44643ad7-alpha(25205) 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 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 1692273 ..
Detected format: [lz4_legacy]
[-] Dumping from 1692273 to 3642830 ..
Detected format: [lz4_legacy]
[*] Repacking ramdisk ..
[-] 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)
[*] repacking back to ramdisk.img format
[!] Copy Magisk.zip to Magisk.apk
[*] Pull ramdiskpatched4AVD.img into ramdisk.img
[-] /data/data/com.android.shell/Magisk/ramdiskpatched4AVD.img: 1 file pulled. 195.6 MB/s (3643110 bytes in 0.018s)
[*] Pull Magisk.apk into 
[-] /data/data/com.android.shell/Magisk/Magisk.apk: 1 file pulled. 203.9 MB/s (11874417 bytes in 0.056s)
[*] Pull Magisk.zip into .
[-] /data/data/com.android.shell/Magisk/Magisk.zip: 1 file pulled. 202.8 MB/s (11874417 bytes in 0.056s)
[-] 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

Thanks

separate dependencies

magisk and busybox should be downloaded locally and then pushed to avd.
in case of busybox, one can check the checksum and confirm the authenticity, rather than obfuscating busybox in the code. as an extra advantage, you make sure latest busybox is being used

For example:

download_dep.sh

#!/bin/sh

# DOWNLOAD MAGISK
username="topjohnwu"
repo="Magisk"

# latest stable
# magisk_URL=$(curl -s https://api.github.com/repos/$username/$repo/releases/latest | grep "browser_download_url" | grep -v stub | awk -F ['"'] '{print $4}')

# canary more compatible
magisk_URL="https://raw.githubusercontent.com/topjohnwu/magisk-files/canary/app-debug.apk"

echo "$magisk_URL"

curl -L -o magisk.apk "$magisk_URL"

# DOWNLOAD BUSYBOX

username="Magisk-Modules-Repo"
repo="busybox-ndk"

busybox_URL="https://github.com/$username/$repo/raw/master/busybox-x86_64-selinux"

curl -L -o busybox "$busybox_URL"

How to enter safe mode when boot fails

Hmmm, in fact I have successfully entered safe mode (so that all magisk modules got disabled), by pressing volume down button.

However it seemed to be more tricky than expected. I tried pressing the volume down button since the emulator started, however sometimes it didn't enter safe mode. I then tried to repeat "releasing & immediately pressing down the button" every few seconds, it then seemed to work, however I still don't know the details.

API 28

Magisk patched boot image detected
[-] Constructing environment - PAY ATTENTION to the AVDs Screen
[!] not root yet
[!] Couldn't construct environment
[!] Double Check Root Access
[!] Re-Run Script with clean ramdisk.img and try again
[!] aborting the script

Can't seem to make it work with BLUESTACKS

after doing ./rootAVD.sh BLUESTACKS
everything install successfully with some minor errors like

[-] Overwriting /boot/android/android/ramdisk.img with ramdiskpatched4AVD.img
cp: can't create '/boot/android/android/ramdisk.img': Read-only file system
[-] Change ramdisk Mode to 644
chmod: /boot/android/android/ramdisk.img: Read-only file system
[-] Change ramdisk Owner to System
chown: /boot/android/android/ramdisk.img: Read-only file system

I don't know how but after several tries it worked for me 1 time yesterday but i had to delete my bluestacks and redo the operation today. Can't seem to make it work and can't install Xposed either.

Any help is deeply appreciated

Thanks

image

Magisk installed but not Rooted

Hi,
I have an issue when use it to root my AVD Google API Playstore on Android 28 x86.
(This is my avd config.ini)
config.txt
image
image

This script success and Magisk installed on my AVD, but still not rooted.
image

![image](https://user-images.githubusercontent.com/65939746/130311103-1f266acc-5d12-4164-bbca-90c431010874.png)

Any solutions ?
I still need the Google Play Store to download the apps from there.
if I use AVD with Google API there is no Google Play Store on there.

Thanks in advance.

script doesn't find directories

C:\Users\Name\Downloads\Android\rootAVD>rootAVD.bat ListAllAVDs
FIND: '/I': No such file or directory
FIND: 'DEBUG': No such file or directory
FIND: '/I': No such file or directory
FIND: 'PATCHFSTAB': No such file or directory
FIND: '/I': No such file or directory
FIND: 'GetUSBHPmodZ': No such file or directory
FIND: '/I': No such file or directory
FIND: 'ListAllAVDs': No such file or directory
FIND: '/I': No such file or directory
FIND: 'InstallApps': No such file or directory
rootAVD A Script to root AVD by NewBit XDA

Usage: rootAVD [DIR/ramdisk.img] [OPTIONS] | [EXTRA_CMDS]
or: rootAVD [ARGUMENTS]

Arguments:
ListAllAVDs Lists Command Examples for ALL installed AVDs
<...>

Is this normal behaviour?

I also noticed the SKD Folder links are wrong, at least in the readme. For me with newest Android Studio & Win10 it´s in \AppData\Local\Android\Sdk\system-images\android-29\ google_apis \x86 and not in \google_apis_playstore\ .

Android TV

Did anybody try this with an Android TV image in the emulator?

I tried on Windows 11 with the default Android TV - 1080p base device from the device manager.
It has these settings:

  • processor: x86
  • OS: Android 12.0 - API31

adb shell just opens once, but quits on later tries.

After starting the emulator, the rootAVD ListAllAVDs returns only the default options and does not seem to detect the emulator.

image

AVD Root question

Can this be used to root "Google Play" System Images (With Play store installed in it)?

keep Extracting busybox from script for about half hour,and AVD freeze up

./rootAVD.sh ~/Library/Android/sdk/system-images/android-28/google_apis_playstore/arm64-v8a/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. 511.5 MB/s (11278270 bytes in 0.021s)
[-] ramdisk.img Backup exists already
[] Push ramdisk.img into /data/data/com.android.shell/Magisk
[-] /Users/xxx/Library/Android/sdk/system-images/android-28/google_apis_playstore/arm64-v8a/ramdisk.img: 1 file pushed, 0 skipped. 1062.5 MB/s (1506130 bytes in 0.001s)
[
] Push rootAVD.sh into /data/data/com.android.shell/Magisk
[-] rootAVD.sh: 1 file pushed, 0 skipped. 946.4 MB/s (7855302 bytes in 0.008s)
[-] 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: 28
[-] First API Level: 28
[-] The AVD runs on Android 9
[-] Switch to the location of the script file
[
] Extracting busybox from script ...

"Boot image patched by unsupported programs" on arm64 (Mac Silicon)

Hi there

I like the work you have done here, thanks very much!
I use a Mac BookPro M1 (Silicon) and therefore the previous version of Android Emulator with a arm64-image. If I run it like this...
./rootAVD.sh /Users/x/Library/Android/sdk/system-images/android-31/google_apis/arm64-v8a/ramdisk.img

... i get this error message.

[!] 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
[-] Magisk installer Zip exists already
[*] Cleaning up the ADB working space
[*] Creating the ADB working space
[*] Push Magisk.zip into /data/data/com.android.shell/Magisk
[-] ./Magisk.zip: 1 file pushed, 0 skipped. 205.0 MB/s (6874374 bytes in 0.032s)
[*] create Backup File of ramdisk.img
[*] Push ramdisk.img into /data/data/com.android.shell/Magisk
[-] /Users/simon/Library/Android/sdk/system-images/android-31/google_apis/arm64-v8a/ramdisk.img: 1 file pushed, 0 skipped. 80.5 MB/s (4206234 bytes in 0.050s)
[*] Push rootAVD.sh into /data/data/com.android.shell/Magisk
[-] rootAVD.sh: 1 file pushed, 0 skipped. 153.2 MB/s (7826127 bytes in 0.049s)
[-] run the actually Boot/Ramdisk/Kernel Image Patch Script
[*] from Magisk by topjohnwu and modded by NewBit XDA
[!] We are in an emulator shell
[-] Api Level Arch Detect
[-] Device Platform is arm64 only
[-] Device SDK API: 30
[-] First API Level: 30
[-] Switch to the location of the script file
[*] Extracting busybox and Magisk.zip ...
[*] Extracting busybox from script ...
[!] Found a working busybox Binary: 
[!] BusyBox v1.33.1-Magisk (2021-05-08 15:20:41 PDT) multi-call binary.
[-] Checking AVDs Internet connection...
[!] AVD is online
[!] Checking available Magisk Versions
[?] Choose a Magisk Version to install and make it local
[1] Local '23.0' (ENTER)
[2] Canary d232cba0(23012)
[3] Stable 23.0
[4] Alpha a3eafdd2-alpha(23011)
[1] You choose Magisk Local Version '23.0'
[*] 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 '23.0' Installer
[-] Get Flags
[*] System-as-root, keep dm/avb-verity
[-] Encrypted data, keep forceencrypt
[*] RECOVERYMODE=false
[-] KEEPVERITY=true
[*] KEEPFORCEENCRYPT=true
[*] No 64-Bit Binarys found, please consider Magisk Alpha
[-] 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 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 1568700 ..
/data/data/com.android.shell/Magisk/magiskboot: line 1: syntax error: unexpected word (expecting ")")
[-] Dumping from 1568700 to 4206215 ..
/data/data/com.android.shell/Magisk/magiskboot: line 1: syntax error: unexpected word (expecting ")")
[*] Repacking ramdisk ..
[-] Deleting system ramdisk build.prop
[-] Test patch status and do restore
[-] Checking ramdisk status
[-] STATUS=2
[!] Boot image patched by unsupported programs
[!] Please restore back to stock boot image
[!] aborting the script

Any ideas?

Ran successfully but no root

Hello, I'm trying to root API 29 x86_64 AVD. Magisk app gets installed, but there is no root access. After rebooting the AVD for the first time there was a "Magisk needs to restart your device", but it didn't matter did I click Yes or No, the root disappeared right after.

Log:

$ ./rootAVD.sh ~/Android/Sdk/system-images/android-29/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. 16.1 MB/s (11278270 bytes in 0.668s)
[-] ramdisk.img Backup exists already
[*] Push ramdisk.img into /data/data/com.android.shell/Magisk
[-] /home/krystian/Android/Sdk/system-images/android-29/google_apis/x86_64/ramdisk.img: 1 file pushed, 0 skipped. 209.4 MB/s (1358995 bytes in 0.006s)
[*] Push rootAVD.sh into /data/data/com.android.shell/Magisk
[-] rootAVD.sh: 1 file pushed, 0 skipped. 47.2 MB/s (7855302 bytes in 0.159s)
[-] 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: x64
[-] ARCH32 x86
[-] Device SDK API: 29
[-] First API Level: 28
[-] The AVD runs on Android 10
[-] Switch to the location of the script file
[*] Extracting busybox and 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 '25.2' Installer
[-] Get Flags
[*] System-as-root, keep dm/avb-verity
[-] Encrypted data, keep forceencrypt
[*] RECOVERYMODE=false
[-] KEEPVERITY=true
[*] KEEPFORCEENCRYPT=true
[*] copy x86 files to /data/data/com.android.shell/Magisk/lib/x86_64
[-] 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
[*] After decompressing ramdisk.img, magiskboot will work
Detected format: [gzip]
[-] Checking ramdisk STATUS=1
[-] Magisk patched boot image detected
[*] 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. 23.0 MB/s (1358995 bytes in 0.056s)
[*] Pull Magisk.apk into
[-] /data/data/com.android.shell/Magisk/Magisk.apk: 1 file pulled, 0 skipped. 51.4 MB/s (11278270 bytes in 0.209s)
[-] 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

Screenshot_1669234005

Command Examples list is empty & ListAllAVDs not working

I'm on windows :

WindowsBuildLabEx                                       : 19041.1.amd64fre.vb_release.191206-1406
WindowsCurrentVersion                                   : 6.3
WindowsEditionId                                        : Professional
WindowsInstallationType                                 : Client
WindowsInstallDateFromRegistry                          : 25/10/2020 22:42:20
WindowsProductId                                        : 00330-80192-25494-AA258
WindowsProductName                                      : Windows 10 Pro

I get no commands examples as list:
image

And the command ListAllAVDs is not working, displaying the help again. (I'm using CMD and not PowerShell)

Bootloop

Bootloop after installing magisk and rebooting AVD

The AVD can't start

[INFO]
platfrom : MacOS
AVD: Pixel 6 API 31 Android 12.0 | Arm64

[Result]
After run the script, and get hint of reboot AVD; I did it manually, but AVD started with black screen.

Not Working on Api30 x86

❯ .\rootAVD.bat C:\Users\cyl\AppData\Local\Android\Sdk\system-images\android-30\google_apis\x86\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
[-] D:\下载\rootAVD-master\Magisk.zip: 1 file pushed, 0 skipped. 233.0 MB/s (6874374 bytes in 0.028s)
[*] create Backup File
[*] Push ramdisk.img into /data/data/com.android.shell/Magisk
[-] C:\Users\cyl\AppData\Local\Android\Sdk\system-images\android-30\google_apis\x86\ramdisk.img: 1 file pushed, 0 skipped. 285.0 MB/s (1520108 bytes in 0.005s)
[-] Copy rootAVD Script into Magisk DIR
rootAVD.sh: 1 file pushed, 0 skipped. 126.4 MB/s (7826127 bytes in 0.059s)
[-] run the actually Boot/Ramdisk/Kernel Image Patch Script
[*] from Magisk by topjohnwu and modded by NewBit XDA
[!] We are in an emulator shell
[-] Api Level Arch Detect
[-] Device Platform is x86 only
[-] Device SDK API: 30
[-] First API Level: 30
[-] Switch to the location of the script file
[*] Extracting busybox and Magisk.zip ...
unzip: couldn't open /data/data/com.android.shell/Magisk/Magisk.zip: I/O error
chmod: /data/data/com.android.shell/Magisk/lib: No such file or directory
[*] Extracting busybox from script ...
[!] There is no busybox behind the script
[*] Trying to Download the Up-To-Date Script Version
[!] Temporarily installing Magisk
cp: bad '/lib': No such file or directory
chmod: /data/data/com.android.shell/Magisk/lib: No such file or directory
[-] Checking AVDs Internet connection...
[!] AVD is offline

image
image
image

Black screen after rooting magisk canary

Ekran Resmi 2022-02-25 21 57 40

[!] 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
[-] Magisk installer Zip exists already
[
] Cleaning up the ADB working space
[] Creating the ADB working space
[
] Push Magisk.zip into /data/data/com.android.shell/Magisk
[-] ./Magisk.zip: 1 file pushed, 0 skipped. 285.9 MB/s (10641074 bytes in 0.035s)
[] create Backup File of ramdisk.img
[
] Push ramdisk.img into /data/data/com.android.shell/Magisk
[-] /Users/onderaydin/Library/Android/sdk/system-images/android-32/google_apis/arm64-v8a/ramdisk.img: 1 file pushed, 0 skipped. 269.8 MB/s (4257802 bytes in 0.015s)
[] Push rootAVD.sh into /data/data/com.android.shell/Magisk
[-] rootAVD.sh: 1 file pushed, 0 skipped. 172.4 MB/s (7826127 bytes in 0.043s)
[-] run the actually Boot/Ramdisk/Kernel Image Patch Script
[
] from Magisk by topjohnwu and modded by NewBit XDA
[!] We are in an emulator shell
[-] Api Level Arch Detect
[-] Device Platform is arm64 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
[1] Local '24.1' (ENTER)
[2] Canary 1a1b346c(24102)
[3] Stable 24.1
[4] Alpha e7c82f20-alpha(24102)
2
[2] You choose Magisk Canary Version 1a1b346c(24102)
[
] Deleting local Magisk '24.1'
[] Downloading Magisk 1a1b346c(24102)
[!] Downloading Magisk 1a1b346c(24102) complete!
[-] Switch to the location of the script file
[
] Extracting busybox and Magisk.zip ...
[] 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 1a1b346c(24102) Installer
[-] Get Flags
[] System-as-root, keep dm/avb-verity
[-] Encrypted data, keep forceencrypt
[
] RECOVERYMODE=false
[-] KEEPVERITY=true
[] KEEPFORCEENCRYPT=true
[-] 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
[-] 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 1568512 ..
Detected format: [lz4_legacy]
[-] Dumping from 1568512 to 4257783 ..
Detected format: [lz4_legacy]
[] Repacking ramdisk ..
[-] Deleting system ramdisk build.prop
[-] 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
[!] Copy Magisk.zip to Magisk.apk
[
] Pull ramdiskpatched4AVD.img into ramdisk.img
[-] /data/data/com.android.shell/Magisk/ramdiskpatched4AVD.img: 1 file pulled, 0 skipped. 222.8 MB/s (4760088 bytes in 0.020s)
[] Pull Magisk.apk into
[-] /data/data/com.android.shell/Magisk/Magisk.apk: 1 file pulled, 0 skipped. 236.7 MB/s (17697878 bytes in 0.071s)
[
] Pull Magisk.zip into .
[-] /data/data/com.android.shell/Magisk/Magisk.zip: 1 file pulled, 0 skipped. 247.6 MB/s (17697878 bytes in 0.068s)
[-] 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
[-] 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 doesn't shut down, try it manually!

mac m1
android 12
google play not installed
arm64-v8a

mac m1 run rootAVD error

#22

[!] 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
[-] Magisk installer Zip exists already
[*] Cleaning up the ADB working space
[*] Creating the ADB working space
[*] Push Magisk.zip into /data/data/com.android.shell/Magisk
[-] ./Magisk.zip: 1 file pushed, 0 skipped. 204.3 MB/s (6874374 bytes in 0.032s)
[*] create Backup File of ramdisk.img
cp: ramdisk.img/ramdisk.img.backup: Not a directory
[*] Push ramdisk.img into /data/data/com.android.shell/Magisk
[-] ramdisk.img: 1 file pushed, 0 skipped. 218.8 MB/s (4206334 bytes in 0.018s)
[*] Push rootAVD.sh into /data/data/com.android.shell/Magisk
[-] rootAVD.sh: 1 file pushed, 0 skipped. 194.9 MB/s (7826127 bytes in 0.038s)
[-] run the actually Boot/Ramdisk/Kernel Image Patch Script
[*] from Magisk by topjohnwu and modded by NewBit XDA
[!] We are in an emulator shell
[-] Api Level Arch Detect
[-] Device Platform is arm64 only
[-] Device SDK API: 31
[-] First API Level: 31
[-] Switch to the location of the script file
[*] Extracting busybox and Magisk.zip ...
[*] Extracting busybox from script ...
[!] Found a working busybox Binary: 
[!] BusyBox v1.33.1-Magisk (2021-05-08 15:20:41 PDT) multi-call binary.
[-] Checking AVDs Internet connection...
[!] AVD is online
[!] Checking available Magisk Versions
[?] Choose a Magisk Version to install and make it local
[1] Local '23.0' (ENTER)
[2] Canary 1a1b346c(24102)
[3] Stable 24.1
[4] Alpha e7c82f20-alpha(24102)
[1] You choose Magisk Local Version '23.0'
[*] 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 '23.0' Installer
[-] Get Flags
[*] System-as-root, keep dm/avb-verity
[-] Encrypted data, keep forceencrypt
[*] RECOVERYMODE=false
[-] KEEPVERITY=true
[*] KEEPFORCEENCRYPT=true
[*] No 64-Bit Binarys found, please consider Magisk Alpha
[-] 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 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 1568182 ..
/data/data/com.android.shell/Magisk/magiskboot: line 1: syntax error: unexpected word (expecting ")")
[-] Dumping from 1568182 to 4206315 ..
/data/data/com.android.shell/Magisk/magiskboot: line 1: syntax error: unexpected word (expecting ")")
[*] Repacking ramdisk ..
[-] Deleting system ramdisk build.prop
[-] Test patch status and do restore
[-] Checking ramdisk status
[-] STATUS=2
[!] Boot image patched by unsupported programs
[!] Please restore back to stock boot image
[!] aborting the script

l find this issues, but i want to use 23.0(because of magisk hide), can i find any way to use it.

Black Screen after successfully running

OS: Macos 13.2
CPU: Apple M1 Pro
Android Studio: 2022.1.1
API: Pixel 4 -30 arm64, api 28, api 31

Everything run successfully, but emulator shutdown and not restart. I manually restart but emulator black screen

Add support for A12 under Linux

I really need to test something with root on a virtual device without Google Services, but currently there is no version of Android 13 that has absolutely no Google APIs etc. So is it possible to add support for rooting Android 12 under Linux?

Env no longer constructed

Hello!

Magisk is no longer allowing to construct env, as it tries to update instead and fails, and FixEnvTask does nothing.

how to activate safetynet?

Hello how are you? I hope you're well. First I would like to apologize for the confusion created yesterday in my topic. It's the first time I'm dealing with rooted and right away it was by emulator. Secondly, I would like to thank you for the tutorial and your patience.
Today I really DISCOVERED what I need.

Can you help me?

I need to pass safetynet checks to access banking apps through android emulator. However, I've tried every possible way with safetynet kdragon, prompconfs and everything else. I've watched all the tutorials available on youtube possible, but the problem is that these tutorials only show how to do this through a real cell phone and not through an emulator. Would you help me?

Syntax error in rootAVD.sh

When I attempt to run the batch file on Windows (after fixing the unzip issue), I get the following error:

"[-] Pushing all the stuff into the ADB working DIR"
C:\Android\rootAVD\Magisk: 20 files pushed, 0 skipped. 170.8 MB/s (11756017 bytes in 0.066s)
"[-] run the actual Boot/Ramdisk/Kernel Image Patch Script"
"[*] from Magisk by topjohnwu and modded by NewBit XDA"
: not foundcom.android.shell/Magisk/rootAVD.sh[11]:
'data/data/com.android.shell/Magisk/rootAVD.sh[22]: syntax error: unexpected 'in

"[-] After the ramdisk.img file is patched and back gz'ed,"

That line references the loop in getdir(). Removing that function temporarily uncovers a similar "syntax error" complaint for the "do" in installapps(). Removing that function temporarily runs into a problem with the "do" on line 265 of the original script (in InstallMagiskToAVD(), which I can't exactly remove to test further).

and we are NOT in an emulator shell

input: adb devices
output:

List of devices attached
emulator-5554   device

input: ./rootAVD.sh InstallApps
output:

[!] and we are NOT in an emulator shell
[*] Set Directorys
[-] Test if ADB SHELL is working
[-] Install all APKs placed in the Apps folder
[*] Trying to install Apps/*

and stuck there. did i miss anything?

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

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.

Not working on latest android studio

the ramdisk successfully patched, the avd shitted down, and i power it on using cold boot now, then i tried root checker it shows not rooted, I tried :
./rootAVD.sh /Users/bixmatech/Library/Android/sdk/system-images/android-31/google_apis/x86_64/ramdisk.img DEBUG PATCHFSTAB GetUSBHPmodZ
It shows this
{
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 the AVDs Screen
[!] not root yet
[!] Couldn't construct environment
[!] Double Check Root Access
[!] Re-Run Script with clean ramdisk.img and try again
[!] aborting the script
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.