所以,我是一个Android和Java的初学者。我才刚刚开始学习。当我今天用Intent做实验时,我犯了一个错误。

Error:Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed with multiple errors, see logs

我在这里找到了一些解决方案,并试图实施,但没有奏效。

这是我的身材。gradle:

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.0"

defaultConfig {
    applicationId "com.example.rohan.petadoptionthing"
    minSdkVersion 10
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.0'
}

这是我的AndroidManifest:

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

package="com.example.rohan.petadoptionthing" > <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name=".MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".Second" /> <activity android:name=".third"/> <activity android:name=".MainActivity"/> </application> This is my first week with coding, I am sorry if this is a really silly thing. I am really new to this and did not find any other place to ask. Sorry if I broke any rules


当前回答

如果在构建中使用多个manifest占位符项。在Gradle文件中,必须将它们作为数组元素添加,而不是单独的项。

例如,这将导致一个构建错误或编译错误:RuntimeException:合并失败,出现多个错误。

android {
    ...
    defaultConfig {
        manifestPlaceholders = [myKey1: "myValue1"]
        manifestPlaceholders = [myKey2: "myValue2"] // Error!
    }
}

这将修复错误:

android {
    ...
    defaultConfig {
        manifestPlaceholders = [myKey1: "myValue1", myKey2: "myValue2"]
    }
}

其他回答

下面的黑客工作:

中添加xmlns:tools="http://schemas.android.com/tools"行 清单标签 添加 工具:取代= " android:图标,android:主题,android: allowBackup,标签,名称” 在应用程序标签中

作为Android Studio的新手,在我的情况下,我已经将一个现有的项目从Eclipse移动到Android Studio,并发现在我的Manifest.xml中有一个重复的活动定义,而Eclipse没有拾取它,这显示为一个Gradle错误。

我在Gradle控制台(屏幕右下角)找到了这一点。

在我的情况下,我在清单文件的元数据标签中使用firebase vision Dependencies上的多个模型,所以我将它们混合在一个值参数中,它确实解决了我的问题。以下是如何做到的:

<meta-data
    android:name="com.google.mlkit.vision.DEPENDENCIES"
    android:value="ocr,langid"/>

在AndroidManifest.xml: 在应用程序中,添加工具:replace="android:icon, android:theme和 在清单根目录下,添加xmlns:tools="http://schemas.android.com/tools 在build.gradle: 在根节点添加useOldManifestMerger true

最小sdk版本应该与您正在使用的模块/lib相同 例如:你的模块的最小sdk版本是26,你的应用程序的最小sdk版本是21。