Get root on android emulator

How to start Android Terminal Emulator as root

As usual with Linux, anything beyond simple use cases is a minor ordeal.

UPDATE: This method seems to be causing the app to crash for some folks. I haven’t used the feature in a while and am unaware of a workaround.

You probably know the su or sudo commands on Linux, but those don’t seem to work in the Android terminal.* Fortunately, you can get around that via a terminal emulator setting. Here’s how to do that:

  1. Install Android Terminal Emulator.
  2. Open the above.
  3. Tap the options menu icon.
  4. Tap Preferences.
  5. Scroll down to Shell.
  6. Tap Command line.
  7. Enter /system/xbin/su -c «/system/xbin/bash -» as shown below.

One thing Android does have in common with desktop Linux is even the simplest things are always unnecessarily complicated for the sake of engineering ideological purism.

  • Tap OK.
  • Back out of Preferences.
  • Close the terminal window.
  • Restart the app.
  • Approve the root permissions request that pops up.
  • You’ll now have superuser permissions every time you start the terminal.

    Thanks bitmaster2000 for the method.

    *I suspect the main reason for this is Android doesn’t handle user/administrator/root accounts in the same manner desktop Linux does. On Android every app is a user in Linux parlance, while Android users are something else entirely.

    Источник

    [SCRIPT] rootAVD — root your Android Studio Virtual Device emulator with Magisk [Android 12][Linux][Darwin/MacOS][WIN][Google Play Store APIs]

    newbit

    Senior Member

    here is a little script, rootAVD, I wrote to root Android Studio Virtual Devices with Magisk.
    It is actually just a modified boot_patch.sh from @topjohnwu, which didn’t work
    for Android 11 (R), so I tried the script from @shakalaca MagiskOnEmulator.
    Which didn’t work for Android 11 (R) either, so I used his decompression routine to
    modify my rootAVD script and now it works with Android 11 (R), Android 10 (Q)
    and Android 7 (Nougat) with all the Google Play Store API Versions.
    Successfully tested with Stock Kernels on Linux, MacOS and Windows.
    Since Android 12 (S) API 31 is a 64 Bit Only System, Magisk Alpha from vvb2060 is needed.
    So, all credits go to all three of them.

    I hope this might come in handy.

    [Update 29.03.2021]
    Added Download Manager Function for bad TLS record
    Please check out the README.md for «up to date» information.

    Please provide the following information If you are asking for support:

    • Host System
    • Android Studio Version
    • AVD Version
    • Magisk Version
    • Terminal input & output

    Example Templates:
    Host System:
    sw_vers
    ProductName: Mac OS X
    ProductVersion: 10.15.7
    Android Studio Version: 4.1.3
    AVD Version: Google APIs Intel x86 Atom_64 System Image (revision: 2)
    Magisk Version: Stable 22.1
    Terminal input & output:

    Also, before you ask, please answer your self the following questions:

    • Did I read AND understood the README.md ?
    • Is my question as detailed and simple as possible couched ?

    Also, please include my Username in your Salutation to make sure I will get notice of it.
    I love to help, but asking all the time, where to pick you up, just increases the time period to get
    your issues fixed.

    My thanks to Android AppSec for his wonderful little video about this script.

    wangofjian

    New member

    newbit

    Senior Member

    wangofjian

    New member

    My work System:
    OS: MacOS Catalina 10.15.6
    Android Studio 4.0.1
    AVD: Pixel 2 API 30 Android 10.0+ x86_64

    I restart AVD into safemode, then exec

    restart and follow the magisk to fix problem.

    Attachments

    Hylianer

    Member

    My work System:
    OS: Windows 10
    Android Studio 4.0.1
    AVD: Pixel 2 API 29 Android 10.0+ x86_64

    BUT
    basicintegrity: False
    ctsProfile: False

    And i cant install lot of Apps.
    But root look like the Picture above me

    newbit

    Senior Member

    My work System:
    OS: Windows 10
    Android Studio 4.0.1
    AVD: Pixel 2 API 29 Android 10.0+ x86_64

    BUT
    basicintegrity: False
    ctsProfile: False

    Hylianer

    Member

    Nice, thanks for your feedback.
    I’ve never tried to get pass through the SafetyNet Check.
    But If you want to go further, you can try to change your devices fingerprint with MagiskHidePropsConf from @Didgeridoohan.
    So you could pass basicintegrety, and for ctsprofile you can try Universal SafetyNet Fix from @kdrag0n
    Both modules are just awesome and I have them both on my real phone for the same purpose.

    What do you mean by that? If you can’t drag and drop the apk to Emulators Display to install it, there is something wrong
    with your ADB connection. I had this quite a lot, but booting the AVD up over the SDK fixed it mostly for me.

    THX , i will test it.
    I test to install Magisk and spoof with Pokemon Go

    Magisk install — Check
    Smalipatcher install — Check
    Pokemon Go install — not check (cant install)
    Joystick install — not check (cant install)

    But i will test more first

    Hylianer

    Member

    Both Zips cant installed by Emulator

    it come a Error = Unsupport CPU.
    I think it dont work to make it ready for Fake GPS^^

    newbit

    Senior Member

    Both Zips cant installed by Emulator

    it come a Error = Unsupport CPU.
    I think it dont work to make it ready for Fake GPS^^

    I could install the MagiskHidePropsConf over the Magisk Manager and changed the fingerprint, but it didn’t change anything on the
    safetynet checks. The other zip didn’t install yes.

    rushi12565

    Member

    I could install the MagiskHidePropsConf over the Magisk Manager and changed the fingerprint, but it didn’t change anything on the
    safetynet checks. The other zip didn’t install yes.

    baribalbear

    Senior Member

    newbit

    Senior Member

    API 28 is PIE, Google changed the ramdisk location to SAR Partition.
    The Qemu Engine does have a ramdisk.img, but it is not used by it!!
    Therefor the rootAVD script succeeded, but Qemu is ignoring the ramdisk.img anyway. -> No Root
    You could try to force qemu using it by passing it as boot parameter, I never tried this.

    baribalbear

    Senior Member

    I tried to boot emulator with -ramdisk parameter and pointed to patched file — no luck, it boots but magisc manager don’t see root.

    What is changed in Android 10 comparing to Android 9 that it started to work with the patching script?

    newbit

    Senior Member

    I tried to boot emulator with -ramdisk parameter and pointed to patched file — no luck, it boots but magisc manager don’t see root.

    What is changed in Android 10 comparing to Android 9 that it started to work with the patching script?

    QuilLeeR

    New member

    hello i am new to this, after downloading the zip file what do i have to do? i was trying to open the .bat but it closes immediately and does not do the rooting process

    edit: I ran the script but it doesn’t work does anyone know what I’m doing wrong, I tried it on both android 11 and 12

    newbit

    Senior Member

    hello i am new to this, after downloading the zip file what do i have to do? i was trying to open the .bat but it closes immediately and does not do the rooting process

    edit: I ran the script but it doesn’t work does anyone know what I’m doing wrong, I tried it on both android 11 and 12

    it is possible that you didn’t meet all the preconditions for rootAVD. So, first things first:

    1. Have the AVD running
    2. Have a command prompt open
    3. make sure if you run adb shell it will connect to the running AVD
    4. If you have all above checked, run rootAVD.bat with appropriate argument.

    For Android 11 (R):

    On Android 12 (S), you have to run the script a second time, after the shutdown and restart!
    The Magisk App doesn’t find its Deamon running, and shows no root. — But you can grant root if you request it!
    adb shell
    su
    Hence, it doesn’t trigger the additional setup. Hence, you need to run the script twice.

    Since Android 12 (S) rev 2, the Magisk Daemon is not running when the AVD is booted.
    To solve this, you need to install a Canary Version. Which you can now choose during the installation process.

    QuilLeeR

    New member

    it is possible that you didn’t meet all the preconditions for rootAVD. So, first things first:

    1. Have the AVD running
    2. Have a command prompt open
    3. make sure if you run adb shell it will connect to the running AVD
    4. If you have all above checked, run rootAVD.bat with appropriate argument.

    For Android 11 (R):

    On Android 12 (S), you have to run the script a second time, after the shutdown and restart!
    The Magisk App doesn’t find its Deamon running, and shows no root. — But you can grant root if you request it!
    adb shell
    su
    Hence, it doesn’t trigger the additional setup. Hence, you need to run the script twice.

    Since Android 12 (S) rev 2, the Magisk Daemon is not running when the AVD is booted.
    To solve this, you need to install a Canary Version. Which you can now choose during the installation process.

    newbit

    Senior Member

    Well, you don’t have to restart the entire Studio, just the AVD. And yes, shutdown and start is mandatory, only rebooting
    doesn’t pick up the patched ramdisk.img
    I am glade it worked eventually.

    Just for improvement purposes.

    Did I hint it not well enough? What was missing?
    Or was it just a misreading/misunderstanding on your side?
    I would like to keep the Notes for the script as clear as possible.
    Also, there is always some space to the top left.

    QuilLeeR

    New member

    Well, you don’t have to restart the entire Studio, just the AVD. And yes, shutdown and start is mandatory, only rebooting
    doesn’t pick up the patched ramdisk.img
    I am glade it worked eventually.

    Just for improvement purposes.

    Did I hint it not well enough? What was missing?
    Or was it just a misreading/misunderstanding on your side?
    I would like to keep the Notes for the script as clear as possible.
    Also, there is always some space to the top left.

    newbit

    Senior Member

    Similar threads

    Top Liked Posts

    here is a little script, rootAVD, I wrote to root Android Studio Virtual Devices with Magisk.
    It is actually just a modified boot_patch.sh from @topjohnwu, which didn’t work
    for Android 11 (R), so I tried the script from @shakalaca MagiskOnEmulator.
    Which didn’t work for Android 11 (R) either, so I used his decompression routine to
    modify my rootAVD script and now it works with Android 11 (R), Android 10 (Q)
    and Android 7 (Nougat) with all the Google Play Store API Versions.
    Successfully tested with Stock Kernels on Linux, MacOS and Windows.
    Since Android 12 (S) API 31 is a 64 Bit Only System, Magisk Alpha from vvb2060 is needed.
    So, all credits go to all three of them.

    I hope this might come in handy.

    [Update 29.03.2021]
    Added Download Manager Function for bad TLS record
    Please check out the README.md for «up to date» information.

    Please provide the following information If you are asking for support:

    • Host System
    • Android Studio Version
    • AVD Version
    • Magisk Version
    • Terminal input & output

    Example Templates:
    Host System:
    sw_vers
    ProductName: Mac OS X
    ProductVersion: 10.15.7
    Android Studio Version: 4.1.3
    AVD Version: Google APIs Intel x86 Atom_64 System Image (revision: 2)
    Magisk Version: Stable 22.1
    Terminal input & output:

    Also, before you ask, please answer your self the following questions:

    • Did I read AND understood the README.md ?
    • Is my question as detailed and simple as possible couched ?

    Also, please include my Username in your Salutation to make sure I will get notice of it.
    I love to help, but asking all the time, where to pick you up, just increases the time period to get
    your issues fixed.

    My thanks to Android AppSec for his wonderful little video about this script.

    Источник

    Читайте также:  Android studio для амд
    Оцените статью