What went wrong:
Execution failed for task ':app:processDebugMainManifest'.
Manifest merger failed : android:exported needs to be explicitly specified for
element <activity#com.example.flutter_application_1.MainActivity>. 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.
I'm creating an app with flutter, after I linked it to firebase, this problem appeared when I tried to run the app on the emulator
Related
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.
I also added the android:exported="false" in the AndroidManifest.xml file
I have already added the android:exported="false" in the AndroidManifest.xml file in
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:installDebug'.
java.util.concurrent.ExecutionException: com.android.builder.testing.api.DeviceException: com.android.ddmlib.InstallException: INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: Failed parse during installPackageLI: /data/app/vmdl377948902.tmp/base.apk (at Binary XML file line #145): com.onesignal.GcmBroadcastReceiver: Targeting S+ (version 31 and above) requires that an explicit value for android:exported be defined when intent filters are present
The specific module (in this case must be onesignal) must be outdated and needs to be updated using: yarn add react-native-onesignal#latestVersion
This will update the library version that you have , that might be having outdated androidManifest.XML. This can be verified in android studio, by opening up your androidManifest.XML and clicking on merged manifests to see information about all androidManifests in your project (including those of libraries)
After updating to Android Gradle Plugin 7.3.1 Android Studio says that package is deprecated in AndroidManifest.xml and I need to use namespace param in build.gradle.kts. I removed the package attribute in all my android manifests (I'm using additional manifest files for debug and release builds) and have done this:
build.gradle.kts
android {
...
applicationId = "org.sample.appid"
...
namespace = "org.sample.packageid"
...
}
After this I can not build the project because of the error:
D:\Desktop\Sample\app\src\debug\AndroidManifest.xml:4:5
Execution failed for task ':app:processDebugMainManifest'.
> Manifest merger failed : Attribute manifest#package value=(org.sample.packageid) from AndroidManifest.xml:4:5-35
is also present at AndroidManifest.xml:2:1-102:12 value=(org.sample.appid).
Attributes of <manifest> elements are not merged.
Debug manifest can not be merged with the main manifest, but why package name is mixed with applicationId while merging? Is there anything that must be additionally configured? Or there's a bug with AGP 7.3.1?
The error message even precisely tells where the problem lies.
... also remove package from src\debug\AndroidManifest.xml.
The problem was really complex - I missed removing the package attribute in one AndroidManifest.xml. Also, Android Studio must be restarted after that with a full cache clear (without this it will not work). After that everything works as expected.
I've followed the jetpack compose navigation codelab. Everything was going well until it came to testing the NavHost in step 7.
When trying to run the tests, I get the following error and stack trace :
FAILURE: Build failed with an exception.
* What went wrong:
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:188)
at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:263)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:186)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:174)
at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:109)
.....
Caused by: java.lang.RuntimeException: Manifest merger failed with multiple errors, see logs
at com.android.build.gradle.tasks.ProcessTestManifest.handleMergingResult(ProcessTestManifest.kt:331)
at com.android.build.gradle.tasks.ProcessTestManifest.mergeManifestsForTestVariant(ProcessTestManifest.kt:301)
at com.android.build.gradle.tasks.ProcessTestManifest.doFullTaskAction(ProcessTestManifest.kt:111)
.....
There is a problem with the merged Manifest, but within the androidTest directory I have no Manifest, so as far as i can see, I have no control over what's in the generated one.
I can see the Merged Manifest from the main directory and there are no errors present in there. I can see the generated manifest in the build folder and it does display a load of errors.
Is there some technique I could use to attempt to resolve this?
EDIT:
Further investigation shows the problem as
android-compose-codelabs/NavigationCodelab/app/build/intermediates/tmp/manifest/androidTest/debug/tempFile1ProcessTestManifest6269584048200983460.xml Error:
android:exported needs to be explicitly specified for <activity>. 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.
android:exported has been declared in the main/AndroidManifest.xml as expected, and it is also present in each component in the generated merged manifest for androidTest.
I found a solution here. Adding the following dependency should solve the problem:
androidTestImplementation "androidx.test.ext:junit:1.1.3"
From the comment:
Essentially, Android 12 introduced the requirement to specify the android:exported value on all activities when you have an intent-filter defined. This is causing issues right now because some libraries haven't updated to handle this change properly.
Problems: There are bugs in the new version and the old version. Problems occur when updating SDK versions.
"Manifest merger failed : 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."
There is a solution, but it gives an error as in the picture.
<activity android:name=".MainActivity"
android:exported="true">
I think the solution should be like this, but it gives another error.
You are getting this error because the API level (or the android version) of the device that you are trying to run the app is less than the minimum API version you specified in the gradle file.
You can find more information about API levels here.