Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't build apk in android studio because getting Execution failed for task ':app:processDebugAndroidTestManifest'

This is on the Android Studio Electric Eel | 2022.1.1 Patch 2, but I last built the app on version 4.x.x. When trying to run the build apk command, it gives me these errors:

> Task :app:processDebugAndroidTestManifest FAILED
[androidx.test.espresso:espresso-core:3.2.0] C:\Users\Jason_A\.gradle\caches\transforms-3\aaf0029a0d039603c4fc1b2830c7e911\transformed\espresso-core-3.2.0\AndroidManifest.xml Warning:
    Namespace 'androidx.test.espresso' used in: androidx.test.espresso:espresso-core:3.2.0, androidx.test.espresso:espresso-idling-resource:3.2.0.
G:\Coding\Android_Studio\YouTubeStartEndTime\app\build\intermediates\tmp\manifest\androidTest\debug\tempFile1ProcessTestManifest7671241862673218921.xml:27:9-33:20 Error:
    android:exported needs to be explicitly specified for element <activity#androidx.test.core.app.InstrumentationActivityInvoker$BootstrapActivity>. Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.
G:\Coding\Android_Studio\YouTubeStartEndTime\app\build\intermediates\tmp\manifest\androidTest\debug\tempFile1ProcessTestManifest7671241862673218921.xml:34:9-40:20 Error:
    android:exported needs to be explicitly specified for element <activity#androidx.test.core.app.InstrumentationActivityInvoker$EmptyActivity>. Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.
G:\Coding\Android_Studio\YouTubeStartEndTime\app\build\intermediates\tmp\manifest\androidTest\debug\tempFile1ProcessTestManifest7671241862673218921.xml:41:9-47:20 Error:
    android:exported needs to be explicitly specified for element <activity#androidx.test.core.app.InstrumentationActivityInvoker$EmptyFloatingActivity>. Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.

See https://developer.android.com/r/studio-ui/build/manifest-merger for more information about the manifest merger.


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

* Try:
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:processDebugAndroidTestManifest'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:142)
    at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:282)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:140)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTask
...

Caused by: java.lang.RuntimeException: Manifest merger failed with multiple errors, see logs
    at com.android.build.gradle.tasks.ProcessTestManifest.handleMergingResult(ProcessTestManifest.kt:346)
    at com.android.build.gradle.tasks.ProcessTestManifest.mergeManifestsForTestVariant(ProcessTestManifest.kt:316)
    at com.android.build.gradle.tasks.ProcessTestManifest.doTaskAction(ProcessTestManifest.kt:116)
    at com.android.build.gradle.internal.tasks.NonIncrementalTask$taskAction$$inlined$recordTaskAction$1.invoke(BaseTask.kt:66)
    at com.android.build.gradle.internal.tasks.Blocks.recordSpan(Blocks.java:51)
    at com.android.build.gradle.internal.tasks.NonIncrementalTask.taskAction(NonIncrementalTask.kt:97)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

...

This is my AndroidManifest.xml

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

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

        <activity android:name=".MainActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

</manifest>

The build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 33

    defaultConfig {
        applicationId "com.example.youtubestartendtime"
        minSdkVersion 16
        targetSdkVersion 33
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    namespace 'com.example.youtubestartendtime'
    buildToolsVersion '33.0.1'
    ndkVersion '25.2.9519653'
}

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

}

And this is the manifest-merger-blame-debug-report

