This guide assumes you DO NOT have any Google apps installed, esp. Google Services Framework. If you already do, you may as well just install OpenGApps. I wrote this guide for MicroG LineageOS 17.1 (Android Q), but it should work on earlier editions of Android and other AOSP-based ROMs. Root is required. This guide assumes the user will be performing all of these tasks on the phone without the use of a desktop computer. This process will not survive a system update, so be sure to keep libjni_latinimegoogle.so
around.
The idea behind this guide is for people who are more concerned about privacy and security than the complete, 100% use of FOSS. libjni_latinimegoogle.so is not FOSS.