Android Manifest uses uses-library compilation error when Android S builds APK

(1) Errors in installation or compilation

Google's changes in Android S in this regard have document output, you can refer to the following: Deexpreopt and uses-library inspection .

This error is mainly because the build system performs a build-time consistency check between the information in the Android.bp or Android.mk file and the Manifest list. It is required to declare that the libraries used by the request are consistent with those declared in the AndroidManifest.xml, otherwise an error will be reported.

Next, check the compilation error:

error: mismatch in the <uses-library> tags between the build system and the manifest:
    - required libraries in build system: []
                     vs. in the manifest: [org.apache.http.legacy]
    - optional libraries in build system: []
                     vs. in the manifest: [com.x.y.z]
    - tags in the manifest (.../X_intermediates/manifest/AndroidManifest.xml):
        <uses-library android:name="com.x.y.z"/>
        <uses-library android:name="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

According to the prompts, you can make the following three attempts to modify:

(A) Product-wide temporary fix : configure PRODUCT_BROKEN_VERIFY_USES_LIBRARIES := true in MK ;

This will still perform a build-time consistency check, but a failure of the check does not mean a build failure. Conversely, a check failure causes the build system to downgrade the dex2oat compiler filter to verify in dexpreopt, completely disabling AOT compilation of this module.

(B) Quick global command line repair : please use the environment variable RELAX_USES_LIBRARY_CHECK=true;

It has the same effect as PRODUCT_BROKEN_VERIFY_USES_LIBRARIES but is intended for use on the command line. Environment variables override product variables.

(C) Root cause fix : please make the build system aware of the flags in the manifest;

Check the list in AndroidManifest.xml or APK, you can use aapt dump badging $APK | grep uses-library to check, and then configure the following in the MK file:

//LOCAL_USES_LIBRARIES := <library-module-name>
//LOCAL_OPTIONAL_USES_LIBRARIES := <library-module-name>

LOCAL_OPTIONAL_USES_LIBRARIES := org.apache.http.legacy    androidx.window.extensions     androidx.window.sidecar

(2) once and for all

//Android.bp

enforce_uses_libs: false,
dex_preopt: {
    enabled: false,
},

//Android.mk

LOCAL_ENFORCE_USES_LIBRARIES := false
LOCAL_DEX_PREOPT := false


---------------------
Author: Xuewu Feiying
Source: CSDN
Original:
https://blog.csdn.net/dongxianfei/article/details/123665498Copyright Disclaimer: This article is the author's original article, please attach the link to the blog post for reprinting!
Content analysis By: CSDN, CNBLOG blog post one-click reprint plug-in

Guess you like

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