[Android General] V0latyle:
For those of you who want the AOSP experience, here is how to install generic Android system images. This -should- work on any Samsung device for which TWRP is available. A GSI is only a system image and does not include the kernel. You can use this guide to install any GSI as the process should work the same. You can find various projects in Treble-Enabled Device Development.

These instructions are not specific to AOSP, however, and can be used to install any GSI.

WARNING: These instructions are intended ONLY for those who are familiar with Android, partitions, Odin, TWRP, ADB tools, etc. If you are a beginner/novice, GO NO FURTHER. I am NOT a developer, and I will NOT provide support. All software linked herein is provided AS IS. If you screw something up with your phone because you're trying to do something you know nothing about, I won't help you fix it.

To check whether you can run a GSI on your device, you can either use Termux or adb shell:

getprop ro.treble.enabled

If this returns TRUE, your device is Treble enabled and can run GSIs.

Unlock Bootloader

Enable Developer Options and turn on OEM Unlocking

Disconnect USB/power cables and turn your device OFF

Hold both Volume buttons (do not press Power) and plug in the USB cord connected to your PC

The download/unlock screen should come up immediately. Select the option for device unlock mode.

Disable Knox Guard

After unlocking your bootloader, boot your device normally. Skip through setup, but make sure you connect to the Internet.

Enable Developer options again; OEM Unlocking will likely not be visible. To fix this, initiate a check for a firmware update. Do not download the update.

Go back to Developer Options and confirm that OEM Unlocking is visible; it should be grayed out with the message "Bootloader is already unlocked". If you do NOT see OEM Unlocking, do not attempt to flash any custom firmware.

Put your device in Download Mode. Look for a line that says "KG STATUS" - CHECKING or COMPLETE are OK. If this says LOCKED or PRENORMAL, do not attempt to flash custom firmware and go back to step 1 of this section.

Flash TWRP

Download TWRP for your device. You need the file that ends in .tar.

Put your device in download mode and connect to your PC.

Using Odin, flash the TWRP image in the AP slot. Make sure you either uncheck Auto Reboot in the Options tab, or be ready to force recovery mode when the device reboots. If you allow the OEM firmware to boot after flashing TWRP, it will automatically install the OEM recovery.

Install Multidisabler

Download Multidisabler, transfer it to your device, and flash in TWRP. Among other things, this will disable the recovery restoration, although since you won't be using the OEM firmware this doesn't matter.

Format /data.

Install GSI

Download the Android Preview GSI from Google

These builds are similar to what Pixel devices are running, although they lag behind in updates, and the GMS flavor includes Google Apps. If you want the pure AOSP source, check out Android Continuous Integration for the "master" builds.

If you prefer, you can install the vanilla version, and flash the GApps package of your choice. I highly recommend LiteGapps or NikGapps

Extract system.img from the above archive and transfer to your device

Wipe /system in TWRP. Do not wipe /boot as this will erase your kernel!

Install GSI in TWRP: Install > Install Image > Select GSI image > Select /system and flash.

Important: If you need to flash a GApps package, do this immediately after installing the GSI. You may need to resize /system if you get an error.

Root/Pass Play Integrity

If you want root, just flash Magisk in TWRP. No need to rename it to .zip. If you choose not to root, be aware that the device will not pass Play Integrity, so many banking/DRM apps will not work.

If you do want to be able to use banking/DRM apps, root with Magisk and install the Play Integrity Fix to pass BASIC_INTEGRITY and DEVICE_INTEGRITY.

Notes:

If your device does not have TWRP available, you can try patching your own recovery to enable fastbootd; this will allow you to flash partitions directly from a fastboot command line.

If you're feeling really brave, you can try running a Generic Kernel Image, which you'd flash to /boot. This may not boot properly.