yashsingh1/xdaforums huggingface dataset:
[Samsung Galaxy M31 Questions & Answers] mvini_ab:
Install Root Checker to check if you actually have root access and made the process correctly. If not, you have to make it again following step by step carefully.

Once the process is finished and you have root access, go to magisk and allow the app you're using to see the system folder to have access through magisk.

To uninstall apps, I advice you to use this app, because at least on my M31, even Lucky Patcher and TitanumBackup wasn't able to uninstall system apps:

https://xdaforums.com/android/apps-games/app-uninstall-apps-t3776235

Let me know if you're still need help
[Samsung Galaxy M31 Questions & Answers] gigabyteua:
Stitched only patched boot.img. and it worked
[Samsung Galaxy M31 Questions & Answers] mvini_ab:
Good to know. Thank you for the feedback
[Samsung Galaxy M31 Questions & Answers] Deleted member 9636854:
The method does not work on my European version (DBT) with *System as Root*.

Tried to use just the patched boot.img as suggested here (fail message in Odin) and the patched full AP file as suggested on Magisk website (reboots to download until reflashing the stock ROM).
[Samsung Galaxy M31 Questions & Answers] gigabyteua:
you need to patch boot.img from the firmware that is currently installed, and not the one that is offered. Then, after the firmware, immediately go into recovery and do Wipe data / factory reset and Wipe Cache Partition. And then reboot into the system
[Samsung Galaxy M31 Questions & Answers] Deleted member 9636854:
I had extracted the boot.img from my current firmware (M315FXXU2ATIC from SEP2020 with One UI 2.1 and new bootloader), patched it, flashed the tar via Odin, here I got the "failed" message in Odin.

Can you reconfirm if your Samsung firmware version has also System as root? Which region do you use?
[Samsung Galaxy M31 Questions & Answers] gigabyteua:
Mod edit: Translation

I am from Ukraine, I am not strong in English, please excuse me. I will write in Russian, I hope you will understand.

After many unsuccessful attempts by various methods, I was overcome by paranoia and I began to do everything that was possible, perhaps not necessary.

1. Installed the latest Ukrainian region SEK - M315FXXU2ATIC with One UI 2.1 used CSC_OMC_OXM_M315FOXM2ATI6

2. Copied AP_M315FXXU2ATIC_CL19748244_QB34588175_REV00_user_ low_ship_meta_RKEY_OS10.tar to your phone

3. Installed CANARY from the forum 4pda.ru/forum/index.php?showtopic=774072 registration required to download

4. Patched all AP_M315FXXU2ATIC.

5. Copied magisk_patched.tar to computer

6 Opened magisk_patched.tar in 7zip and removed everything except boot.img vbmeta.img recovery.img.lz4

7. Deleted Google account, made a hard reset in the phone

8. Once again, enter Recovery and again Wipe data / factory reset and Wipe Cache Partition.

9. Initial setup without registration with Google and Samsung

10. Shutdown.

11. Entering the download mode - holding down both volume buttons and then connecting the cable.

in Odin auto reboot - remove the bird

12. I asked for magisk_patched.tar = bootloop

13. Deleted recovery.img.lz4 stitched = bootloop

14. Removed vbmeta.img I only asked for boot.img

15. Reboot as soon as the screen goes out immediately enter recovery

16.Wipe data / factory reset and Wipe Cache Partition again.

17. Finally, from recovery, reboot into the system.

Root received. System files are edited (deleted, renamed, file permissions, folders are created, etc.)

Я из Украины, в английском не силен прошу извинить. Напишу на русском надеюсь разберетесь.

После многих неудачных попыток разными методами меня охватила паранойя и я начал делать все что можно, возможно и не нужное.

1. Установил последнюю украинскую регион SEK - M315FXXU2ATIC с One UI 2.1 использовал CSC_OMC_OXM_M315FOXM2ATI6

