Different Ways to fix "Execution failed for task ':processDebugManifest'" in Android Studio - GeeksforGeeks

17 Mar, 2021
AndroidManifest.xml file is one of the most important files in your Android Project. This file handles all other files in your Android Studio Project and also provides apk name and app logo for the generated apk in Android. Many times while building an Android project our Manifest file gets overwritten. So we will get to see this kind of issue as Execution failed for task ‘:processDebugManifest” in Android Project. The error dialog is shown below:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':ItchyFeet:processDebugManifest'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
at org.gradle.api.internal.changedetection.state.CacheLockReleasingTaskExecuter$1.run(CacheLockReleasingTaskExecuter.java:35)
at org.gradle.internal.Factories$1.create(Factories.java:22)
at org.gradle.cache.internal.DefaultCacheAccess.longRunningOperation(DefaultCacheAccess.java:179)
at org.gradle.cache.internal.DefaultCacheAccess.longRunningOperation(DefaultCacheAccess.java:232)
at org.gradle.cache.internal.DefaultPersistentDirectoryStore.longRunningOperation(DefaultPersistentDirectoryStore.java:142)
at org.gradle.api.internal.changedetection.state.DefaultTaskArtifactStateCacheAccess.longRunningOperation(DefaultTaskArtifactStateCacheAccess.java:83)
at org.gradle.api.internal.changedetection.state.CacheLockReleasingTaskExecuter.execute(CacheLockReleasingTaskExecuter.java:33)
...........................................................................................................................
...........................................................................................................................
So in this article, we will take a look at resolving this issue with 5 different methods.
Method 1: Adding a code snippet in your build.gradle file
Method 2: Adding node in your AndroidManifest.xml file
Method 3: Update your minSDK and targetSDK to the highest version
Method 4: Remove duplicates from your Manifest file
Method 5: Check the requirements when adding a new dependency
In this method, we will be updating the build Tools version and check for the issue. For this process add the below code in your build.gradle file. Navigate to the app > Gradle Scripts > build.gradle (:app) and add the below code snippet to the dependencies section. Comments are added to it to get to know in more detail. 
// in below line we are adding configurations to to our project.
configurations.all {
    // in below line we are adding strategy for each dependency and requesting the details 
    resolutionStrategy.eachDependency {DependencyResolveDetails details ->
        // on below line we are getting to see the details using requested. 
        def requested = details.requested
        // in below line we are requesting a group. 
        if (requested.group == 'com.android.support'){
            // on below line we are checking if the request is a group and checking if it starts with com.android.support.
            if(!requested.name.startsWith("multidex")){
                // if the requested name starts with multi dex then we are displaying the use version which is given below. 
                details.useVersion '25.3.0'
            }
        }
    }
} 
After adding this code now sync your project and again run your application to solve this issue. 
In this process, we will be adding an attribute in our AndroidManifest.xml file. We have to add this attribute in the application tag which is shown below. Below is the code for the whole Manifest file. After adding this file. Sync your project and run your project again to solve this issue. 
XML
<manifest xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    package="com.example.gfgpagination">      <uses-permission android:name="android.permission.INTERNET" />    <application        android:allowBackup="true"        android:icon="@mipmap/ic_launcher"        tools:node="replace"        android:label="@string/app_name"        android:roundIcon="@mipmap/ic_launcher_round"        android:supportsRtl="true"        android:theme="@style/Theme.GFGPagination">        <!--below is the code for default activity which is Main Activity-->        <activity android:name=".MainActivity">            <!--Inside this activity you should be having below code for intent filter which will check the default activity-->            <intent-filter>                <action android:name="android.intent.action.MAIN" />                  <category android:name="android.intent.category.LAUNCHER" />            </intent-filter>        </activity>    </application>  </manifest>
Navigate to the app > Gradle Script > build.gradle (:app) and add update your SDK version in the default config section which is shown below. Add the below code in the default config section and sync your project. After adding this code sync your project and now run your app to solve this issue. 
defaultConfig {
        applicationId "com.example.gfgpagination"
        minSdkVersion 19
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
  } 
When you are using Firebase or any other external services in your project. There is some block of code that is added multiple times. Remove the duplicate code which is added in your Manifest file. Sync your project and then run your app to solve this issue. 
When we are adding a new dependency make sure to check the dependency requirements such as minSDK version and targetSDK version which are required for this dependency. If multiple dependencies show conflicts in your Gradle file then we may have to remove that dependency to solve this issue.   
Android-Studio
Picked
Android
Android
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Retrofit with Kotlin Coroutine in Android
Flutter - Custom Bottom Navigation Bar
Android Listview in Java with Example
How to Read Data from SQLite Database in Android?
How to Change the Background Color After Clicking the Button in Android?
MVP (Model View Presenter) Architecture Pattern in Android with Example
Fragment Lifecycle in Android
How to Add Image to Drawable Folder in Android Studio?
How to Post Data to API using Retrofit in Android?
Animation in Android with Example