问题
I have to build an android application in AOSP source tree with vendor config. Which have some pre-build .so files, I have loaded the .so files by using the following configuration
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_PACKAGE_NAME := MySample
LOCAL_CERTIFICATE := platform
# SRC files
#======================================
LOCAL_SRC_FILES := $(call all-java-files-under, src) \
$(call all-Iaidl-files-under, aidl)
LOCAL_AIDL_INCLUDES := $(LOCAL_PATH)/aidl
# RES files
#================================================
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
LOCAL_RESOURCE_DIR +=./prebuilts/sdk/current/support/v7/appcompat/res
LOCAL_RESOURCE_DIR +=./prebuilts/sdk/current/support/design/res
LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_APPS)
LOCAL_MANIFEST_FILE := AndroidManifest.xml
LOCAL_USE_AAPT2 := true
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_MULTILIB := 32
LOCAL_JNI_SHARED_LIBRARIES := \
libmysamplelib.so
#Adding aapt packages
#==============================================
LOCAL_AAPT_FLAGS := --auto-add-overlay
LOCAL_AAPT_FLAGS += --extra-packages android.support.v7.appcompat
LOCAL_AAPT_FLAGS += --extra-packages android.support.v7.recyclerview
LOCAL_AAPT_FLAGS += --extra-packages android.support.annotations
LOCAL_AAPT_FLAGS += --extra-packages android.support.v4
LOCAL_AAPT_FLAGS += --extra-packages android.support.design
LOCAL_AAPT_FLAGS += --extra-packages com.google.gson
LOCAL_AAPT_FLAGS += --extra-packages com.squareup.picasso
LOCAL_AAPT_FLAGS += --extra-packages com.google.zxing
LOCAL_AAPT_FLAGS += --extra-packages com.google.android.exoplayer2
LOCAL_AAPT_FLAGS += --extra-packages com.google.android.exoplayer2.source.dash
LOCAL_AAPT_FLAGS += --extra-packages com.google.android.exoplayer2.source.hls
LOCAL_AAPT_FLAGS += --extra-packages com.google.android.exoplayer2.source.smoothstreaming
#Include Static libraries
#===============================
LOCAL_STATIC_JAVA_LIBRARIES := android-support-v7-appcompat
LOCAL_STATIC_JAVA_LIBRARIES += android-support-v7-recyclerview
LOCAL_STATIC_JAVA_LIBRARIES += android-support-v4
LOCAL_STATIC_JAVA_LIBRARIES += android-support-v7-gridlayout
LOCAL_STATIC_JAVA_LIBRARIES += android-support-annotations
LOCAL_STATIC_JAVA_LIBRARIES += android-support-design
LOCAL_STATIC_JAVA_LIBRARIES += gson
include $(BUILD_PACKAGE)
#Including prebuild libs
#======================================
include $(CLEAR_VARS)
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := exoplayer2_core:libs/exoplayer-core-2.7.1.aar
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES += exoplayer2_dash:libs/exoplayer-dash-2.7.1.aar
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES += exoplayer2_hls:libs/exoplayer-hls-2.7.1.aar
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES += exoplayer2_smoothstreaming:libs/exoplayer-smoothstreaming-2.7.1.aar
include $(BUILD_MULTI_PREBUILT)
# parsercreator
#========================
include $(CLEAR_VARS)
LOCAL_MODULE := libmysamplelib
LOCAL_SRC_FILES := libs/libmysamplelib.so
LOCAL_MODULE_PATH :=$(TARGET_OUT_VENDOR)/lib
LOCAL_MODULE_CLASS := SHARED_LIBRARIES
LOCAL_MODULE_SUFFIX := .so
LOCAL_32_BIT_ONLY := true
LOCAL_MODULE_TAGS := optional
include $(BUILD_PREBUILT)
include $(call all-makefiles-under,$(LOCAL_PATH))
After flashing the build in the target device the application will not correctly load the application. I suspect the .so files are not included correctly.any help will appriciated
回答1:
Solution for this issue.
I have created a new .mk(LibCopy.mk)
file for copy the .SO
files to the vendor path when the ASOP build, and the LibCopy.mk
will call from the device.mk
file $(call inherit-product-if-exists, <Your application path>/LibCopy.mk)
My LibCopy.mk look like below
PRODUCT_COPY_FILES := \vendor/apps/MySample/lib/<architecture>/libmysamplelib.so:vendor/app/MySample/lib/<architecture>/libmysamplelib.so \
来源:https://stackoverflow.com/questions/51983553/vendor-application-build-aosp