前言
在Android 12源碼更新适配是, 需要内置各種第三方APK, 如搜狗輸入法, FIrefox等,使用Android9上的Android.mk進行編譯, 發現會報錯。
出錯資訊
FAILED: out/target/common/obj/APPS/SogouInputMi_intermediates/enforce_uses_libraries.status
/bin/bash -c "(rm -f out/target/common/obj/APPS/SogouInputMi_intermediates/enforce_uses_libraries.status ) && (build/soong/scripts/manifest_check.py --enforce-uses-libraries --enforce-uses-libraries-status out/target/common/obj/APPS/SogouInputMi_intermediates/enforce_uses_libraries.status --aapt out/host/linux-x86/bin/aapt device/rochchip/rk3399/common/apps/SogouInput_xiaomi/SogouInputMi.apk )"
error: mismatch in the <uses-library> tags between the build system and the manifest:
- required libraries in build system: []
vs. in the manifest: []
- optional libraries in build system: []
vs. in the manifest: [org.apache.http.legacy]
- tags in the manifest (device/rochchip/rk3399/common/apps/SogouInput_xiaomi/SogouInputMi.apk):
uses-library-not-required:'org.apache.http.legacy'
note: the following options are available:
- to temporarily disable the check on command line, rebuild with RELAX_USES_LIBRARY_CHECK=true (this will set compiler filter "verify" and disable AOT-compilation in dexpreopt)
- to temporarily disable the check for the whole product, set PRODUCT_BROKEN_VERIFY_USES_LIBRARIES := true in the product makefiles
- to fix the check, make build system properties coherent with the manifest
- see build/make/Changes.md for details
解決方法
修改Android.mk,添加LOCAL_ENFORCE_USES_LIBRARIES := false,
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := APPS
LOCAL_MODULE := SogouInputMi
LOCAL_SRC_FILES := $(LOCAL_MODULE).apk
LOCAL_PREBUILT_JNI_LIBS := $(subst $(LOCAL_PATH)/,,$(wildcard $(LOCAL_PATH)/lib/arm64-v8a/*.so))
LOCAL_PRIVILEGED_MODULE := true
LOCAL_OVERRIDES_PACKAGES := LatinIME
LOCAL_CERTIFICATE := PRESIGNED
#LOCAL_CERTIFICATE := $(DEFAULT_SYSTEM_DEV_CERTIFICATE)
LOCAL_ENFORCE_USES_LIBRARIES := false