[APP] microG GmsCore - lightweight free software clone of Google Play Services

kurtn

Senior Member
Jan 28, 2017
3,771
1,582
233
Small town in Bavaria
Hello,
I have OnePlus 7 Pro with crDroid 6 (Android 10) and I try to upgrade (Clear Fresh install) crDroid 7.2.( Android 11).
I've got some issue:
MicroG Magisk module works fine on Android 10 along with Play Market (from Fdroid Nanolx rep.) but behaves strangely on Android 11, i.e. MicroG works normally only if a "dummy' (Fake Store) is installed instead of PlayMarket
As soon as I get a real PlayMarket (from Fdroid Nanolx rep.), the device falls into bootloop after reboot.
Tried to workaround by using NanoDroid-MicroG TWRP installer instead of MicroG Magisk module but failed.
The right place to ask about play store for microG is in nanodroid thread. But be aware: that play store is a real Google app, which you tried to avoid.
 
Last edited:

hypern0va

Senior Member
Sep 18, 2014
355
129
73
Italy
I've clean flashed LOS17.1 in the weekend, patched it for signature spoofing, and then:

  1. Installed GMSCore 0.2.15, DroidGuard Helper, Services Framework Proxy through F-Droid
  2. Installed FakeStore
  3. Installed Mozilla, Apple, Deja Vu NLPs
  4. Installed Nominatim Geocoder Backend
  5. Enabled modules in points 2 and 3
  6. Got everything to be ticked in MicorG's self check
After this I didn't get any app to get network provided location. In addition, some other apps cannot display maps (they only show the Google logo in the bottom of the frame the maps should be in), while others can (by using Mapbox). All of these problems were not found on the same set of apps before the clean flash, on older LOS17.1 and microG builds.

Tried to fix those issues doing the following:
  1. Flashed microG Installer Revived in Magisk to move everything to /system/priv-app/ (this updated microG to 0.2.16) -> did not fix
  2. Updated to version 0.2.17 through F-Droid -> did not fix
  3. Tried turning off/on NLP modules in microG settings to check if some of them is causing problems -> did not fix
  4. Flashed the Maps v1 flashable zip from GitHub -> did not fix
  5. Flashed the Maps v1 Magisk flashable zip provided in this repo fork -> did not fix
Network provided location seems to randomly work at times, once every ~10 nonconsecutive tentatives I'd say. I could not notice any action or condition triggering it to work. Funnily enough the "latest known location" entry in every NLP module settings page is actually correct, but since I'm not moving much (covid) I don't know how updated it is.

On the contrary, apps which could not display maps never got to display them in any tentative. Again, they were able to do it before the clean flash.

Any known condition comes in mind to you which could cause either the network location or the maps problem?



EDIT: Admitting I have no specific knowledge of the Maps API, I find the following logs interesting, appearing just after some others regarding an app which should show a map but it does not:

Code:
01-19 00:38:19.511 I/Google Maps Android API(4165): Google Play services client version: 11951000
01-19 00:38:19.512 I/Google Maps Android API(4165): Google Play services package version: 204714034
01-19 00:38:19.552 W/ActivityManager(1395): Unable to start service Intent { cmp=com.google.android.gms/.maps.auth.ApiTokenService } U=0: not found
01-19 00:38:19.639 I/ActivityTaskManager(1395): START u0 {act=android.content.pm.action.REQUEST_PERMISSIONS pkg=com.android.permissioncontroller cmp=com.android.permissioncontroller/com.android.packageinstaller.permission.ui.GrantPermissionsActivity (has extras)} from uid 10229
01-19 00:38:20.975 W/DynamiteModule(23560): Failed to load module via V2: java.lang.NoSuchFieldException: No field sClassLoader in class Lcom/google/android/m4b/maps/t/a$b; (declaration of 'com.google.android.m4b.maps.t.a$b' appears in base.apk)
 
Last edited:
  • Like
Reactions: kurtn

[email protected]

Senior Member
Jul 26, 2019
54
54
28
Any known condition comes in mind to you which could cause either the network location or the maps problem?
Since Android 6, a location provider has to be a priviledged app and thus, its apk has be be pushed to /system/priv-app.

For any priveledged app on the other hand, any permission it requests has to be well defined in a xml file within /etc/permissions. Otherwise, the OS will stay in a boot loop and continuously recheck the permissions.

The thing is, we get the new microg-releases via f-droid, but f-droid will install it als non-priviledged app. That's why you'll see location updates on the location modules page of gms-core, but no other app can receive it. E.g. Osmand will output "no network location provider found" in the system log.

You'll notice the difference when granting gms-core its permissions on the self-check page: If Android asks you to grant the selected permission after you clicked it, it means gms-core is running as non-priviledged.

If it is priviledged, you'll just have to check the checkboxes without getting asked by the OS.

To get gms-core running as a priviledged app,

- connect via adb root and remount
- make a directory /system/privapp/microg (naming is unrevelant)
- push a gms-core release to that folder, e.g. com.google.android.gms-204714034.apk
- set the correct file permissions: chmod 644 <file.apk> (this is important, since files with 777 or 600 are ignored)

For the sake of better understanding, reboot. You will be stuck in a boot loop because of missing permissions. This is intended. Find that permissions by

- connecting via adb root and remounting
- executing adb logcat | grep android.permission
- leave that terminal open

Now, if you use a terminal emulator on you PC that supports backscrolling, watch out for the "permission not in whitelist" messages. You'll get the exact names of missing permissions, e.g.
Code:
Privileged permission android.permission.INSTALL_LOCATION_PROVIDER for package com.google.android.gms (/system/priv-app/com.google.android.gms) not in privapp-permissions whitelist
Now, create a xml file granting gms-core the permissions in question by

- opening another terminal
- touch /etc/permissions/privapp-permissions-microg.xml (filename doesn't matter)
- edit that file via vim or nano and paste the following:

Code:
<permissions>
    <privapp-permissions package="com.google.android.gms">
        <permission name="android.permission.READ_PHONE_STATE"/>
        <permission name="android.permission.READ_CONTACTS"/>
        <permission name="android.permission.WRITE_CONTACTS"/>
        <permission name="android.permission.GET_ACCOUNTS"/>
        <permission name="android.permission.ACCESS_FINE_LOCATION"/>
        <permission name="android.permission.ACCESS_COARSE_LOCATION"/>
        <permission name="android.permission.ACCESS_BACKGROUND_LOCATION"/>
        <permission name="org.microg.permission.FORCE_COARSE_LOCATION"/>
        <permission name="android.permission.INSTALL_LOCATION_PROVIDER"/>
        <permission name="android.permission.RECEIVE_SMS"/>
        <permission name="android.permission.READ_EXTERNAL_STORAGE"/>
        <permission name="android.permission.WRITE_EXTERNAL_STORAGE"/>
        <permission name="android.permission.CHANGE_DEVICE_IDLE_TEMP_WHITELIST"/>
        <permission name="android.permission.UPDATE_APP_OPS_STATS"/>
    </privapp-permissions>
</permissions>
Last but not least

- set the correct file permissions: chmod 644 <file.xml>

No reboot required: Android will immediately continue starting.

These permissions are taken from Nanodroid because that was easier that grepping through the logs: https://github.com/Nanolx/NanoDroid...tc/default-permissions/microg-permissions.xml

Now, if there is any permission issue in the future, fire up the above logcat command, find the missing permission and add it to the xml file.


Addendum
For me that workes using LineageOS 17.1 and 18.1 (thank you @derf elot and @modpunk ) with the latest gms-core releases. I prefer Local GSM Location by deveee as a network location provider. Find it on f-droid.

The only downside is you can't update gms-core via f-droid. But you can enable the "include incompatible versions" option in the f-droid client to receive update notifications. If you then let the f-droid client download the update (and do checksum and pgp verifications), you can install it manually via root terminal:

Code:
mv /data/data/org.fdroid.fdroid/cache/apks/f-droid.org--1/com.google.android.gms<new_version>.apk /system/priv-app/microg/

chmod 644 /system/priv-app/microg/com.google.android.gms<new_version>.apk

rm /system/priv-app/microg/com.google.android.gms<old_version>.apk

restart
The upside is you wont't have to waint until a new Nanodroid bundle or Magisk module is released. You can update gms-core by yourself anytime.
 
Last edited:

hypern0va

Senior Member
Sep 18, 2014
355
129
73
Italy
Since Android 6, a location provider has to be a priviledged app and thus, its apk has be be pushed to /system/priv-app.

For any priveledged app on the other hand, any permission it requests has to be well defined in a xml file within /etc/permissions. Otherwise, the OS will stay in a boot loop and continuously recheck the permissions.

The thing is, we get the new microg-releases via f-droid, but f-droid will install it als non-priviledged app. That's why you'll see location updates on the location modules page of gms-core, but no other app can receive it. E.g. Osmand will output "no network location provider found" in the system log.

You'll notice the difference when granting gms-core its permissions on the self-check page: If Android asks you to grant the selected permission after you clicked it, it means gms-core is running as non-priviledged.

If it is priviledged, you'll just have to check the checkboxes without getting asked by the OS.

To get gms-core running as a priviledged app,

- connect via adb root and remount
- make a directory /system/privapp/microg (naming is unrevelant)
- push a gms-core release to that folder, e.g. com.google.android.gms-204714034.apk
- set the correct file permissions: chmod 644 <file.apk> (this is important, since files with 777 or 600 are ignored)

For the sake of better understanding, reboot. You will be stuck in a boot loop because of missing permissions. This is intended. Find that permissions by

- connecting via adb root and remounting
- executing adb logcat | grep android.permission
- leave that terminal open

Now, if you use a terminal emulator on you PC that supports backscrolling, watch out for the "permission not in whitelist" messages. You'll get the exact names of missing permissions, e.g.
Code:
Privileged permission android.permission.INSTALL_LOCATION_PROVIDER for package com.google.android.gms (/system/priv-app/com.google.android.gms) not in privapp-permissions whitelist
Now, create a xml file granting gms-core the permissions in question by

- opening another terminal
- touch /etc/permissions/privapp-permissions-microg.xml (filename doesn't matter)
- edit that file via vim or nano and paste the following:

Code:
<permissions>
    <privapp-permissions package="com.google.android.gms">
        <permission name="android.permission.READ_PHONE_STATE"/>
        <permission name="android.permission.READ_CONTACTS"/>
        <permission name="android.permission.WRITE_CONTACTS"/>
        <permission name="android.permission.GET_ACCOUNTS"/>
        <permission name="android.permission.ACCESS_FINE_LOCATION"/>
        <permission name="android.permission.ACCESS_COARSE_LOCATION"/>
        <permission name="android.permission.ACCESS_BACKGROUND_LOCATION"/>
        <permission name="org.microg.permission.FORCE_COARSE_LOCATION"/>
        <permission name="android.permission.INSTALL_LOCATION_PROVIDER"/>
        <permission name="android.permission.RECEIVE_SMS"/>
        <permission name="android.permission.READ_EXTERNAL_STORAGE"/>
        <permission name="android.permission.WRITE_EXTERNAL_STORAGE"/>
        <permission name="android.permission.CHANGE_DEVICE_IDLE_TEMP_WHITELIST"/>
        <permission name="android.permission.UPDATE_APP_OPS_STATS"/>
    </privapp-permissions>
</permissions>
Last but not least

- set the correct file permissions: chmod 644 <file.xml>

No reboot required: Android will immediately continue starting.

These permissions are taken from Nanodroid because that was easier that grepping through the logs: https://github.com/Nanolx/NanoDroid...tc/default-permissions/microg-permissions.xml

Now, if there is any permission issue in the future, fire up the above logcat command, find the missing permission and add it to the xml file.


Addendum
For me that workes using LineageOS 17.1 and 18.1 (thank you @derf elot and @modpunk ) with the latest gms-core releases. I prefer Local GSM Location by deveee as a network location provider. Find it on f-droid.

The only downside is you can't update gms-core via f-droid. But you can enable the "include incompatible versions" option in the f-droid client to receive update notifications. If you then let the f-droid client download the update (and do checksum and pgp verifications), you can install it manually via root terminal:

Code:
mv /data/data/org.fdroid.fdroid/cache/apks/f-droid.org--1/com.google.android.gms<new_version>.apk /system/priv-app/microg/

chmod 644 /system/priv-app/microg/com.google.android.gms<new_version>.apk

rm /system/priv-app/microg/com.google.android.gms<old_version>.apk

restart
The upside is you wont't have to waint until a new Nanodroid bundle or Magisk module is released. You can update gms-core by yourself anytime.
This post is great and I honestly think it should be included in the first post or somewhere visible.

I especially appreciated the teaching-based approach instead of just telling me what to do to make things work.

Thank you a lot.
 
  • Like
Reactions: [email protected]

oswald_pu

Member
Sep 19, 2017
5
0
1
Hello folks,
in order to check a problem with microG crashes, I downgraded from microG 0.17 to 0.15 on a lineageOS 14 device: deinstalled the 0.17, installed 0.15. Since then, I can no longer make my location services work. I reinstalled several times 0.15 and 0.17, reinstalled my location providers, tried another, previously unused location provider (Apple); deinstalled microG core and all location providers, then reinstalled all - nothing worked. When using "Here GPS location" (network > read) it says "network not enabled".

Guess I messed up permissions - what should I do?

Cheers,
Wolf
 

kurtn

Senior Member
Jan 28, 2017
3,771
1,582
233
Small town in Bavaria
Hello folks,
in order to check a problem with microG crashes, I downgraded from microG 0.17 to 0.15 on a lineageOS 14 device: deinstalled the 0.17, installed 0.15. Since then, I can no longer make my location services work. I reinstalled several times 0.15 and 0.17, reinstalled my location providers, tried another, previously unused location provider (Apple); deinstalled microG core and all location providers, then reinstalled all - nothing worked. When using "Here GPS location" (network > read) it says "network not enabled".

Guess I messed up permissions - what should I do?

Cheers,
Wolf
LineageOS 14 has a feature to select location mode in settings. If you select " device only" the network location services are disable and you only get satellite location (GPS etc.)
 

oswald_pu

Member
Sep 19, 2017
5
0
1
LineageOS 14 has a feature to select location mode in settings. If you select " device only" the network location services are disable and you only get satellite location (GPS etc.)
Thank you for your hint. I'm familiar with that feature and set the control to "energy saving - use network only".
 

sabei

Member
Jul 9, 2020
41
10
8
Since Android 6, a location provider has to be a priviledged app and thus, its apk has be be pushed to /system/priv-app.

For any priveledged app on the other hand, any permission it requests has to be well defined in a xml file within /etc/permissions. Otherwise, the OS will stay in a boot loop and continuously recheck the permissions.

The thing is, we get the new microg-releases via f-droid, but f-droid will install it als non-priviledged app. That's why you'll see location updates on the location modules page of gms-core, but no other app can receive it. E.g. Osmand will output "no network location provider found" in the system log.

You'll notice the difference when granting gms-core its permissions on the self-check page: If Android asks you to grant the selected permission after you clicked it, it means gms-core is running as non-priviledged.

If it is priviledged, you'll just have to check the checkboxes without getting asked by the OS.

To get gms-core running as a priviledged app,

- connect via adb root and remount
- make a directory /system/privapp/microg (naming is unrevelant)
- push a gms-core release to that folder, e.g. com.google.android.gms-204714034.apk
- set the correct file permissions: chmod 644 <file.apk> (this is important, since files with 777 or 600 are ignored)

For the sake of better understanding, reboot. You will be stuck in a boot loop because of missing permissions. This is intended. Find that permissions by

- connecting via adb root and remounting
- executing adb logcat | grep android.permission
- leave that terminal open

Now, if you use a terminal emulator on you PC that supports backscrolling, watch out for the "permission not in whitelist" messages. You'll get the exact names of missing permissions, e.g.
Code:
Privileged permission android.permission.INSTALL_LOCATION_PROVIDER for package com.google.android.gms (/system/priv-app/com.google.android.gms) not in privapp-permissions whitelist
Now, create a xml file granting gms-core the permissions in question by

- opening another terminal
- touch /etc/permissions/privapp-permissions-microg.xml (filename doesn't matter)
- edit that file via vim or nano and paste the following:

Code:
<permissions>
    <privapp-permissions package="com.google.android.gms">
        <permission name="android.permission.READ_PHONE_STATE"/>
        <permission name="android.permission.READ_CONTACTS"/>
        <permission name="android.permission.WRITE_CONTACTS"/>
        <permission name="android.permission.GET_ACCOUNTS"/>
        <permission name="android.permission.ACCESS_FINE_LOCATION"/>
        <permission name="android.permission.ACCESS_COARSE_LOCATION"/>
        <permission name="android.permission.ACCESS_BACKGROUND_LOCATION"/>
        <permission name="org.microg.permission.FORCE_COARSE_LOCATION"/>
        <permission name="android.permission.INSTALL_LOCATION_PROVIDER"/>
        <permission name="android.permission.RECEIVE_SMS"/>
        <permission name="android.permission.READ_EXTERNAL_STORAGE"/>
        <permission name="android.permission.WRITE_EXTERNAL_STORAGE"/>
        <permission name="android.permission.CHANGE_DEVICE_IDLE_TEMP_WHITELIST"/>
        <permission name="android.permission.UPDATE_APP_OPS_STATS"/>
    </privapp-permissions>
</permissions>
Last but not least

- set the correct file permissions: chmod 644 <file.xml>

No reboot required: Android will immediately continue starting.

These permissions are taken from Nanodroid because that was easier that grepping through the logs: https://github.com/Nanolx/NanoDroid...tc/default-permissions/microg-permissions.xml

Now, if there is any permission issue in the future, fire up the above logcat command, find the missing permission and add it to the xml file.


Addendum
For me that workes using LineageOS 17.1 and 18.1 (thank you @derf elot and @modpunk ) with the latest gms-core releases. I prefer Local GSM Location by deveee as a network location provider. Find it on f-droid.

The only downside is you can't update gms-core via f-droid. But you can enable the "include incompatible versions" option in the f-droid client to receive update notifications. If you then let the f-droid client download the update (and do checksum and pgp verifications), you can install it manually via root terminal:

Code:
mv /data/data/org.fdroid.fdroid/cache/apks/f-droid.org--1/com.google.android.gms<new_version>.apk /system/priv-app/microg/

chmod 644 /system/priv-app/microg/com.google.android.gms<new_version>.apk

rm /system/priv-app/microg/com.google.android.gms<old_version>.apk

restart
The upside is you wont't have to waint until a new Nanodroid bundle or Magisk module is released. You can update gms-core by yourself anytime.
Great post and I wish I could execute. Unfortunately I don't have the necessary knowledge of ADB commands to be able to work out exactly what to put and would probably end up in a big mess! Especially the "whitelist part" :(

I have downloaded and installed microG apk on AOSP Extended Android 10 ROM without issue but want to use the location back ends - and apparently cannot unless in privapp folder.

I have magisk (not used to install microG) and TWRP installed. I am not using F droid installer. If I use the Systemiser Terminal app via magisk do you know if it will achieve the same end? I am a bit concerned about the 644 permissions.
Are there any other options I should consider?
 

Oswald Boelcke

Forum Moderator / Recognized Translator
Staff member
Apr 13, 2016
10,202
13,986
243
64
Preserving Air Supremacy over XDA
en.wikipedia.org
Great post and I wish I could execute. Unfortunately I don't have the necessary knowledge of ADB commands to be able to work out exactly what to put and would probably end up in a big mess! Especially the "whitelist part" :(

I have downloaded and installed microG apk on AOSP Extended Android 10 ROM without issue but want to use the location back ends - and apparently cannot unless in privapp folder.

I have magisk (not used to install microG) and TWRP installed. I am not using F droid installer. If I use the Systemiser Terminal app via magisk do you know if it will achieve the same end? I am a bit concerned about the 644 permissions.
Are there any other options I should consider?
Check the Magisk module "App Systemizer". Easy to use without ADB knowledge.
 

sabei

Member
Jul 9, 2020
41
10
8
Check the Magisk module "App Systemizer". Easy to use without ADB knowledge.
Thanks that was the one I was referring to. Still concerned about the permissions however. I would prefer to use ADB and found many articles online I could follow but not sure how efficacious they are with Android 10 and the whitelist/permissions aspect.
I guess I should just try and see........:unsure:
 

Oswald Boelcke

Forum Moderator / Recognized Translator
Staff member
Apr 13, 2016
10,202
13,986
243
64
Preserving Air Supremacy over XDA
en.wikipedia.org
Thanks that was the one I was referring to. Still concerned about the permissions however. I would prefer to use ADB and found many articles online I could follow but not sure how efficacious they are with Android 10 and the whitelist/permissions aspect.
I guess I should just try and see........:unsure:
Personally, I'm pretty much concerned about privacy and security as my own threads probably show. However, every apk that I've in priv-app has the permission "644" and its respective folder, in which the apk is located, has the permission "755".
 

sabei

Member
Jul 9, 2020
41
10
8
However, every apk that I've in priv-app has the permission "644" and its respective folder, in which the apk is located, has the permission "755".
Sorry I wasn't very clear. I do not have any concerns about granting the respective permissions but in the mechanics of doing so as per the post I replied to originally. That is the creating and editing of an xml file etc.

I have enjoyed reading your threads on privacy and my views tend to mirror yours in that regard. (y)
 
  • Like
Reactions: Oswald Boelcke

Adolamin

Senior Member
Oct 26, 2017
82
22
8
will paying via google pay work with this?
Nah, safety net not working currently. Doesn't look like a difficult fix though. I feel like there have been a few devs who have privately fixed it without publishing (so google isn't encouraged to roll out hardware attestation)