nift4 / microg_installer_revived

Install microG GmsCore, GsfProxy, FakeStore (or Play Store if you want so) and MapsV1 to /system/
GNU General Public License v3.0
744 stars 41 forks source link

Unable to install microg over itself as a user update - App gets removed after reboot #123

Open gitguy1988 opened 5 months ago

gitguy1988 commented 5 months ago

I am familiar with solving crashes and inability to grant all permissions to microg gmscore by reinstalling microg from its own apk as a user update and have done this in the past on Android 13. For some reason when I do this update workaround on Android 14 it succeeds and works fine, but once I reboot it causes microg gmscore to be removed by the next boot. As a system app with no updates, the app persists across reboots.

To work around this, I've installed the app as an update, opened microg and granted all petmissions, then went to microg gmscore app info from system settings and uninstalled the updates. This retains the granted permissions and the app is not removed after a reboot.

Unfortunately, to use the play integrity fix module, I need to perform the install as a user update trick, otherwise microg continuously crashes. I can't seem to figure out what's causing the app to be removed when I install it over itself as an update. I don't even know where to find any useful logs since it happens during the reboot process. I had removed google play services with sunilpaulmathew's Debloater app/magisk module and thought this might be the issue but it happens even without this module installed

I am stumped..

Other modules installed: Magisk Built In Busybox Systemless Hosts Zygisk LSPosed

I am on a Nothing Phone 2 stock ROM 2.5.2, Android 14. Let me know if there's anything I can do to help diagnose the issue.

nift4 commented 5 months ago

After microG disappears, what does pm dump com.google.android.gms spit out? I recommend you to use a pastebin site like https://bpa.st as the output is very long.

gitguy1988 commented 5 months ago

That site wouldn't let me paste it as it exceeds the maximum allowed size. Here is the pastebin link: https://pastebin.com/3i7T9c2F

Also, I just noticed microG.apk is still present in /system/priv-app/microG after reboot but is not shown as installed

nift4 commented 5 months ago

Can you reboot your phone, then go to Android settings, Developer options, Create bugreport, Interactive and email it to me? nift4@protonmail.com

gitguy1988 commented 5 months ago

Okay I sent it. Also once I reboot a second time, microg services returns, but when I try to install microg.apk as an update again, package installer crashes. Here is a logcat from the time of the crash: https://bpa.st/AQ7A

nift4 commented 5 months ago

Sorry for the late response, I'll try to check the file tomorrow :)

gitguy1988 commented 5 months ago

Take your time. For now, I don't have any need to pass the play integrity check, and microG seems to be working fine with the install update, grant permissions, uninstall update workaround. I am mostly just curious about what might cause the app to be removed after being updated because I've never encountered an issue like this before. I'd appreciate any insight.

danchoto commented 4 months ago

Same issue here. Microg works great until a reboot - when it disappears.... until the next reboot when it re-appears (all settings lost though) It cycles on and off at every reboot. And yes as a system app it persists across reboots, but once updated (or self-updates) and gets moved to /data - it's gone on the next reboot. I also tried the "uninstall updates" trick the OP suggested but the app keeps closing - won't work as a system app. It doesn't seem to be influenced by Zygisk or LSPosed or DenyLists - I tried disabling all of these - no difference. Any advice would be appreciated, thanks in advance!

Samsung Galaxy S23Ultra Android 14, Magisk 27

nift4 commented 4 months ago

are you on stock rom, too? or are you using any debloater?

danchoto commented 4 months ago

Newest Samsung Stock Rom yes, and also I debloated some apps with Universal Android Debloater (recommended settings) https://github.com/0x192/universal-android-debloater Do you think the debloated apps could be the reason? (Also i've replaced the Google Play Store apk with FakeStore apk if that might be a culprit as well)

danchoto commented 4 months ago

Update: I did a factory reset and installed Microg first. So far it works great and persist across reboots. Thank you so much for the advice, and for this project as a whole - greatly appreciated!!

nift4 commented 4 months ago

Thank you for the kinds words :) Indeed, looking at gitguy1988's logs, I can see the original (Google) GmsCore being loaded, investigation on why was pending because I didn't find time. But seeing how you both used debloater, that's the most likely reason - @gitguy1988 can you please try if that workaround works for you too?

danchoto commented 4 months ago

