Manifest Merger错误 - 工具:替换不工作

时间:2016-09-02 06:30:39

标签: android android-manifest

更新

我已经尝试了一切。 Manifest合并工具有什么问题吗?

  • 工具:替换
  • 工具:除去
  • 工具:忽略
  • 工具:节点

无法解决以下错误:

D:\AndroidStudioProjects\Iknowthis2\app\src\main\AndroidManifest.xml:29:9-36
Error: Attribute application@allowBackup value=(false) from AndroidManifest.xml:29:9-36 is also present at [com.sackcentury:shinebutton:0.1.5] AndroidManifest.xml:12:9-35 value=(true).     
Suggestion: add 'tools:replace="android:allowBackup"'to <application> element at AndroidManifest.xml:27:5-73:19 to override.

D:\AndroidStudioProjects\Iknowthis2\app\src\main\AndroidManifest.xml:34:9-36
Error:  Attribute application@supportsRtl value=(false) from AndroidManifest.xml:34:9-36 is also present at [com.sackcentury:shinebutton:0.1.5] AndroidManifest.xml:14:9-35 value=(true).
Suggestion: add 'tools:replace="android:supportsRtl"' to <application> element at AndroidManifest.xml:27:5-73:19 to override.

应用程序的原始Manifest.xml - 在工具之前:替换

 <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="xyz">

    <!-- Include following permission if you load images from Internet -->
    <uses-permission android:name="android.permission.INTERNET" />
    <!-- Include following permission if you want to cache images on SD card -->
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

    <application
        android:name=".ABC"
        android:allowBackup="false"
        android:fullBackupContent="false"
        android:hardwareAccelerated="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="false"
        android:theme="@style/Theme"
        tools:ignore="GoogleAppIndexingWarning,UnusedAttribute">


        <activity
            android:name="com.facebook.FacebookActivity"
            android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
            android:label="@string/app_name"
            android:theme="@android:style/Theme.Translucent.NoTitleBar" />

        <meta-data
            android:name="com.facebook.sdk.ApplicationId"
            android:value="@string/facebook_app_id" />

        <activity
            android:name=".activity.SignInActivity"
            android:windowSoftInputMode="adjustPan">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

图书馆的Manifest.xml:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.sackcentury.shinebuttonlib">

    <application android:allowBackup="true" android:label="@string/app_name"
        android:supportsRtl="true">

    </application>

</manifest>

5 个答案:

答案 0 :(得分:44)

就我而言,

从清单文件中删除tools:ignore并添加tools:replace="allowBackup,supportsRtl"为我工作。

更新

另一种解决方案看起来很有希望,但我从未尝试过。

 <application
    xmlns:tools="http://schemas.android.com/tools"  <-- added tools on application tag
    android:name=".ABC"
    android:allowBackup="false"
    android:fullBackupContent="false"
    android:hardwareAccelerated="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="false"
    android:theme="@style/Theme"
    tools:replace="allowBackup,supportsRtl"
    tools:ignore="GoogleAppIndexingWarning,UnusedAttribute">

答案 1 :(得分:6)

据我所知,我们不能同时使用tools:replacetools:ignore。因此,您可以从AndroidManifest.xml声明中删除一个。

答案 2 :(得分:0)

在清单文件中添加以下代码-

只需在应用程序标记中添加tools:replace =“ android:allowBackup”

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.example.exampleapp">

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

答案 3 :(得分:0)

它对我来说很好用。我的清单文件看起来像:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:tools="http://schemas.android.com/tools"
 package="package name">

 <application       
    android:allowBackup="false"
    android:fullBackupContent="false"
    android:hardwareAccelerated="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"       
    android:supportsRtl="false"
    android:theme="@style/AppTheme"
    android:usesCleartextTraffic="true"
    tools:replace="allowBackup,supportsRtl"
    tools:ignore="GoogleAppIndexingWarning,UnusedAttribute">

    </application>

  </manifest>

答案 4 :(得分:-2)

只需在清单的应用程序标记中添加tools:replace =“ android:allowBackup”。这会起作用。