【发布时间】:2021-12-11 06:54:45
【问题描述】:
我关注了jetpack compose navigation codelab。在第 7 步测试 NavHost 之前,一切都很顺利。 尝试运行测试时,我收到以下错误和堆栈跟踪:
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)
.....
合并的 Manifest 存在问题,但在 androidTest 目录中我没有 Manifest,所以据我所知,我无法控制生成的 Manifest 中的内容。
我可以从main 目录中看到合并清单,并且其中没有错误。我可以在 build 文件夹中看到生成的清单,它确实显示了很多错误。
我可以使用一些技术来尝试解决这个问题吗?
编辑: 进一步调查显示问题为
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 已按预期在main/AndroidManifest.xml 中声明,并且它也存在于为androidTest 生成的合并清单中的每个组件中。
【问题讨论】:
标签: android android-jetpack-compose android-jetpack-navigation android-instrumentation jetpack-compose-navigation