所以,我是一个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


当前回答

我看到了答案,它们是完整的和有用的。无论如何,如果你正在完成Jetpack撰写测试代码实验室,并且在2021年底发现了这个错误,解决方案不是可接受的答案,你需要将目标sdk版本降低到30。

在app /构建。gradle,替换:

targetSdkVersion 31

:

targetSdkVersion 30

并再次运行Android测试

其他回答

删除<activity android:name="。MainActivity"/>。正如你已经定义的那样:

 <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>

Manifest文件显示歧义。

打开你的gradle控制台,然后你会看到gradle建议你添加特定的行(如:tools:replace="android:allowBackup"或tools:replace="android:label"等)。将这一行添加到您的清单文件下的标签和同步gradle,就是这样。

检查清单中是否声明了任何重复的活动。这是我的错误,这个错误和问题解决后,删除副本。

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

我也面临着同样的问题,经过大量研究,我找到了解决方案:

Your min sdk version should be same as of the modules you are using eg: your module min sdk version is 14 and your app min sdk version is 9 It should be same. If build version of your app and modules not same. Again it should same ** In short, your app build.gradle file and manifest should have same configurations** There's no duplicacy like same permissions added in manifest file twice, same activity mention twice. If you have delete any activity from your project, delete it from your manifest file as well. Sometimes its because of label, icon etc tag of manifest file: a) Add the xmlns:tools line in the manifest tag. b) Add tools:replace= or tools:ignore= in the application tag.

例子:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.slinfy.ikharelimiteduk"
    xmlns:tools="http://schemas.android.com/tools"
    android:versionCode="1"
    android:versionName="1.0" >

  <application
      tools:replace="icon, label"
      android:label="myApp"
      android:name="com.example.MyApplication"
      android:allowBackup="true"
      android:hardwareAccelerated="false"
      android:icon="@drawable/ic_launcher"
      android:theme="@style/Theme.AppCompat" >
  </application>

</manifest>

如果两个依赖项的版本不同 示例:你正在使用appcompat v7 . 26.0.0和facebook com.facebook.android:facebook-android-sdk:[4,5) facebook使用com.android.support:cardview-v7 . 25.3.1版本的cardview, appcompat v7 . 26.0.0使用v7 . 26.0.0版本的cardview,因此在两个库中存在差异,因此会给出错误

错误:执行失败的任务':app:processDebugManifest'。

清单合并失败:属性元数据#android.support。VERSION@value value=(26.0.0-alpha1) from [com.android.support:appcompat-v7:26.0.0-alpha1] AndroidManifest.xml:27:9-38 [com.android.support:cardview-v7 . 25.3.1] AndroidManifest.xml:24:9-31 value=(25.3.1) 建议:在AndroidManifest.xml:25:5-27:41的元素中添加“tools:replace="android:value"”来覆盖。

因此,通过使用25.3.1版本的appcompat,我们可以避免这个错误

通过考虑以上几点,你将摆脱这个恼人的问题。 你也可以看看我的博客 https://wordpress.com/post/dhingrakimmi.wordpress.com/23