1<?xml version="1.0" encoding="utf-8"?>
2<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3    package="com.example.youtubestartendtime"
4    android:versionCode="1"
5    android:versionName="1.0" >
6
7    <uses-sdk
8        android:minSdkVersion="16"
8-->G:\Coding\Android_Studio\YouTubeStartEndTime\app\src\main\AndroidManifest.xml
9        android:targetSdkVersion="33" />
9-->G:\Coding\Android_Studio\YouTubeStartEndTime\app\src\main\AndroidManifest.xml
10
11    <application
11-->G:\Coding\Android_Studio\YouTubeStartEndTime\app\src\main\AndroidManifest.xml:4:5-20:19
12        android:allowBackup="true"
12-->G:\Coding\Android_Studio\YouTubeStartEndTime\app\src\main\AndroidManifest.xml:5:9-35
13        android:appComponentFactory="androidx.core.app.CoreComponentFactory"
13-->[androidx.core:core:1.3.0] C:\Users\Jason_A\.gradle\caches\transforms-3\87c712ceb280b89563e287f590257de7\transformed\core-1.3.0\AndroidManifest.xml:24:18-86
14        android:debuggable="true"
15        android:icon="@mipmap/ic_launcher"
15-->G:\Coding\Android_Studio\YouTubeStartEndTime\app\src\main\AndroidManifest.xml:6:9-43
16        android:label="@string/app_name"
16-->G:\Coding\Android_Studio\YouTubeStartEndTime\app\src\main\AndroidManifest.xml:7:9-41
17        android:roundIcon="@mipmap/ic_launcher_round"
17-->G:\Coding\Android_Studio\YouTubeStartEndTime\app\src\main\AndroidManifest.xml:8:9-54
18        android:supportsRtl="true"
18-->G:\Coding\Android_Studio\YouTubeStartEndTime\app\src\main\AndroidManifest.xml:9:9-35
19        android:theme="@style/AppTheme" >
19-->G:\Coding\Android_Studio\YouTubeStartEndTime\app\src\main\AndroidManifest.xml:10:9-40
20        <activity
20-->G:\Coding\Android_Studio\YouTubeStartEndTime\app\src\main\AndroidManifest.xml:12:9-19:20
21            android:name="com.example.youtubestartendtime.MainActivity"
21-->G:\Coding\Android_Studio\YouTubeStartEndTime\app\src\main\AndroidManifest.xml:12:19-47
22            android:exported="true" >
22-->G:\Coding\Android_Studio\YouTubeStartEndTime\app\src\main\AndroidManifest.xml:13:13-36
23            <intent-filter>
23-->G:\Coding\Android_Studio\YouTubeStartEndTime\app\src\main\AndroidManifest.xml:14:13-18:29
24                <action android:name="android.intent.action.MAIN" />
24-->G:\Coding\Android_Studio\YouTubeStartEndTime\app\src\main\AndroidManifest.xml:15:17-69
24-->G:\Coding\Android_Studio\YouTubeStartEndTime\app\src\main\AndroidManifest.xml:15:25-66
25
26                <category android:name="android.intent.category.LAUNCHER" />
26-->G:\Coding\Android_Studio\YouTubeStartEndTime\app\src\main\AndroidManifest.xml:17:17-77
26-->G:\Coding\Android_Studio\YouTubeStartEndTime\app\src\main\AndroidManifest.xml:17:27-74
27            </intent-filter>
28        </activity>
29    </application>
30
31</manifest>

The program recommended that I update the SDKs, so I had to change target SDKs from 28 to 33 (otherwise it would complain that the target needs to be at least 30). I also had to update all the android sdk tools to be current. Had to add android:exported="true" to the AndroidManifest.xml but these errors seem to be saying that this code is needed in another location? I thought that changing the minsdk and targetsdk in AndroidManifest.xml and build.gradle to be the same would fix it but still get the same error. Not sure if there is a way for android studio to give a clearer indication of what the problem is but I'm at a loss here.

like image 333
monzano Avatar asked Sep 12 '25 03:09

monzano


1 Answers

I figured it out. Went to the build.gradle(app) file and updated the dependencies to be current. Just went for the quickfixes in the problems section of android studio.

before:

    dependencies {
        implementation fileTree(dir: "libs", include: ["*.jar"])
        implementation 'androidx.appcompat:appcompat:1.2.0'
        implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'androidx.test.ext:junit:1.1.1'
        androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    }

after:

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}
like image 52
monzano Avatar answered Sep 13 '25 16:09

monzano