简体   繁体   中英

Android Manifest merger failure

I have two android projects working individually (A and B). I have made a parent project with two buttons that calls each of these child projects (I have included the child projects as libraries). Initially I added one child project to my parent project and it works fine. However, upon adding the second child project, I get an android manifest merger error. Each of the child application need an SDK key to register upon startup. This is defined in the manifest as below:

Child app A:

<application
    android:name=".DemoApplication"
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme"
    tools:replace="android:icon">

    <!-- DJI SDK -->
    <uses-library android:name="com.android.future.usb.accessory" />

    <meta-data
        android:name="com.dji.sdk.API_KEY"
        android:value="f70d587986XXXXXXXXXX"/>

Child App B:

<application
    android:name=".DJIDemoApplication"
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">

    <!-- DJI SDK -->

    <uses-library android:name="com.android.future.usb.accessory" />

    <meta-data
        android:name="com.dji.sdk.API_KEY"
        android:value="2cde5eaabXXXXXXXXXXXX" /> //TODO: Enter your app key here

The error android manifest gives seems to do with the API_KEY value in metadata portion. My guess is that upon manifest merge, it does not know which value of API_KEY to use. However, I need both values to register both apps A and B. I have tried adding 'tools:replace=android:value' to one of the child applications but the compiled application only runs one child. The exact error is as follows:

Error: Attribute meta-data#com.dji.sdk.API_KEY@value value=(f70d587986XXXXXXXXXX) from AndroidManifest.xml:34:55-95 is also present at AndroidManifest.xml:34:55-95 value=(2cde5eaabXXXXXXXXXXXXX). Suggestion: add 'tools:replace="android:value"' to <meta-data> element at AndroidManifest.xml:34:9-97 to override. app main manifest (this file), line 33

I am new to android and don't know how to resolve this issue. Any help regarding this will be highly appreciated.

add ' tools:replace="android:value" ' to element at AndroidManifest.xml

this error caused by

<meta-data
        android:name="com.dji.sdk.API_KEY"
        android:value="2cde5eaabXXXXXXXXXXXX" />

prensent in both files

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM