lineageos4microg/android_vendor_partner_gms

When built alongside VoltageOS APK left unsigned

cawilliamson opened this issue · 8 comments

Hello!

So I have a strange issue - I'm trying to integrate your microG implementation as a build option for VoltageOS because folks have asked for it.

It builds just fine and integrates nicely but the problem is the GmsCore APK specifically ends up being left unsigned:

05-18 21:46:36.843  2433  4784 E PackageExtInit: unable to parse SigningDetails for com.google.android.gms; code -103; msg Failed to collect certificates from /system/product/priv-app/GmsCore/GmsCore.apk
05-18 21:46:36.843  2433  4784 E PackageExtInit: java.lang.SecurityException: META-INF/CERT.SF indicates /system/product/priv-app/GmsCore/GmsCore.apk is signed using APK Signature Scheme v2, but no such signature was found. Signature stripped?
05-18 21:46:36.843  2433  4784 E ParseTypeImpl: Cannot set to success after set to error, was Failed to collect certificates from /system/product/priv-app/GmsCore/GmsCore.apk
05-18 21:46:36.843  2433  4784 E ParseTypeImpl: java.lang.SecurityException: META-INF/CERT.SF indicates /system/product/priv-app/GmsCore/GmsCore.apk is signed using APK Signature Scheme v2, but no such signature was found. Signature stripped?
05-18 21:46:36.846  2433  2433 W PackageManager: Failed to parse /system/product/priv-app/GmsCore: Failed to collect certificates from /system/product/priv-app/GmsCore/GmsCore.apk

This then results in that APK being completely ignored. It's very strange because I see nobody else reporting this issue and Voltage is based on LineageOS so I'm a bit mystified.

I believe what's happening is that the APK is getting its libs unpacked but then being repacked and not signed. I have attempted to remedy this by adding the following to each APK definition:

LOCAL_SDK_VERSION := current

This should, in theory, skip modifying the APK but then we fail to actually build the ROM at all because then I get errors like this:

out/target/product/tdgsi_arm64_ab/obj/APPS/IchnaeaNlpBackend_intermediates/package.apk: error: Contains compressed JNI libraries and/or dex files 

So it seems like I'm in a catch 22 with this - any guidance would be greatly appreciated. :)

I believe what's happening is that the APK is getting its libs unpacked but then being repacked and not signed. I have attempted to remedy this by adding the following to each APK definition:

I remember bumping into issues like this a while back, when working on IodéOS not los4microg. I don't think the APK should be getting its libs unpacked and then signed because i is already pre-signed. In our Android.mk we have the line
LOCAL_CERTIFICATE := PRESIGNED
Are you using our Android.mk? If not, have you got the LOCAL_CERTIFICATE := PRESIGNED line in yours?

Are you using our Android.mk? If not, have you got the LOCAL_CERTIFICATE := PRESIGNED line in yours?

I'm using your configs so yep - PRESIGNED is present. This issue is baffling me - not sure why the APKs are being messed with. I believe it's just because GmsCore contains libs but still... very strange.

I'm using your configs so yep - PRESIGNED is present. This issue is baffling me - not sure why the APKs are being messed with. I believe it's just because GmsCore contains libs but still... very strange.

Then I'm baffled too. Just for information, here's the issue where we dealt with this in IodéOS
https://gitlab.com/iode/os/public/lineage/vendor_extra/-/issues/4

Maybe worth looking at the second fix -

adding the following line to the Android.mk files means that the original apk is installed rather than the signature stripped version.
LOCAL_REPLACE_PREBUILT_APK_INSTALLED := $(LOCAL_PATH)/$(LOCAL_MODULE).apk

But I think I'm clutching at straws here :(

But I think I'm clutching at straws here :(

Well - great clutching because that was EXACTLY the issue and your fix worked wonderfully. :)

Thanks a lot for the advice - very greatly appreciated. May be worth noting that in the README for any other poor soup facing the same issue with other ROM. :)

May be worth noting that in the README for any other poor soup facing the same issue with other ROM. :)

I'll do that before I close this issue. Please can you give me a bit more information about how you are / were trying to use the components from this repo? In particular,

  • which Android version(s) you were building?
  • how you were including these components? Just adding this repo to a local manifest as described in our README.md or...?

I've had a quick look at @VoltageOS and your treble_voltage repo but there's quite a lot there to take in :)

Draft text for the README


Note 3. If you encounter problems related to APK / app signing when using these components you may need to add the following line in the Android.mk for the component in question:

LOCAL_REPLACE_PREBUILT_APK_INSTALLED := $(LOCAL_PATH)/$(LOCAL_MODULE).apk

Such problems can occur when

  • the app / APK is resigned with your keys; (this should not happen if the line LOCAL_CERTIFICATE := PRESIGNED is included in the app makefile)
  • app / APK signatures are 'stripped` during the during the deodexing phase of the build. For some apps the deodexed app ends up unsigned, and so will not run.

(Some background to this can be found [here](link to this issue) and [here](link to the IodéOS gitlab issue))


Exactly that @petefoth! :)

I was trying to build Android 14, I included them with this patch: https://github.com/cawilliamson/treble_voltage/blob/14/patches/personal/platform_device_phh_treble/0011-Add-microG-to-build-script.patch

It's a GSI meaning it can be made to run on many devices with one image but that's more just FYI - not really relevant to the ticket. 👍

Not sure if you want to go in to this detail but the symptoms can display as certain apps (in my case, FakeStore and GmsCore) missing completely from your launcher and acting like they're not installed. To check users can run:

$ adb wait-for-device logcat | grep "unable to parse SigningDetails"

Again - not sure if that's too much info - I'd imagine anyone getting to the point where this becomes a problem would have checked logcat already although I'll admit it took me an embarrassing amount of time to find the problem! :)

README.md updated.

Closing