Manifest merger failed with multiple errors, see logs even after setting export in all components

I am getting below error while building apk. It is running properly on android device but apk is not build. I have set android:exported="false" in all activity, receiver and services.

Task :app:processDebugAndroidTestManifest FAILED
[androidx.test.espresso:espresso-core:3.2.0] /home/bansal/.gradle/caches/transforms-2/files-2.1/a88c494942c30cb858ca2f4a16161a0e/espresso-core-3.2.0/AndroidManifest.xml Warning:
Package name ‘androidx.test.espresso’ used in: androidx.test.espresso:espresso-core:3.2.0, androidx.test.espresso:espresso-idling-resource:3.2.0.
/home/bansal/Documents/Buyer/bharatcall-android/app/build/intermediates/tmp/manifest/androidTest/debug/manifestMerger12251506600435692045.xml Error:
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.
/home/bansal/Documents/Buyer/bharatcall-android/app/build/intermediates/tmp/manifest/androidTest/debug/manifestMerger12251506600435692045.xml Error:
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.
/home/bansal/Documents/Buyer/bharatcall-android/app/build/intermediates/tmp/manifest/androidTest/debug/manifestMerger12251506600435692045.xml Error:
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.

>Solution :

you might set up exported in all YOUR components, but does all your dependencies do the same? open your manifest and below it you have "merged manifest" tab – in there you will see your manifest entries + all needed by dependencies, all merged into one manifest file (e.g. some lib may provide own Activity or Service, which also needs to be included in manifest, these may not have exported tags)

your problematic dependency is androidx.test.espresso according to posted error – you are using 3.2, newest one is 3.4. update dependency version, lib creators should fix that on their side already. if not – afaik you can’t do anything besides manually importing sources, adding missing XML attributes and importing this modified lib instead of "official" one. or by "pinging" owner for do so in official repo… 🙂

Leave a Reply