Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported

        有一篇同名博客:Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported_蜗牛君子的博客-CSDN博客介绍了该问题的原因,即targetSdkVersion>=31(Android 12)之后,AndroidManifest.xml中带有<intent-filter>,必须显示的声明android:exported。

        但是,我在AndroidManifest.xml添加之后,问题还是未得到解决。然后,我又搜到了StackOverflow的一个相关问题:Manifest merger failed targeting Android 12 - Stack Overflow

        同时,我又在Merged Manifest里看到了androidx.test.core.app.InstrumentationActivityInvoker$BootstrapActivity等合并过来的Manifest。如下图所示:

        这时,我大概猜到了原因,这些应该是junit单元自测产生的。然后,我搜索到了Test版本信息:https://developer.android.google.cn/jetpack/androidx/releases/test?hl=th

        如下图所示:

        最后,我更新了androidx.test.ext:junit:1.1.5和androidx.test.espresso:espresso-core:3.5.1。问题得到了解决。

        结论:除了需要保证自己AndroidManifest.xml中带有<intent-filter>的需要显性声明android:exported外,还要保证自己使用的其他AndroidManifest.xml也必须遵循该要求。

猜你喜欢

转载自blog.csdn.net/afunx/article/details/129973659
今日推荐