android_app_import corrupts APK

599 views
Skip to first unread message

TblS

unread,
May 3, 2023, 3:54:08 PM5/3/23
to Android Building
I'm trying to add some prebuilt apps to my AOSP built, using this blueprint:

android_app_import {
    name: "App",
    apk: "App.apk",
    presigned: true,
    dex_preopt: {
        enabled: false,
    },
    privileged: true,
    product_specific: true,
}

Two of them work fine, but others don't — the APK are being changed during the build.

Their md5 differ and it looks like the signature is stripped out, because if I pull the APK from the device and try to install it with adb install, it says that INSTALL_PARSE_FAILED_NO_CERTIFICATES: Failed to collect certificates from /data/app/vmdl476333160.tmp/base.apk: META-INF/APP.SF indicates /data/app/vmdl476333160.tmp/base.apk is signed using APK Signature Scheme v2, but no such signature was found. Signature stripped?

How to fix it?

Vyrine

unread,
Jun 6, 2023, 2:11:40 PM6/6/23
to Android Building
I'm having this problem since last year 2022. I still debugging up to now and I don't know what's causing it.

Андрейка

unread,
Sep 15, 2023, 10:17:04 AM9/15/23
to Android Building
Hi

Have the same issue. Found out there is a flag named preprocessed. Did you tried it?

вторник, 6 июня 2023 г. в 21:11:40 UTC+3, Vyrine:

Андрейка

unread,
Sep 29, 2023, 4:36:15 PM9/29/23
to Android Building
Ok, preinstalled flag didnt work... seems like soong does not support it, though make seems should.

Anyway, I finally was able to fix this.
It seems that AOSP wants presigned apps to have uncompressed so and dex (if not, it will uncompress it, and break signing for presigned apk), so build it with
packagingOptions {
    jniLibs.useLegacyPackaging = false
    dex.useLegacyPackaging = false
}
That helped in my case.

пятница, 15 сентября 2023 г. в 17:17:04 UTC+3, Андрейка:

Vyrine

unread,
Oct 5, 2023, 10:49:17 AM10/5/23
to Android Building
Do you know what's the equivalent in makefile?

Mikko Koivisto

unread,
Oct 5, 2023, 10:49:58 AM10/5/23
to Android Building
Build output has become more helpful at least in latest main. In some cases it will complain something like:
device/google/cuttlefish/guest/prebuilts/chr_x64_ChromePublic.apk: Prebuilt, presigned apks with targetSdkVersion >= 30 (or a codename targetSdkVersion) must set preprocessed: true in the Android.bp definition (because they must be signed with signature v2, and the build system would wreck that signature otherwise)
so adding preprocessed: true helped there. Then there is also other flag  skip_preprocessed_apk_checks that is commented as "Whether or not to skip checking the preprocessed apk for proper alignment and uncompressed JNI libs and dex files."
Reply all
Reply to author
Forward
0 new messages