Reputation: 3084
I build my project in Android Studio and generate signed apk, then put my apk in Android Open Source Project to pack my app with system image.
I followed these steps to pack my app with system image.
My problem is this line in Android.mk
:
LOCAL_CERTIFICATE := < desired key >
if I don't sign the apk and use
LOCAL_CERTIFICATE := platform
everything goes well and build is successful
but if I sign my apk and use
LOCAL_CERTIFICATE := PRESIGNED
my build fails with Error 1:
make: *** [out/target/product/helpera64-v2/obj/APPS/MyApp_intermediates/package.apk] Error 1
for verbos log I make project with make showcommands
and this is where error happens:
mv out/target/product/helpera64-v2/obj/APPS/MyApp_intermediates/package.apk out/target/product/helpera64-v2/obj/APPS/MyApp_intermediates/package.apk.unaligned
out/host/linux-x86/bin/zipalign -f -p 4 out/target/product/helpera64-v2/obj/APPS/MyApp_intermediates/package.apk.unaligned out/target/product/helpera64-v2/obj/APPS/MyApp_intermediates/package.apk.aligned
make: *** [out/target/product/helpera64-v2/obj/APPS/MyApp_intermediates/package.apk] Error 1
so the problem is zipalign! build system should not use zipalign for signed apk, but why does it use?
My full Android.mk:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := MyApp
LOCAL_MODULE_TAGS := optional
LOCAL_CERTIFICATE := PRESIGNED
LOCAL_DEX_PREOPT := false
LOCAL_MODULE_PATH := $(TARGET_OUT)/preinstall
LOCAL_MODULE_CLASS := APPS
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
LOCAL_SRC_FILES := my_app.apk
LOCAL_PRIVILEGED_MODULE = true
LOCAL_OVERRIDES_PACKAGES := Home Launcher2 Launcher3
include $(BUILD_PREBUILT)
Upvotes: 0
Views: 656
Reputation: 659
mv out/target/product/helpera64-v2/obj/APPS/MyApp_intermediates/package.apk out/target/product/helpera64-v2/obj/APPS/MyApp_intermediates/package.apk.unaligned
out/host/linux-x86/bin/zipalign -f -p 4 out/target/product/helpera64-v2/obj/APPS/MyApp_intermediates/package.apk.unaligned out/target/product/helpera64-v2/obj/APPS/MyApp_intermediates/package.apk.aligned
make: *** [out/target/product/helpera64-v2/obj/APPS/MyApp_intermediates/package.apk] Error 1
From the error log, the zipalign
command executed failed, so the potential failed reason is that your apk with wrong align
. Maybe you can follow the Android's zipalign document to ensure your apk with the correct align
.
PS: I have encountered the similar problem because of presigned apk has wrong align
so file.
Upvotes: 1