Android on-board application development and analysis - integrated third-party APK

Keywords: Android


In the process of on-board application development, there will be a special need to pre install some third-party apps, such as Baidu map on-board version, on-board wechat and so on. This kind of app OEM will not get the source code, but only one apk.

This article demonstrates how to use AOSP based on Android R_ car_ x86_ The third-party apk is pre installed in x64. aosp_car_x86_x64 we are compiling the build selected by AOSP_ Type, if you don't know how to compile AOSP, you can refer to this article Android Automotive application development and analysis (1) - Android Automotive overview and compilation.

In fact, there are different ways for OEM manufacturers to pre install the third-party APK. This article only demonstrates a relatively simple way.

##1. Directory of application installation

This path stores some underlying applications of the system, such as Setting, systemUI, etc. The app in this directory has high system permissions, and if you want to use android:protectionLevel=signatureOrSystem, the app must be placed in the priv app directory.

The permissions of system apps stored in this directory are relatively low, and when you have root permission, you may uninstall these apps.

This directory stores the vendor's app

This directory stores oem specific app s.

Third party app s installed by users.

When PMS is started, apk s in these directories are scanned and parsed one by one according to the above sequence

##2. Pre install APK
Create a new folder in device/generic/car, such as bilibili, copy the APK to the bilibilibili folder, and create the file, as follows:

LOCAL_PATH:=$(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := bilibili.apk
#It can be compiled for user, eng, tests and optional. Optional means that it can be compiled under any version
#The name of the compiled module
LOCAL_MODULE := bilibili
#It can be testkey, platform, shared, media and preset (using the original signature), and platform represents the system application
#Application output path, here is system/app
#If it is not set or set to false, the installation location is system/app. If it is set to true, the installation location is system / priv app?
#module suffix, optional
# If precompiling is turned off, the OAT file will not be generated

Add bilibili to device/generic/car/

PRODUCT_PACKAGE_OVERLAYS := device/generic/car/common/overlay

$(call inherit-product, device/generic/car/emulator/
$(call inherit-product, $(SRC_TARGET_DIR)/product/

# Add packages to product_ In packages
  bilibili \

PRODUCT_NAME := aosp_car_x86_64
PRODUCT_DEVICE := generic_car_x86_64
PRODUCT_MODEL := Car on x86_64 emulator

Recompile the entire project

# Clear the contents in the corresponding board folder under the out directory
make installclean
make -j8

3. Precautions

  1. Prompt during compilation: Verification error in and Had a hard failure verifying all classes, and was asked to abort in such situations
    Reason: when apk is prefabricated into the system, it will parse the apk and generate an odex file to speed up the startup and operation of the app. Integrate the app developed for the lower version in the higher version Android system (generally, the lower version will report an error), and such a prompt will appear when there is an error in odex file parsing.
    Solution: turn off precompiling in in the folder where apk is placed
# If precompiling is turned off, the OAT file will not be generated

Posted by jesseledwards on Mon, 11 Oct 2021 13:22:04 -0700