2. Скопировал AP_M315FXXU2ATIC_CL19748244_QB34588175_REV00_user_low_ship_meta_RKEY_OS10.tar на телефон

3. Установил CANARY с форума 4pda.ru/forum/index.php?showtopic=774072 для скачивания необходима регистрация

4. Patched всю AP_M315FXXU2ATIC.

5. Скопировал magisk_patched.tar на компьютер

6 Открыл magisk_patched.tar в 7zip и удалил все кроме boot.img vbmeta.img recovery.img.lz4

7. Удалил учетную запись Google, сделал полный сброс (hard reset) в телефоне

8. Еще раз вход в Recovery и снова Wipe data / factory reset and Wipe Cache Partition.

9. Начальная настройка без регистрации в Google и Samsung

10. Выключение.

11. Вход в режим download - зажатые обе кнопки громкости и затем подключение кабеля.

в Odin auto reboot - снять птичку

12. Прошил magisk_patched.tar = bootloop

13. Удалил recovery.img.lz4 прошил = bootloop

14. Удалил vbmeta.img прошил только boot.img

15. Перезагрузка, как только экран погас сразу вход в recovery

16. снова Wipe data / factory reset and Wipe Cache Partition.

17. И наконец из recovery перезагрузка в систему.

Root получен. Системные файлы редактируются (удаляются, переименовываются, права файлам, папки создаются и.т.д.)
[Samsung Galaxy M31 Questions & Answers] Badger50:
[MENTION=5387848]gigabyteua[/MENTION]

Just a friendly FYI my friend. If you would please review XDA Rule #4, and post accordingly, we would be very appreciative.

--Regards: Badger50
[Samsung Galaxy M31 Questions & Answers] Deleted member 9636854:
Thanks for all the details.

Can you reconfirm your firmware version is SAR (system as root) - this is shown in magisk manager.

Can you reconfirm you unlocked bootloader not only in developer mode but also in bootloader (long press volume up)?

Thanks.
[Samsung Galaxy M31 Questions & Answers] gigabyteua:
yes unlocked in the developer menu and long press in bootloader mode
[Samsung Galaxy M31 Questions & Answers] Dodgerx01:
I can confirm that the hints of gigabyteua worked!

What i actually did:

