microg / GmsCore

Free implementation of Play Services
https://microg.org
Apache License 2.0
7.83k stars 1.63k forks source link

Installation instructions #1980

Open alex9434 opened 1 year ago

alex9434 commented 1 year ago

Dear all,

The wiki does not explain how to directly "inject" microg into a system.img for Android 10 to 13. I would like to add microg directly into a mounted system.img file before flashing the file to the phone with fastboot.

Could you add installation instructions? Lineage.microg.org obvously does exactly this but I would like to do something similar for a device that is not listed there.

Thank you, alex

Sapiosenses commented 11 months ago

On their Github (I do not have a link handy) there is a page that shows the parts that they use to add the microG components to a ROM when building.

Here's the main repo page for the ROM-related things, if you don't see the files you need you can open an issue there and ask:

https://github.com/lineageos4microg/docker-lineage-cicd

ale5000-git commented 11 months ago

LineageOS for microG compile the ROM completely from scratch, it doesn't inject into an existing image.

g4b0 commented 4 months ago

Now it seems possible to install MicroG on a vanilla LineageOS: https://review.lineageos.org/c/LineageOS/android_frameworks_base/+/383573

Can someone please provide instruction on how to do it?

Wojtaz0w commented 4 months ago

Now it seems possible to install MicroG on a vanilla LineageOS: https://review.lineageos.org/c/LineageOS/android_frameworks_base/+/383573

Can someone please provide instruction on how to do it?

If you root phone, just flash this as a magisk/ksu module. https://github.com/nift4/microg_installer_revived

bblacher commented 4 months ago

This should be possible without rooting the phone. LineageOS has rooted adb without Magisk, you can push to /system/priv-app directly from adb. I haven't quite figured it out though, currently my phone bootloops when doing this. Will reply if I find anything out.

bblacher commented 4 months ago

Alright, I figured it out and put it all in a script, you can use that as installation instructions :) I don't know if there are things that could be done better but this works for me. https://gitlab.com/bblacher/microg-installer

ale5000-git commented 4 months ago

Didn't anyone see this? https://xdaforums.com/t/mod-flashable-microg-unofficial-installer.3432360/ If it were that simple, I wouldn't have spent 8 years of my life working on an installer

alex9434 commented 4 months ago

I was looking for a way to add MicroG directly to the system.img file from payload.bin before flashing it. The current solution (incl. the great installer from ale5000 that I use) are flashed on top of the image. To clarify what I would like to archive on a linux system:th

  1. Extract system.img with payload_extractor
  2. Loop mount system.img
  3. Modify services.jar to enable signature spoofing
  4. Add microg to system.img
  5. Repackage everything as OTA
  6. Optional: Re-sign (e.g. Pixel devices)
  7. Flash to phone (e.g. as OTA update)

I know how to do 1,2,3,5, and 6 but I am still unclear on step 4. Any idea how to do that? The other steps (and more) are for instance covered by https://github.com/chriswoope/resign-android-image. Since all modifications need to be done on a linux computer, I am looking to set-up a shell script that does these automatically on the loop-mounted image file. Still I am not clear how to best add MicroG incl. all required dependencies.

JonnyTech commented 4 months ago

Just copy the file and modify its attributes. Here is a snippet from my script:

mkdir mountdir
mount system.img mountdir
cp gmscore.apk mountdir/priv-app/
chown 0:0 mountdir/priv-app/gmscore.apk
chmod 644 mountdir/priv-app/gmscore.apk
chcon u:object_r:system_file:s0 mountdir/priv-app/gmscore.apk
umount mountdir

File must go to priv-app folder as it needs privileged permissions.

alex9434 commented 4 months ago

Thank you very much. What is the best way to automatically set all permissions that Microg requires (eg. draw over other apps)?

JonnyTech commented 4 months ago

https://github.com/micro5k/microg-unofficial-installer/tree/main/zip-content/origin/etc/permissions