topjohnwu / Magisk

The Magic Mask for Android
GNU General Public License v3.0
47.68k stars 12.1k forks source link

Is there a way to intall Magisk to an Android emulator? #732

Closed PureDark closed 5 years ago

PureDark commented 5 years ago

I have been trying for a long time and without luck.

Emulators don't have a recovery mode.... I read that someone was able to install Magisk V12.0 on Android x86 7.1.2 rc2, using this tools to create a "fake" boot.img using kernel and ramdisk.img files.

Thought I'd ask if it is possible in current version, or can the author made a simple way to install this on emulators.

nekomekoraiyuu commented 5 years ago

Hi, @PureDark

its Possible in Nox emulator... Nox Emulator has The boot Img. But For some region It doesn't has Revovery, also You can install Magisk in it...

zulu99-zulu99 commented 5 years ago

It is possible install magisk on google android emulator, that come with android studio.

get the ramdisk.img and kernel and create a boot.img

patch the created boot image with magisk manager

split the patched_boot.img and use the new patched ramdisk.img

The problem is that new versions of Magisk, break the compatibility with the emulator.

I tested on Android emulator OREO and PIE

The last working Magisk version on both Android OREO and PIE is the magisk 16.6

The problem with Magisk 18 on Oreo and PIE is this:

[ 3.066551] init: cannot setexeccon('u:r:magisk:s0') for ab4bRgk: Invalid argument [ 13.074987] init: wait for '/dev/.magisk.unblock' timed out and took 10008ms [ 13.083000] init: Command 'wait /dev/.magisk.unblock 10' action=post-fs-data (/init.magisk.rc:6) took 10016ms and failed: wait_for_file() failed [ 13.089982] init: Service 'ab4bRgk' (pid 1585) exited with status 6

If the developer of Magisk can help, we are very happy. I have already a working PIE emulator with last arm translation working (houdini). The only problem is that i must add Magisk 16.6 because last versions not work.

KishinMukito commented 5 years ago

@xxRaiyanxxYT

you say its possible to install it on nox but how do you do it? i tried it using the direct install option in magisk manager and it said it failed

qauck commented 5 years ago

It is possible install magisk on google android emulator, that come with android studio.

get the ramdisk.img and kernel and create a boot.img

patch the created boot image with magisk manager

split the patched_boot.img and use the new patched ramdisk.img

The problem is that new versions of Magisk, break the compatibility with the emulator.

I tested on Android emulator OREO and PIE

The last working Magisk version on both Android OREO and PIE is the magisk 16.6

The problem with Magisk 18 on Oreo and PIE is this:

[ 3.066551] init: cannot setexeccon('u:r:magisk:s0') for ab4bRgk: Invalid argument [ 13.074987] init: wait for '/dev/.magisk.unblock' timed out and took 10008ms [ 13.083000] init: Command 'wait /dev/.magisk.unblock 10' action=post-fs-data (/init.magisk.rc:6) took 10016ms and failed: wait_for_file() failed [ 13.089982] init: Service 'ab4bRgk' (pid 1585) exited with status 6

If the developer of Magisk can help, we are very happy. I have already a working PIE emulator with last arm translation working (houdini). The only problem is that i must add Magisk 16.6 because last versions not work.

Can you share more details for how to create/split the boot.img? or share the patched working image for the emulator?

topjohnwu commented 5 years ago

I run Magisk in emulators. Might release documentations on how to do it soon.

schumi2004 commented 5 years ago

I'm also interested on how to do this, can't wait ;)

Mygod commented 5 years ago

A related but different enhancement would be to bring it to Chrome OS (i.e. Android containers). 😀

MAYBreath commented 5 years ago

still no release documentations..waiting for you untill I am dead..

cherinyy commented 5 years ago

There will not be a general guide.

topjohnwu:

The basic idea is to find a way to replace init to magiskinit. There will not be a general guide for that since emulators does not have a clear standard.

https://github.com/topjohnwu/Magisk/issues/1255#issuecomment-485891789

vrqq commented 5 years ago

Note: In Android Emulator from Android Studio, Android 9.0 PIE x86, the ramdisk.img is useless, this file will not be loaded by qemu. (Try to zero it and the emulator run normally.)

The system.img will be mounted to / (device root), and kernel will load system.img/init directly. (The characteristic of A/B system) See the detail by : https://github.com/topjohnwu/Magisk/issues/503

So, the Systemlessly should be implemented by another method in kernel?

By android-studio-ide-182.5314842-windows + Hypervisor Platform && Android 9.0 x86 without Google APPs.

cherinyy commented 5 years ago

I think many people are not using Android Emulator from Android Studio. Most people use virtual machines based on VirtualBox(MuMu, NoxPlayer, etc. ) They provide a hard disk image directly instead of an installation image. I tried to extract the boot partition using DiskGenius, but I failed.

Apihplays commented 5 years ago

any news on magisk on android emulator such as bluestack or memu ?

neoblackxt commented 5 years ago

I failed to install Magisk on Android O, P, and Q, but succeeded on N. P image is system-as-root. I modified the advancedFeatures.ini file by changing "SystemAsRoot = on" to "off", but still failed, it even can't boot complete.

neoblackxt commented 5 years ago

Good news! Update emulator.sh to support all AVD images

andronoob commented 4 years ago

I got Magisk 20.1 installed on my AVD: https://github.com/topjohnwu/Magisk/issues/1255#issuecomment-559696946

I hope my comment would be helpful, however, I take no responsibility of potential damage/info leak/apocalypse etc :-)

MAYBreath commented 4 years ago

I think many people are not using Android Emulator from Android Studio. Most people use virtual machines based on VirtualBox(MuMu, NoxPlayer, etc. ) They provide a hard disk image directly instead of an installation image. I tried to extract the boot partition using DiskGenius, but I failed.

I totally agree with you,but now magisk' emulator just support useless ADV..I even can not able open the pokemon on it.what a pity

ttimasdf commented 4 years ago

I think many people are not using Android Emulator from Android Studio. Most people use virtual machines based on VirtualBox(MuMu, NoxPlayer, etc. ) They provide a hard disk image directly instead of an installation image. I tried to extract the boot partition using DiskGenius, but I failed.

@wordlesswind

Nox VM use a shared, read-only system image for all VMs created with same template. You could open the virtual machine configuration with text editor to get the vmdk path. Open VMDK with DiskGenius, you can easily find in the MBR section that the Android system is booted by GRUB. You could further down from here 😄

The example below is taken from a community modified version of Android 5 base image in NoxVM.

image

HemanthJabalpuri commented 3 years ago

any news on magisk on android emulator such as bluestack or memu ?

I have successfully, installed Magisk in MEmu 7.3.2, LDPlayer 4.0.45 with Android 7.1(25) x86(32) with https://forum.xda-developers.com/t/guide-magisk-and-xposed-for-memu-7-3-2.4222919/

Modules are also working.

HemanthJabalpuri commented 3 years ago

@wordlesswind @ttimasdf @Apihplays If we can able to replace ramdisk in MEmu or LDPlayer using the paths as shown here https://forum.xda-developers.com/t/guide-magisk-supersu-and-xposed-for-memu-7-3-2-or-ldplayer-4-0-45.4222919/post-84723623 we can able to full root it.

Thanks

leros1337 commented 3 years ago

@HemanthJabalpuri If you have any success, reply in thread please with guideline