I followed the instructions of the thread starter (what is mostly like the instruction of topjohnwu.github.io/Magisk/install.html#patching-images)

But when i did that, i was stuck in download mode which was telling me about a CRC error without letting me out of the download mode.

So, i deleted (as mentioned by gigabyteua) all files out of my patched firmware file (magisk_patched.tar) except the boot.img.

I used odin and loaded only the original firmware AP_(...) File (reboot off)

and directly after that i flashed the magisk_patched (only containing the boot.img).

then i left download mode by pressinf and holding volume down and power and directly after leaving download mode i pressed and holding power up and power to enter recovery mode.

Here I Wipe data / factory reset and Wipe Cache Partition

Boot into system and started the standard initial setup. Installed Magisk manager and was finally left with a rooted M31 phone! *cheers*

Thanks to mvini_ab and gigabyteua and of course topjohnwu for providing magisk

(btw i patched with the normal MagiskManager-v8.0.2.apk, used Odin3_v3.14.1 und got the firmware with Frija-v1.4.2)

edit:

A last hint:

I realized, that the SafetyNet check was not successful in the point "ctsProfile" because of the hardwarecheck.

I just found this little module (https://xdaforums.com/showpost.php?p=83028387&postcount=40658).

After flashing it via Magisk(+reboot), the SafetyNet check is fully successful.

Thanks to Displax for that tiny but useful workaround!
[Samsung Galaxy M31 Questions & Answers] :
Thank you all for the details. Good to see that the method worked also with SAR. I can see I had done 2 steps different, so I have hope for another trial.
[Samsung Galaxy M31 Questions & Answers] possumisdead:
does this method work for the Indian version as well? can anybody confirm?
[Samsung Galaxy M31 Questions & Answers] jagt28:
Hello, I have rooted my Galaxy M31. I have M315FXXU2ATIC firmware (Spain). I have extracted by myself the boot.img file. I have not used the one posted by mvini_ab, to be sure that I use the correct one for my device. If you don’t know how to do it, there are many tutorials on the Internet. If you have any problem with this step, ask, and I can also explain.

The trickier step has been to unlock bootloader, because the tutorials that I have found on the Internet were not very clear. The steps I have followed are below (IMPORTANT: make a backup before following the process, because the phone makes a factory reset in the process).

1. Unlock developer options.

2. Set OEM unlocking to unlock your bootloader (settings/developer options)

[IMG="image1"]https://drive.google.com/file/d/1QTLfm0_oglP4GH5s2CKDFcK-0Ubs9CB5/view?usp=sharing[/IMG]

3. Shutdown your phone.

4. Press and hold volume up and volume down at the same time, hold it and then plug USB cable to enter to bootloader:

[IMG="image2"]https://drive.google.com/file/d/1pgd_WR5xWMyDGdzFFyybGCgFKOFFzjSB/view?usp=sharing[/IMG]

5. Long press Volume up to enter device unlock mode:

[IMG="image3"]https://drive.google.com/file/d/1RMtF2IcqEPAQZ95QdlZFTRZ8Lx8oeYUe/view?usp=sharing[/IMG]

6. Press Volume up to confirm the unlock of the bootloader (you may void warranty).

7. The phone will re-start. Be patient, because it takes several minutes to re-start the phone. The Samsung logo will appear for several minutes. From now on, you will see a warning message every time you power on the phone:

[IMG="image4"]https://drive.google.com/file/d/1Tw5glfuX3DKNB2IFV2Xhit9adh14wH0h/view?usp=sharing[/IMG]

8. The phone makes a factory reset, so you have to configure everything again.

9. Unlock developer options.

10. Enable USB Debugging.

11. Then, you can follow steps 2), 4), and 5) of mvini_ab original post.

After flashing with Odin you will get the following warning message:

[IMG="image5"]https://drive.google.com/file/d/1Y96iBeQYM1png9Salq8l4-YwJXbILNV9/view?usp=sharing[/IMG]

Regards,

Jose Antonio

PD: I don't know how to post images here, so you can find pictures in this link: https://drive.google.com/drive/folders/1Ja6y4ViNjw48jlsZeHtUGLxxgOC0TgfD?usp=sharing
[Samsung Galaxy M31 Questions & Answers] florinbitca0@gmail.com:
I also managed to Root with the same method but after the end I realized that galaxy store, samsung health, magisk did not pass Safetynet checks I reinstalled everything as new, so in my opinion this is still not the right method to do the Root (excuse me the English language because I translated with Google translator).
[Samsung Galaxy M31 Questions & Answers] jagt28:
Everything works fine for me.

Regards

José Antonio
[Samsung Galaxy M31 Questions & Answers] florinbitca0@gmail.com:
So if everything works well for you it surely depends on the Firmware, I have updated to the latest (M315FXXU2ATIC_M315FOXM2ATI6_ITV_Italia Security Patch Level 2020-09-01) and the result was not satisfactory.
[Samsung Galaxy M31 Questions & Answers] jagt28:
I have also the latest, M315FXXU2ATIC for Spain.

