Add prebuilt apk(.so included) into update.img

Hello Khadas team,

I’m currently working on a project that requires preinstalling some apps and services into an image file. I’ve tried putting the .apk into the out\target\product\kvim3\system\app directory, but after compiling the image nothing changed.

Is there any way you could help me with this?

Thanks in advance,
Leo

Put the corresponding APK in this directory: device\khadas\kvim3\preinstall
Add corresponding file modification: device\khadas\kvim3\preinstall\Android.mk

include $(CLEAR_VARS)
LOCAL_MODULE := xxx_apk
LOCAL_MODULE_CLASS := APPS
LOCAL_MODULE_PATH := $(TARGET_OUT)/preinstall
LOCAL_SRC_FILES := $(LOCAL_MODULE)$(COMMON_ANDROID_PACKAGE_SUFFIX)
LOCAL_CERTIFICATE := PRESIGNED
LOCAL_DEX_PREOPT := false
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
include $(BUILD_PREBUILT)

device\khadas\kvim3\preinstall\preinstall.mk

PRODUCT_PACKAGES += xxx_apk
1 Like

Hi, :slightly_smiling_face:

Appreciate your response. I think I’ve already tried this solution yesterday. The app was installed. But it showed the error OpenCV manager package was not found. I think .so wasn’t properly compiled into the image. But I will try this solution again tomorrow morning in case I missed some steps last time!

Hi goenjoy,

I’ve tried to install two of our apps using the solution above. One installed properly, but the other one didn’t get installed at all. I tried to use pm install manually under /system/preinstall/ourAPP/* directory. It showed the error Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES: Package /data/app/vmdl438956791.tmp/base.apk has no certificates at entry AndroidManifest.xml], which Im pretty sure out app is signed properly.

Anyone know what could be the potential reason for this?

Thanks in advance,
Leo

You can upload this APK to me for a try…

@noobsplzwin Put the corresponding APK in this directory: vendor/amlogic/common/apps/xxx/
Add corresponding file modification: vendor/amlogic/common/apps/xxx/Android.mk

LOCAL_PATH := $(call my-dir)
	include $(CLEAR_VARS)
	LOCAL_MODULE := xxx
	LOCAL_MODULE_CLASS := APPS
	LOCAL_MODULE_TAGS := optional
	LOCAL_BUILT_MODULE_STEM := package.apk
	LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
	LOCAL_CERTIFICATE := platform
	LOCAL_DEX_PREOPT:=false
	LOCAL_SRC_FILES := $(LOCAL_MODULE).apk
	include $(BUILD_PREBUILT)
hlm@Server:/users/hlm/4_VIM3/device/khadas$ git diff
diff --git a/common/products/mbox/product_mbox.mk b/common/products/mbox/product_mbox.mk
index 7e75d61..45df65e 100644
--- a/common/products/mbox/product_mbox.mk
+++ b/common/products/mbox/product_mbox.mk
@@ -84,6 +84,9 @@ PRODUCT_PACKAGES += \
     FactoryTest
 
+PRODUCT_PACKAGES += \
+    xxx
+

Hi goenjoy,

Thanks again for the help. I will try this solution tomorrow morning. Couple questions

  1. Does the second solution only apply for the apk I sent to u or it’s a general solution? What’s the reason caused the apk I sent to u can’t be installed using ur previous solution?
  2. Based on ur solution, except Android.mk, I also need to modify product_mbox.mk right?

Thanks,

You need system signature for this APK, so you can’t use the general method.