Update2: "Play Integrity Fix" or "Universal SafetyNet Fix" both crash Microg when it's a system app, so I can't use them. Putting it on DenyList crashes it as well. This was the problem before I believe. So, no way to get SafetyNet, unless microg goes into /data after it's updated. But then it disappears on next reboot as usual. But still it's progress : )

nift4 commented 4 months ago

The SafetyNet fix and denylist crashes are caused by a simple chicken-egg problem: microG isn't supposed to see modifications by Magisk (which includes putting microG onto /system), but it can't load it's own code if it's neither on /system or /data, and Android gives up shortly after and crashes the app.

MC-loud commented 4 months ago

A workaround I did was to use Tasker + Tasker Settings to uninstall and reinstall the update on shutdown/startup. Seems to be the only way for PIF to work with MicroG at all

gitguy1988 commented 4 months ago

Thank you for the kinds words :) Indeed, looking at gitguy1988's logs, I can see the original (Google) GmsCore being loaded, investigation on why was pending because I didn't find time. But seeing how you both used debloater, that's the most likely reason - @gitguy1988 can you please try if that workaround works for you too?

Ater disabling the debloater module it still happens. I was thinking it could be the Play Protect, but after completely removing phonesky it still happens as well. Did you happen to notice the package installer crash log? So after I reboot with the update applied, microg is removed. When I reboot a 2nd time, it returns as a /system/priv-app app. When I try to install it as an update again, package installer crashes with the following error in logcat:

show content
02-18 12:06:24.826  6273  6273 E AndroidRuntime: FATAL EXCEPTION: main
02-18 12:06:24.826  6273  6273 E AndroidRuntime: Process: com.google.android.packageinstaller, PID: 6273
02-18 12:06:24.826  6273  6273 E AndroidRuntime: java.lang.RuntimeException: Unable to start receiver com.android.packageinstaller.InstallEventReceiver: android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
02-18 12:06:24.826  6273  6273 E AndroidRuntime:    at android.app.ActivityThread.handleReceiver(ActivityThread.java:4527)
02-18 12:06:24.826  6273  6273 E AndroidRuntime:    at android.app.ActivityThread.-$$Nest$mhandleReceiver(Unknown Source:0)
02-18 12:06:24.826  6273  6273 E AndroidRuntime:    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2287)
02-18 12:06:24.826  6273  6273 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:106)
02-18 12:06:24.826  6273  6273 E AndroidRuntime:    at android.os.Looper.loopOnce(Looper.java:232)
02-18 12:06:24.826  6273  6273 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:334)
02-18 12:06:24.826  6273  6273 E AndroidRuntime:    at android.app.ActivityThread.main(ActivityThread.java:8291)
02-18 12:06:24.826  6273  6273 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
02-18 12:06:24.826  6273  6273 E AndroidRuntime:    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:557)
02-18 12:06:24.826  6273  6273 E AndroidRuntime:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:981)
02-18 12:06:24.826  6273  6273 E AndroidRuntime: Caused by: android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
02-18 12:06:24.826  6273  6273 E AndroidRuntime:    at android.app.ContextImpl.startActivity(ContextImpl.java:1127)
02-18 12:06:24.826  6273  6273 E AndroidRuntime:    at android.app.ContextImpl.startActivity(ContextImpl.java:1103)
02-18 12:06:24.826  6273  6273 E AndroidRuntime:    at android.content.ContextWrapper.startActivity(ContextWrapper.java:436)
02-18 12:06:24.826  6273  6273 E AndroidRuntime:    at android.content.ContextWrapper.startActivity(ContextWrapper.java:436)
02-18 12:06:24.826  6273  6273 E AndroidRuntime:    at com.android.packageinstaller.EventResultPersister.onEventReceived(EventResultPersister.java:189)
02-18 12:06:24.826  6273  6273 E AndroidRuntime:    at com.android.packageinstaller.InstallEventReceiver.onReceive(InstallEventReceiver.java:50)
02-18 12:06:24.826  6273  6273 E AndroidRuntime:    at android.app.ActivityThread.handleReceiver(ActivityThread.java:4516)
02-18 12:06:24.826  6273  6273 E AndroidRuntime:    ... 9 more
gitguy1988 commented 4 months ago

I am curious to see if this still happens when I update microg with a version that's actually newer than the one installed in /system/priv-app. I am considering installing an older version of your module with an older gmscore package, then installing the recent version of microG as an update. If it's successful, I'll let you know. It won't be for a week or so while I am away from my laptop, because I don't want to mess up my phone until I'm able to recover from it.

nift4 commented 4 months ago

Just to confirm, uninstalling PlayIntegrityFix, Universal SafetyNet Fix, removing microG from denylist / Magisk Hide, and making sure SuList is disabled (whatever applies to your setup), does microG still disappear when installed to /data?

danchoto commented 4 months ago

In my case - yes. I've tried many many different scenarios, including a clean install. Once it goes on /data, after a reboot it's gone. (Btw, the same thing happens with NanoDroid, and also the FriendlyNeighborhoodShane's version - which seems to auto-move to data on install)

nift4 commented 4 months ago

@MC-loud are you too using a debloater?

gitguy1988 commented 4 months ago

Okay, so I tried installing a version of the microg installer revived that has an older version of microG.apk, then updating it to the newest version by installing the new apk. All of this was done with no debloater modules installed, but still produced the same result: MicroG was no longer installed after a reboot.

I noticed a suspicious file in /product/etc/security/fsverity called "gms_fsverity_cert.der" as well as "play_store_fsi_cert.der" which prompt me for a password when i try to open it from a file manager. I do not know anything about fsverity but after searching around I came across this excerpt from the grapheneOS github page apps.grapheneos.org where it states:

"GrapheneOS requires fs-verity for system app updates as part of fully extending verified boot to system app updates. Android doesn't enforce any form of verified boot for system app updates so they can be used to bypass verified boot by replacing system apps with arbitrary APKs since signature checks and downgrade protection aren't enforced at boot. GrapheneOS adds enforced checks and also enforces using fs-verity to provide continuous verification instead of only one-time verification at boot where the SSD is trusted afterwards in order to match the properties of verified boot for the firmware and OS images."

Maybe some newer roms are beginning to implement this feature?

If we can verify that /product/etc/security/fsverity/gms_fsverity_cert.der is present on the phones of users who have this problem and verify that it is absent on phones without the issue, we may have found the cause.

EDIT: I tried removing the fsverity files with magisk and installing microg with the user update applied but it still gets removed on reboot.

merrkry commented 4 months ago

@gitguy1988

I encountered this problem with /product/etc/security/fsverity/* existing.

I am trying to install on my Poco F5 & AOSPA setup, which comes with GApps pre-installed. Before installing the module, I used this debloater to remove all packages marked as "recommended" by it and manually uninstalled gms, gsf and vending.

I've also tried to put GmsCore.apk and GsfProxy.apk into /system/priv-app/ (no subdir, because i forgot), without installing the module. In this case, my micro-g wasn't removed after reboot. But two permissions can't be set (background location and message iirc). Then I tried overwrite install again - permissions were able to be granted and micro-g get's deleted next boot.

danchoto commented 4 months ago

I also have these files in /product/etc/security/fsverity "gms_fsverity_cert.der" and "play_store_fsi_cert.der"

gitguy1988 commented 4 months ago

I tried removing the fsverity files with magisk and installing microg with the user update applied but it still gets removed on reboot.

nift4 commented 4 months ago

After installing it as user app, the APK should be in /data/app, is it still there after rebooting and having it disappear?

oSumAtrIX commented 4 months ago

The issue is replicable with WSA. After installing the module and rebooting, only the companion is installed. The module does not appear. Installing as a user app is not enough. Apps such as YouTube require GmsCore to be under /system

Update

On my end it looks like WSA/Magisk is at fault. Once the module is installed, before rebooting, Magisk creates a folder in /data/adb/modules_update. After rebooting the folder disappears. Moving that folder to /data/adb/modules, then rebooting fixes the issue

gitguy1988 commented 4 months ago

After installing it as user app, the APK should be in /data/app, is it still there after rebooting and having it disappear?

No, the apk in data is gone. The apk in /system/priv-app is still there, but it does not show up in the installed apps list, nor is the icon available on the launcher.

By the way, the stock GmsCore.apk on Nothing OS is found in /product/priv-app/GmsCore just in case that could be relevant to the issue.

nift4 commented 4 months ago

Hmm so it exists, you reboot and it's gone... which means PackageManager is deleting it on boot. But why? Can you create another logcat showing the bootup process with adb logcat as early as it is possible?

nift4 commented 3 months ago

Hi all, L. sent me an E-Mail confirming some of my suspicions (despite the attached log seemingly missing :P) combined with this information in this thread. Thank you for your efforts, everyone - please try this test ZIP: https://github.com/nift4/microg_installer_revived/releases/download/v3.2.0-0-test1/microG_Installer_Revived.zip I hope it solves the issue. Cheers

bschtl commented 3 months ago

Thank you for your work! Unfortunately the problem still persists, at least for me. After flashing the test ZIP and manually installing microg (I have to do this via adb, package installer doesn't install the APK) and rebooting microg is gone. After another reboot it appears again.

Edit: I installed the test ZIP over the already installed module, could that be a problem? Also I'll try to provide adb logcat of boot on the weekend.

nift4 commented 3 months ago

Hi all, Please try this one: https://github.com/nift4/microg_installer_revived/releases/download/v3.2.0-0-test1/microG_Installer_Revived-test2.zip

bschtl commented 3 months ago

The problem persists after installing test2, sent you new logcat.

nift4 commented 3 months ago

thanks for the log, noticed a stupid mistake, please try https://github.com/nift4/microg_installer_revived/releases/download/v3.2.0-0-test1/microG_Installer_Revived-test3.zip

bschtl commented 3 months ago

I'm afraid microg still gets removed after reboot when installed as user app over installed tests module. Can't take a log atm, will try to provide soon.

zekishaw commented 2 months ago

I'm having this issue too, NP2 2.5.3.

I've been painfully trawling for solutions, I also used that UAD tool the others here have. My thoughts (haven't tested yet, I will get onto this afternoon?) Are that the Gapps especially GMS hang around after being debloated as they remain in priv-app on Android 14.

I will try the system less debloater for magisk module and get back to you on how it goes

Editing to add: I'm not a developer I just 'play around' as it were

zekishaw commented 2 months ago

https://github.com/zgfg/SystemlessDebloater

De-bloating using this tool and then installing MicroG in whatever way you like keeps MicroG on boot.

I also have banking apps etc working, using lsposed and shamiko modules etc.

bschtl commented 2 months ago

I can confirm this. Though I used the module for KernelSU and only tested the installer from here.

I still had to manually install the microg APK after flashing the module to be able to give all permissions in microg, but it doesn't get removed after reboot anymore.

Also I was able to install Play Integrity Fix Module which before always crashed microg.

gitguy1988 commented 2 months ago

I installed SystemlessDebloater and my SystemlessDebloater.cfg includes GmsCore and GoogleServicesFramework. The problem still exists for me when updated as a user app. I'm on Nothing Phone 2 with rom version 2.5.2.

bschtl commented 2 months ago

My SystemlessDebloater.cfg only contains GmsCore and Phonesky. I'm on OnePlus 12, ROM 14.0.0.604 but perhaps try debloating these apps.

gitguy1988 commented 2 months ago

Thanks, I'll try that when I can. For consistency, did you use the microG_Installer_Revived-test3.zip when you had success, or the latest official release?

bschtl commented 2 months ago

I used latest official release. Didn't give a test3.zip a try, since it worked immediately with official.

ZX-Commodore-ST commented 2 months ago

I've had some problems with few apps not working: NetMonster - https://play.google.com/store/apps/details?id=cz.mroczis.netmonster . I forgot that I had old GmsCore version installed that might be causing some problems with updated MicroG. After trying to install 3.4.4 it all stopped working but reading through this issue helped me to sort it out. I had to remove MicroG installer from Magisk and all leftovers from MicroG in crDroid. Next I had to install latest version but once again it wasn't flawless experience. I couldn't turn on all options in MicroG so I had to install MicroG.apk again as a normal app just like I did with GmsCore.apk in the past. NetMonster and few other apps are working again.

But in the end without deep knowledge it's hard to tell what is the source of problem. Is it installer or is it MicroG? Anyway, thank you all!

gitguy1988 commented 1 week ago

Nothing that I tried seemed to solve the issue for me yet. So far I have tried using the Systemless Debloater module and tried all test modules posted here. The latest version of the module seems to work as a system app after initial install and reboot, but after rebooting once more, MicroG crashes repeatedly with "Error: androidx.multidex.MultiDexApplication" which is resolved when manually installed as an update, but then is totally removed after another reboot. At the moment I am just happy to have a somewhat functional MicroG using the 3.4.2 module and keeping it as a system app. Eventually I plan on switching from Magisk to KernelSU or updating my stock rom (Nothing OS 2.5.2 on Nothing Phone 2) and will report the results assuming the issue is still open.