José Antonio
[Samsung Galaxy M31 Questions & Answers] AndreM962:
Everyone's talking about magisk_patched.tar, but I can only get magisk_patched.img by patching boot.img. How do I get the magisk_patched.tar file?
[Samsung Galaxy M31 Questions & Answers] florinbitca0@gmail.com:
So first you need to have the Firmware you want to install at hand then extract with 7-zip and get 5 files then extract and get more files from the AP file but you just take the boot.img.lz4 file add it to the archive 7-zip tar format then get the boot.img.tar file that you have to carry on the internal memory of your smartphone.install magisk then open magisk and install on the first line of install and update a file and go to the file you have stored on the internal memory and then go to the start and get a new file called magisk_patched.tar that you find in the download folder of the internal memory.
[Samsung Galaxy M31 Questions & Answers] AndreM962:
So what you're saying is, I compress the boot.img.lz4 file into a tar file, then I patch that file with the Magisk Manager to get the magisk_patched.tar. Is that correct?
[Samsung Galaxy M31 Questions & Answers] florinbitca0@gmail.com:
yes
[Samsung Galaxy M31 Questions & Answers] AndreM962:
After trying both the above solution and using the magisk_patched.tar provided by the OP, the only difference now is that it's no longer giving me any sort of vbmeta error or rebooting into download mode. What's it's doing instead is rebooting into the bootloader screen and giving me no explanation for why.

Would it make any difference if I only used the patched.tar and didn't use the other files (BP, CS, CSC) in Odin? Would that be better?
[Samsung Galaxy M31 Questions & Answers] florinbitca0@gmail.com:
Hi! If you have followed all the steps explained above it should work for you, only that when it returns to the bootloader screen you have to give them a few minutes to boot, and maybe take some pictures and add so let's see what happens.But do you get these two screenshots? If yes then that's okay, just wait a few minutes for it to boot
[Samsung Galaxy M31 Questions & Answers] AndreM962:
Sorry, I meant to say the recovery screen. After installing Magisk via ODIN, the phone reboots and goes to a screen saying "this phone is not using the official firmware", before going into the recovery screen. When I select power off and try to restart, it just happens again. So I'm forced to reinstall the official firmware to get my phone working again.
[Samsung Galaxy M31 Questions & Answers] florinbitca0@gmail.com:
magisk you don't have to install it via odin, you have to install it directly from the site or in apk format
[Samsung Galaxy M31 Questions & Answers] AndreM962:
My device is Samsung, so yes, it DOES need Odin for the installation, as stated in the installation guide: https://topjohnwu.github.io/Magisk/install.html#samsung-system-as-root
[Samsung Galaxy M31 Questions & Answers] AndreM962:
Hello? Where did the OP go?

My phone is the exact same as theirs. I don't understand what I'm doing wrong.
[Samsung Galaxy M31 Questions & Answers] dtanil:
https://xdaforums.com/galaxy-m31/help/m31-root-method-t4172891

This method is working bro try it.
[Samsung Galaxy M31 Questions & Answers] AndreM962:
Alright, I've done it! So what happened was, after installing Magisk, it went into a 'installing update' screen and then into safe mode, and I thought that meant it didn't work. But all I had to do was reboot and then it worked. I'm pretty sure that's what I did with my old phone, too. I just forgot...

One weird thing, though - when I flashed the images and rebooted, I didn't lose any files. Didn't have to reinstall or reconfigure my phone. In fact, the Magisk Manager was still there, and when I opened it, it said Magisk was installed now. Isn't Magisk supposed to make you lose everything?
[Samsung Galaxy M31 Questions & Answers] TheSeyTan1907:
Perfect work with Turkey rom boot.img ?
[Samsung Galaxy M31 Questions & Answers] Atharkhan101:
Is this root method working on M31s too or just M31?
[Samsung Galaxy M31 Questions & Answers] adelf:
tears in my eyes for real

dude thank you so so much i started to hate this phone as i never had a locked unrootable phone

i couldn't cope with the shackles of the system bloatware and the unchangeable settings

i was thinking about selling this phone and buying another lower budget rootable one.

you just helped me root my phone and everything works for me like magic

thank you a lot, a big hug from me bro.
[Samsung Galaxy M31 Questions & Answers] t_gajjar:
what about SafetyNet & banking apps? will this method allow to use of payment apps?

what about SafetyNet & banking apps? will this method allow us to use of payment apps?
[Samsung Galaxy M31 Questions & Answers] enezzolation:
issue

this works guys! but I have a slight issue. I cannot install edxposed to my device, even tho i flashed it through magisk and rebooted. as u know, twrp is not officially available for m31 and I am not trusting the unofficial releases, so...... can u help me?
[Samsung Galaxy M31 Questions & Answers] darenhoff:
Will this boot.img boot M31s

Hi Dear,

I got M31s today. But can not remove the blotwares and all unnecessary stafs. How do I root it? Will boot.im for M31 work on M31s ie M317F device....Please help
[Samsung Galaxy M31 Questions & Answers] darenhoff:
Dear Need boot.img for M317F please

Will M315 boot.img work for M317F/DS M31s, please?
[Samsung Galaxy M31 Questions & Answers] :
I would not try this. Better download your current official firmware, patch your AP file with Magisk and use the boot.img from that patched file.
[Samsung Galaxy M31 Questions & Answers] darenhoff:
But I am still unable to arrange boot.img for M31s
[Samsung Galaxy M31 Questions & Answers] :
At which step are you stuck and what have you tried?
[Samsung Galaxy M31 Questions & Answers] Badr0:
Thank you so much it worked, i'm wondering if it's ok to relock the bootloader after rooting or should i keep it unlocked ?
[Samsung Galaxy M31 Questions & Answers] darenhoff:
This process is perfectly working for M317F/DS also

I did flash only patched boot.img and got root. magisk also giving su permissions. able to uninstall some bloatwares from my M31s.

A BIG thanks for the discovery of the process.
[Samsung Galaxy M31 Questions & Answers] florinbitca0@gmail.com:
You don't want to block the botloader because in theory the phone should return to factory settings then you risk throwing the phone if something goes wrong.
[Samsung Galaxy M31 Questions & Answers] Badr0:
Ok, Thanks :good::good::good:
[Samsung Galaxy M31 Questions & Answers] zunga:
Can anyone provide me some assistance, please?

Here's (roughly) what I did:

1- Downloaded latest ZTO from FRIJA (which I already had installed via the phone's OTA update.

2- Extracted the whole AP file, patched it with magisk manager (did not rename file extension) and flashed with ODIN along with the BL, CP and CSC files from the firmware I had downloaded with FRIJA

3- Got vbmeta error. So I reflashed same as step 2, but unticked the AP. So no AP was flashed this time.

4- Managed to boot properly and got to perform the phone's initial setup.

5- I could not find magisk manager installed so I manually installed it and immediately ran root checker (downloaded from playstore). The app detected the root sucessfully.

6- SafetyNet checks results are: basicintegrity (checkbox) ctsProfile (no checkbox)

Any kind of help would be much appreciated.

------------------------------------------------------------------------------------

EDIT: root performed and SafetyNet errors fixed. Thank you so much mvini_ab!
[Samsung Galaxy M31 Questions & Answers] wackyvinit:
i have sucessfully rooted indian version galaxy m31 you can ask any question if you are facing any issue while rooting or unlocking bootloader
[Samsung Galaxy M31 Questions & Answers] ju1da:
How did yiu fix the safetyNet error?
[Samsung Galaxy M31 Questions & Answers] zunga:
I had to flash a zip called "hardwareoff_1.1.zip". You can find it within the forums. Since my device has stock recovery (and I prefer to keep it that way), I flashed the zip through Magisk itself and it worked flawlessly. Drop me a PM if you need anything.
[Samsung Galaxy M31 Questions & Answers] FinnTheHuman.:
why do i need to flash bl cp csc?

can i just flash the patched boot img through odin ?
[Samsung Galaxy M31 Questions & Answers] Assassin#02:
Can you tell if this method works on ONE UI 3.0 update?
[Samsung Galaxy M31 Questions & Answers] hacko2:
i tried to install hardware off and it cause boot loop

Edit: only go well with the patch universal safetynet fix
[Samsung Galaxy M31 Questions & Answers] ppbear:
Yes it works. Just that you have to do all the steps with patching with magisk and flashing with Odin. I just did it on mine.
[Samsung Galaxy M31 Questions & Answers] Assassin#02:
So you rooted after updating to the latest ONE UI or it was already rooted and survived the update?
[Samsung Galaxy M31 Questions & Answers] ppbear:
I updated it before rooting. I got my phone yesterday and been reading up on it before doing it.
[Samsung Galaxy M31 Questions & Answers] Assassin#02:
Great to know thanks for the info will try to root soon now.
[Samsung Galaxy M31 Questions & Answers] jagt28:
Hello, do you know if it is possible to update the firmware without losing root or losing android programs and settings?
[Samsung Galaxy M31 Questions & Answers] Atharkhan101:
I want to buy this Phone M31 and could anyone HONESTLY confirm that they have rooted this phone. If possible please post screen record. Liars are in XDA as well.
[Samsung Galaxy M31 Questions & Answers] Atharkhan101:
You mentioned you managed to root your Indian Version. Could you please confirm the version number. That red thing you mentioned I guess it's about safetynet. It never passes. If it passes, it bypass root detection in banking apps, Google pay etc and they will work normally.
[Samsung Galaxy M31 Questions & Answers] Atharkhan101:
Is your M31 still rooted or you went to stock unrooted?
[Samsung Galaxy M31 Questions & Answers] Atharkhan101:
You actually rooted right way. Some proprietary apps like Galaxy Store, Samsung health, some banking apps etc will not support rooted devices and you need not to bother because you'll find better alternate in PlayStore. Rooted device is much worth than these little apps.
[Samsung Galaxy M31 Questions & Answers] Atharkhan101:
The 2nd step I did not get. How does the new file look like or named like ?

The 5th step I did not get. Do you mean we need to copy that magisk_patched.tar in PC or let it be in M31?

Also how should I extract boot.img of my phone. Please reply
[Samsung Galaxy M31 Questions & Answers] Atharkhan101:
Could you please confirm the version number
[Samsung Galaxy M31 Questions & Answers] Atharkhan101:
You are lying how did you not faced problem of SafetyNet? Because of people like you, I don't fully trust XDA
[Samsung Galaxy M31 Questions & Answers] Atharkhan101:
Thank you man your step by step procedure is awesome.
[Samsung Galaxy M31 Questions & Answers] Atharkhan101:
Finally I rooted my Galaxy M31 Android 11 One UI 3.1.

Best rooting method is (I call it Clean Root):

Assuming you know how to flash firmware / ROM via Odin:

1. Download the firmware and extract all 5 files.

2. Flash the firmware (All 5 files) via Odin

3. Set up phone with Developers options on and USB debugging ON and get connected to Wifi.

4. Extract the AP file from the downloaded firmware and patch it via Magisk.

5. In Odin, place all 5 firmware file but in place of AP, put the AP magisk patched file and flash it.

6. Phone reboots. Let the phone boot up.

7. Don't close Odin and do not unplug USB cable yet. Being on Odin, just uncheck that AP file and flash those already 4 files showing.

That's it! You have Galaxy M31 rooted. Install Magisk apk and Root checker apk and you'll find device rooted.

This method is best because it does not deal with extracting boot.img which I found very tough and risky.

Google Pay and Banking apps working too with Magisk version 23. Rename magisk and Use magisk hide feature. Perfect.
[Samsung Galaxy M31 Questions & Answers] devasure:
Dear,I would like to get a few things cleared up.

First of all,I am not familiar with patching with magisk.Should /can it be done on my device or does it has to be done one pc?and why should I be on wifi?Is internet required?

I am still on android 10,and I think it doesn't make any difference.

And one more thing

Do I have to do a complete firmware flash or will flashing magisk- patched AP file do?

Thanks in advance