RK3399 android8.1 compile third-party APK into system image

Part 1: Third-party APK without lib

1. Add third-party APK

        Under the android8.1/packages directory, add a thirdpart/music folder. Put the apk file into the music folder.

Add Android.mk file in the same directory:

LOCAL_PATH := $(call my-dir)
 
include $(CLEAR_VARS)
 
LOCAL_MODULE := MusicDemo
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := app_e.apk
LOCAL_MODULE_CLASS := APPS
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
LOCAL_CERTIFICATE := PRESIGNED
include $(BUILD_PREBUILT)

The generated apk is placed in the system/app directory by default and cannot be uninstalled.

If you want to specify a directory, you can modify LOCAL_MODULE_PATH:

LOCAL_MODULE_PATH := $(TARGET_OUT)/vendor/operator/app APK is in the system/vendor/operator/app directory, it can be uninstalled, and the factory settings can be restored.

LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS) APK is in the data/app directory,

It can be uninstalled, and the factory settings cannot be restored.

LOCAL_MODULE_PATH := $(TARGET_OUT)/priv-app 或者 LOCAL_PRIVILEGED_MODULE := true 

APK cannot be uninstalled under the system/priv-app directory.

Add device.mk in the packages/thirdpart directory:

# apps
PRODUCT_PACKAGES +=    \
                       MusicDemo

2. Modify the compilation information (it has nothing to do with adding a third-party APK, it is not necessary)

Add build_id.mk file in android8.1/device/rockchip/rk3399/rk3399_firefly_mid directory

export BUILD_ID=TE-Project-2022
export BUILD_NUMBER=$(shell date +%Y%m%d)
export BUILD_PLATFORM=RK
export BUILD_PRJ_NAME=TEProject
export BUILD_PRJ_TYPE=D
export BUILD_PRJ_NUMBER=TEProject2022
export BUILD_DATE=$(BUILD_NUMBER)
export BUILD_SF_VERSION=V01.00_$(BUILD_DATE)
export BUILD_HW_VERSION=V01.00_20220801
 

3. Add to the system compilation file

Modify rk3399_firefly_mid.mk in the android8.1/device/rockchip/rk3399 directory

#by mode
include device/rockchip/rk3399/rk3399_firefly_mid/build_id.mk //修改编译信息(不必要)
 
$(call inherit-product, $(SRC_TARGET_DIR)/product/full_base.mk)
include device/rockchip/rk3399/rk3399_firefly_mid/BoardConfig.mk
# Inherit from those products. Most specific first.
$(call inherit-product, device/rockchip/rk3399/device.mk)
$(call inherit-product, device/rockchip/common/device.mk)
 
#by mode
$(call inherit-product, packages/thirdpart/device.mk)  //添加自定义Module
 

Part 2: Third-party APK without lib

1. Add third-party APK

Create a new soapk folder in the android8.1/packages/thirdpart directory, and add the third-party Apk file soApk.apk

2. Add so library

Unzip the APK file, extract the lib folder, and place it under the soapk folder.

 Select the so files in different folders according to your own equipment

You can also dynamically choose to get the current device information

my_archs := arm arm64
my_src_arch := $(call get-prebuilt-src-arch, $(my_archs))

Create a new Android.mk file

LOCAL_PATH := $(call my-dir)
 
include $(CLEAR_VARS)
LOCAL_MODULE := SoApk
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := soApk.apk
LOCAL_MODULE_CLASS := APPS
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
LOCAL_PREBUILT_JNI_LIBS :=lib/arm64-v8a/libJniLib.so
LOCAL_CERTIFICATE := platform
include $(BUILD_PREBUILT)
 

3. Add MODULE

Add device.mk in the android8.1/packages/thirdpart directory

# apps
PRODUCT_PACKAGES +=    \
                       MusicDemo \
                        SoApk

Guess you like

Origin blog.csdn.net/xiaowang_lj/article/details/131783076