INSTALL_FAILED_MISSING_SHARED_LIBRARY error occurs when android install apk

Provide a jar package interface based on the add-on method to colleagues in the app group, and encountered an INSTALL_FAILED_MISSING_SHARED_LIBRARY error during debugging.

The background of encapsulating interfaces in add-on mode is to provide stub empty interfaces. App integration is only for normal reference jar package compilation, and the real runtime mainly depends on the current system, which avoids the dominant interface due to the system jar Control rights, in the case of no major changes to the interface, the app does not care about the actual implementation of the interface.

Add a reference to the dynamic library in app AndroidManifest.xml, as follows:

<uses-library android:name="com.test.audio" />

Put it here, when the system does not add platform.xml (device path/system/etc/permission/platform.xml), the application reports INSTALL_FAILED_MISSING_SHARED_LIBRARY error

Let's first take a look at where the lib library opened to the application by the android system is added
framework/base/data/etc/platform.xml

    <!-- This is a list of all the libraries available for application
         code to link against. -->

    <library name="android.test.mock"
            file="/system/framework/android.test.mock.jar" />
    <library name="android.test.runner"
            file="/system/framework/android.test.runner.jar" />
    <library name="javax.obex"
            file="/system/framework/javax.obex.jar" />
    <library name="org.apache.http.legacy"
            file="/system/framework/org.apache.http.legacy.jar" />

So we add our own interface library to the corresponding directory of the system, in order to understand the coupling, directly add our own xml compilation
platform_test_audio.xml

<?xml version="1.0" encoding="utf-8"?>

<permissions>
    <library name="com.test.audio"
            file="/system/framework/com.test.audio.jar" />
</permissions>

Add and compile the Andorid.mk of the interface module:

########################
include $(CLEAR_VARS)
LOCAL_MODULE := platform_test_audio.xml
LOCAL_MODULE_CLASS := ETC
LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/permissions
LOCAL_SRC_FILES := $(LOCAL_MODULE)
include $(BUILD_PREBUILT)

#LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
**# 接口模块的jar包名,app运行真正依赖的库**
LOCAL_MODULE := com.test.audio
LOCAL_SRC_FILES := $(call all-java-files-under, libaudio/src/main/java)

# LOCAL_DEX_PREOPT := false

LOCAL_JAVA_LIBRARIES += framework

LOCAL_REQUIRED_MODULES := platform_test_audio.xml

include $(BUILD_JAVA_LIBRARY)

The app uses the use-library library, which can be summed up to three points:
1. The app uses the add-on stub jar to reference and compile;
2. The system/system/framework has an interface that depends on the system to implement the jar package com.test.audio.jar ;
3. System /system/etc/permission/platfrom_xx.xml releases the path assigned to the app call library.
.

Guess you like

Origin blog.csdn.net/jeephao/article/details/107432720