如何在Android Studio中解决Manifest合并失败?

时间:2015-12-26 16:04:08

标签: java eclipse android-studio android-gradle android-manifest

首先抱歉我的英语。但我试着理解我的问题。 我将我的eclipse项目导入android studio并在同步Gradle之后,它显示我的错误

Error:Execution failed for task ':eWatheqOCRLib:processDebugAndroidTestManifest'.> java.lang.RuntimeException: Manifest merger failed : Attribute application@icon value=(@drawable/ic_launcher) from [debug] AndroidManifest.xml:46:9-45
    is also present at [Graddle Build ewatheq:eWatheqEyesTwoLib:unspecified] AndroidManifest.xml:32:18-55 value=(@drawable/service_icon).
    Suggestion: add 'tools:replace="android:icon"' to <application> element at manifestMerger6194683839773316547.xml:7:5-9:19 to override.

我谷歌很多,尝试使用这些堆栈来解决许多问题。 Android studio Gradle icon error, Manifest Merger https://github.com/coomar2841/image-chooser-library/issues/63 https://github.com/pedant/sweet-alert-dialog/issues/33

这是我的build.gradle文件

apply plugin: 'com.android.application'


buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.5.0'
    }
}
repositories {
    mavenCentral()
}

android {
    compileSdkVersion 10
    buildToolsVersion "23.0.2"
    defaultConfig {

        applicationId "ae.ewatheq.external"
        minSdkVersion 10
        targetSdkVersion 22
        versionCode="7"
        versionName="0.0.7.0"
    }


    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }
}
dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    compile files('libs/activation.jar')
    compile files('libs/converter-gson-2.0.0-beta2.jar')
    compile files('libs/crashlytics.jar')
    compile files('libs/gson-2.2.2.jar')
    compile files('libs/hirondelle-date4j-1.5.1.jar')
    compile files('libs/httpclient-4.3.6.jar')
    compile files('libs/httpcore-4.3.3.jar')
    compile files('libs/httpmime-4.3.6.jar')
    compile files('libs/mail.jar')
    compile files('libs/universal-image-loader-1.9.3.jar')
    compile files('libs/volley.jar')
    compile files('libs/YouTubeAndroidPlayerApi.jar')
    compile project(':eWatheqOCRLib')
    compile project(':eWatheqNineOldLibrary')
    compile project(':eWatheqCalDroidLib')
    compile project(':eWatheqFloatingButtonLib')
    compile project(':eWatheqViewPagerIndicatorlibrary')
}

这是我的清单

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="ae.ewatheq.external"
    xmlns:tools="http://schemas.android.com/tools"
    android:versionCode="7"
    android:versionName="0.0.7.0" >

    <uses-sdk
        android:minSdkVersion="10"
        android:targetSdkVersion="22" />

    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.CAMERA" />

    <uses-feature android:name="android.hardware.camera.autofocus" />
    <uses-feature
        android:name="android.hardware.camera.flash"
        android:required="false" />
    <uses-feature android:name="android.hardware.camera" />
    <uses-feature
        android:name="android.hardware.touchscreen"
        android:required="false" />

    <application

        android:name="ae.ewatheq.app.AppController"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme"
        tools:replace="android:icon">

        <activity
            android:name="ae.ewatheq.SplashActivity"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.SEND" />

                <category android:name="android.intent.category.DEFAULT" />

                <data android:mimeType="image/*" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.VIEW" >
                </action>

                <category android:name="android.intent.category.DEFAULT" >
                </category>
                <category android:name="android.intent.category.BROWSABLE" >
                </category>

                <data android:mimeType="image/*" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.VIEW" >
                </action>

                <category android:name="android.intent.category.DEFAULT" >
                </category>
                <category android:name="android.intent.category.BROWSABLE" >
                </category>

                <data
                    android:mimeType="application/pdf"
                    android:scheme="file" >
                </data>
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.VIEW" >
                </action>

                <category android:name="android.intent.category.DEFAULT" >
                </category>
                <category android:name="android.intent.category.BROWSABLE" >
                </category>

                <data
                    android:mimeType="application/pdf"
                    android:scheme="content" >
                </data>
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.VIEW" >
                </action>

                <category android:name="android.intent.category.DEFAULT" >
                </category>
                <category android:name="android.intent.category.BROWSABLE" >
                </category>

                <data
                    android:host="*"
                    android:pathPattern=".*\.[pP][dD][fF]"
                    android:scheme="file" />
            </intent-filter>
        </activity>
        <activity
            android:name="ae.ewatheq.FilesActivity"
            android:label="@string/app_name" />
        <activity
            android:name="ae.ewatheq.HelpActivity"
            android:label="@string/app_name" />
        <activity
            android:name="ae.ewatheq.SignInActivity"
            android:configChanges="orientation|screenSize|keyboardHidden"
            android:label="@string/app_name" />
        <activity
            android:name="ae.ewatheq.RegisterActivity"
            android:configChanges="orientation|screenSize|keyboardHidden"
            android:label="@string/app_name" />
        <activity
            android:name="ae.ewatheq.MainActivity"
            android:configChanges="orientation|screenSize|keyboardHidden"
            android:label="@string/app_name" />
       <!-- <activity
            android:name="com.artifex.mupdflib.MuPDFActivity"
            android:label="@string/app_name"
            android:screenOrientation="portrait" />
        <activity
            android:name="com.artifex.mupdflib.PDFPreviewGridActivity"
            android:label="@string/app_name"
            android:screenOrientation="portrait" />-->
        <activity
            android:name="ewatheq.ocr.lib.HelpActivity"
            android:label="@string/app_name"
            android:screenOrientation="landscape" />
        <activity
            android:name="ewatheq.ocr.lib.OCRActivity"
            android:label="@string/app_name"
            android:screenOrientation="landscape" />
        <activity android:name="com.soundcloud.android.crop.CropImageActivity" />

        <meta-data
            android:name="com.crashlytics.ApiKey"
            android:value="7f09b80a5dde30b3ef46aaf1e3e241777d9ac74a" />
    </application>

</manifest>

请帮助我,以便我可以继续。

1 个答案:

答案 0 :(得分:-1)

您的模块中存在明显的合并冲突,而不是主项目中的冲突。

从错误日志中,当eWatheqOCRLib中的清单看起来与ewatheq:eWatheqEyesTwoLib清单中的icon元素冲突时,eWatheqOCRLib模块中会发生冲突。

添加以下行:

tools:replace="android:icon"

eWatheqOCRLib模块中的清单,应该可以解决此错误。