microg / GmsCore

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

Patching or installing GmsCore in priv-app #462

Open pelomedusa opened 6 years ago

pelomedusa commented 6 years ago

Note: On Android 7 (or later) an additional patch is needed to make location work, or alternatively, you can install GmsCore.apk in the /system/priv-app folder.

I'm running LineageOS 15. I managed to follow your installation guide from the beginning to the end, except for the very last part (quoted above). Are there any detailed instruction for this anywhere? I'm not really sure how to apply this patch or how to move GmsCore to the right location. Thanks for your work, it's amazing.

ArchangeGabriel commented 6 years ago

Indeed, the whole documentation could need a revamp, but basically:

  1. Remount system partition as rw, see https://android.stackexchange.com/questions/110927/how-to-mount-system-rewritable-or-read-only-rw-ro for instance.
  2. Run adb push GmsCore.apk /system/priv-app.
  3. Remount system as ro.
  4. Reboot.

They are other ways (I know some apps allow doing it from the system —with root right ofc). And if you can wait for official LineageOS 15 builds, then you would just need to install the one from https://lineage.microg.org.

Shadow53 commented 6 years ago

Run adb push GmsCore.apk /system/priv-app.

To make everything work correctly, you'll want to push the apk to /system/priv-app/GmsCore/GmsCore.apk and then extract the lib/ folder from the apk to /system/priv-app/GmsCore/lib - otherwise the bundled libraries will not be found by the app and the maps library will crash apps.

Roboe commented 6 years ago

@ArchangeGabriel Note that priv-apps need a special XML permissions manifest from Android Oreo onwards. You will need to push the appropiate for GmsCore and FakeStore to /etc/permissions too.

@Shadow53:

otherwise the bundled libraries will not be found by the app and the maps library will crash apps.

This is not true since Maps v2 API doesn't need bundled libraries. You'll need to push Maps v1 API jar library if you want to support those, though.

ale5000-git commented 6 years ago

@Roboe: You misunderstood Shadow53, Maps v2 API need the library libvtm-jni.so (it is inside GmsCore.apk, you can see by opening it with a zip decompression utility). When GmsCore is installed as normal app the library is installed automatically from Android but if you install it as system app then you need to do it manually.

Note: From about Marshmallow and up Android can use automatically libraries inside apk files without decompressing them (since GmsCore has the proper flag set) but this feature isn't granted to be present in all ROMs so it is better to extract the library just to be safe.

PS: These things apply to all system apps that contain binary libraries.

Roboe commented 6 years ago

Thanks for the clarification. I've been flashing my own ZIP of microG apps since Lollipop and have not had any issues. Edit: It was since Nougat (LineageOS 14.1). Before that I installed microG as normal user apps, since Fairphone Open OS has the needed system patch included.

So, for the OP issue: it's not needed for Android Oreo, but should be done on pre-Marshmallow releases.

ale5000-git commented 6 years ago

This feature if I'm not wrong was introduced by Google but wasn't in AOSP. Then CyanogenMod team got it implemented but I'm unsure if all Marshmallow ROMs have it.

Also for this feature to be working the app must have in the manifest android:extractNativeLibs="false" and must be zip-aligned (GmsCore comply with this but other apps maybe be not).

PS: The issue (app crash) appear only when the library is needed (so only for "Maps v2 API" things in this case).