I never thought I'd do this instead of just build normal ROMs and install microG manually just like people flashes opengapps or some other stuff, but then I found out that "LineageOS for microG" exists, stable custom ROM plus microG instead of bs out of box, nice idea isn't it?
Oh btw, if you know docker and doesn't want to customize your build, "LineageOS for microG" got you covered already, just check out their repository.
As I'm not gonna cover the part about how you normally make a working ROM for your device, just make sure you can get a booting and working build before you try.
- So, you probably already know how to make use of "local_manifests", now add this prebuilt repo for microG to the xml file. For example:
<project name="lineageos4microg/android_prebuilts_prebuiltapks" path="prebuilts/prebuiltapks" remote="github" revision="master" />
Update: vachounet@Telegram from OmniROM group mentioned that there's another repo with more useful changes, check here, you can include microg.mk
and skip step one from next section if you want all stuff included in your build.
- Sync ROM source like you usually do
- Let's start with the easy one, simply add the following to your device tree .mk file where you normally add
PRODUCT_PACKAGES
to:
# microG
PRODUCT_PACKAGES += \
GmsCore \
GsfProxy \
MozillaNlpBackend \
OpenWeatherMapWeatherProvider \
FDroid \
FakeStore \
com.google.android.maps.jar \
com.google.android.maps.xml \
org.microg.xml
- Now, as you may heard, microG requires signature spoofing patch for
frameworks_base
to let apps recognize microG as GMS so that you can receive push notifications, grab patch from here, just the one that matches the Android version that you're about to build, use patch for P if you're building Q for now.
$ cd frameworks/base
## Special thanks vachounet@Telegram for mentioning these 2
## Only run merge 2 commits if you're building Android Q
$ git fetch "https://gerrit.omnirom.org/android_frameworks_base" refs/changes/29/36729/4 && git cherry-pick FETCH_HEAD
$ pushd ../../packages/apps/PermissionController # for LineageOS, location may vary for different ROMs
$ git fetch "https://gerrit.omnirom.org/android_packages_apps_PackageInstaller" refs/changes/30/36730/3 && git cherry-pick FETCH_HEAD
## Now grab basic patch for microG
$ wget https://github.com/microg/android_packages_apps_GmsCore/raw/master/patches/android_frameworks_base-P.patch
$ patch -p1 < android_frameworks_base-P.patch
## maybe some hunk succeed and some may fail here, resolve it manually if failed
$ git status
## You'll probably see some .orig and .rej files generated when patching, remove it manually
-
To make network location working, we need to set 2 boolean values in Android framework xml file that controls network location provider behavior,
- Add the content below to your overlay xml(recommended - if you don't know anything about overlay, read the next paragraph),
or use your favorite text editor to open
(ROM dir.)/frameworks/base/core/res/res/values/config.xml
then set respective boolean totrue
- Add the content below to your overlay xml(recommended - if you don't know anything about overlay, read the next paragraph),
or use your favorite text editor to open
<!-- From https://github.com/lineageos4microg/docker-lineage-cicd/blob/master/src/signature_spoofing_patches/frameworks_base_config.xml#L21 -->
<!-- Force-enable the location overlays -->
<bool name="config_enableNetworkLocationOverlay" translatable="false">true</bool>
<bool name="config_enableFusedLocationOverlay" translatable="false">true</bool>
- As this is just a quick guide to adding needed overlay to your device tree here, try DuckDuckGo if you want to learn more
- Let's start with checking if you already have overlay in device tree and add it if you don't.
## Go to your device tree dictionary
$ cd device/(vendor)/(codename)
## Check if there's a dictionary named "overlay" there,
## if it exists skip the following in this code block
$ ls overlay
## Open one of the already included Makefile, like the one where you do step 1 of this section
$ vim device.mk
## Add next line to the Makefile(without "##", and change "(vendor)"
## and "(codename)" to match your device tree path)
## DEVICE\_PACKAGE\_OVERLAYS += device/(vendor)/(codename)/overlay
## Create dictionary to "overlay" the Android framework
$ mkdir -p overlay/frameworks/base/res/res/values
- Now we're nearly finished, just have to add the boolean values to the overlay
## Open the file to set the 2 boolean values
$ vim overlay/frameworks/base/res/res/values/config.xml
## Now there're two cases, there's already a "config.xml" and there's not,
## if you already have other values set in that "config.xml", just add the
## content above to the inside of "<resources>" tag, and you'll be good to go
## If you don't have existing "config.xml", grab it from the link below
- (optional - not supported on Android 10 at the time of writing) You can also grab Bromite WebView package from the release page,
and replace the one in
(ROM dir.)/external/chromium-webview/prebuilt/(target device cpu arch.)/webview.apk
Sometimes it's tricky to install Play Store manually, as recent Android version need a permission whitelist xml for Play Store,
for FakeStore, it's easy since it only needs android.permission.FAKE_PACKAGE_SIGNATURE
(source)
For the Play Store apk, you may obtain it from various sources, like APKMirror(original) , shadow53(patched) and Lucky P-something. In my experience, different apk source may have different permissions (as the version varies?), there won't be too much differences, but in case you missed any one of the permissions, you'll experience bootloop, check logcat and you'll see what's missing. (Tip: Grab the whitelist xml from shadow53's package as a quick start)
- First one is to simply replace the apk and xml file in
FakeStore
directory - Another one is cleaner, here we go:
## Assume you're in $TOP dictionary of ROM source
$ cd prebuilts; mkdir Phonesky && cd Phonesky
## I have written the Android.mk for you, grab it with the command below
$ wget https://gist.github.com/dic1911/407184ee427c50ad0066af643a20254f/raw/b413f433cf122635ac7226ef1abe69ef92f0b6d9/Android.mk
Put Play Store apk in current dictionary and rename to "com.android.vending.apk",
then replace the FakeStore
include to Phonesky
in your makefile.
Just run your favorite build command now! Easy, right?
Hi. It is not working, after first merge trying I'm getting error: