LineageOS18.1内置第三方应用APK

前置条件:需要repo 出完整的版本源码。

以百度输入法为例。

将百度输入法apk文件命名为baidushuru.apk,那么在${lineageos_source_code}/packages/apps/目录下新建一个baidushuru

目录。并将baidushuru.apk放于此目录下。并新建Android.mk文件,并将baidushuru.apk文件中的lib目录放置于此目录下。如图:

其中Android.mk文件内容如下:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := baidushuru

LOCAL_MODULE_TAGS := optional

LOCAL_CERTIFICATE := PRESIGNED

LOCAL_SRC_FILES := baidushuru.apk

LOCAL_MODULE_CLASS := APPS

#LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
LOCAL_MODULE_SUFFIX := .apk

#LOCAL_BUILT_MODULE_STEM := package.apk
LOCAL_MODULE_PATH   := $(PRODUCT_OUT)/system/app

 
#LOCAL_MODULE_PATH := $(TARGET_OUT)/app
 
#LOCAL_DEX_PREOPT := false
LOCAL_PREBUILT_JNI_LIBS := \
                                        @lib/armeabi-v7a/libBaiduSpeechSDK.so \
                                        @lib/armeabi-v7a/libbdinput_gif_v1_0_10.so \
                                        @lib/armeabi-v7a/libchiperencoder_v1_2_1.so \
                                        @lib/armeabi-v7a/libfire.so \
                                        @lib/armeabi-v7a/libime_graphics.so \
                                        @lib/armeabi-v7a/libmiuiblursdk.so \
                                        @lib/armeabi-v7a/libp.so \
                                        @lib/armeabi-v7a/libQt.so \
                                        @lib/armeabi-v7a/librsjni.so \
                                        @lib/armeabi-v7a/libRSSupport.so \
                                        @lib/armeabi-v7a/libsimeji_ime.so \
                                        @lib/armeabi-v7a/libvad.dnn.so \
                                        @lib/armeabi-v7a/libxcrash.so \
                                        @lib/armeabi-v7a/libxcrash_dumper.so \
                                        @lib/armeabi-v7a/libyoga.so \
                                        @lib/arm64-v8a/libBaiduSpeechSDK.so \
                                        @lib/arm64-v8a/libbdinput_gif_v1_0_10.so \
                                        @lib/arm64-v8a/libchiperencoder_v1_2_1.so \
                                        @lib/arm64-v8a/libfire.so \
                                        @lib/arm64-v8a/libime_graphics.so \
                                        @lib/arm64-v8a/libmiuiblursdk.so \
                                        @lib/arm64-v8a/libp.so \
                                        @lib/arm64-v8a/libQt.so \
                                        @lib/arm64-v8a/librsjni.so \
                                        @lib/arm64-v8a/libRSSupport.so \
                                        @lib/arm64-v8a/libsimeji_ime.so \
                                        @lib/arm64-v8a/libvad.dnn.so \
                                        @lib/arm64-v8a/libxcrash.so \
                                        @lib/arm64-v8a/libxcrash_dumper.so \
                                        @lib/arm64-v8a/libyoga.so \
include $(BUILD_PREBUILT)

LOCAL_PREBUILT_JNI_LIBS参数为lib文件下的所有so名。我在弄内置微信时发现微信apk的so贼多,我写了个脚本方便直接复制粘贴。

from array import array
from os import walk

mypath = "lib_path"

filenames = next(walk(mypath), (None, None, []))[2]

array = []

for i in filenames:
    # for armv7
    string = "                     @lib/armeabi-v7a/"  + i + " \\"
    array.append(string)
    pass

for i in array:
    print(i)
posted @ 2022-03-06 11:56  Tu9oh0st  阅读(600)  评论(1编辑  收藏  举报