{"id":1139,"date":"2021-08-24T20:12:00","date_gmt":"2021-08-24T12:12:00","guid":{"rendered":"https:\/\/www.ray650128.com\/wordpress\/?p=1139"},"modified":"2021-08-26T22:24:40","modified_gmt":"2021-08-26T14:24:40","slug":"android-12-manifest-merger-error","status":"publish","type":"post","link":"https:\/\/blog.ray650128.com\/?p=1139","title":{"rendered":"Android 12 Manifest merger error"},"content":{"rendered":"\n<p>\u4eca\u5929\u5728\u66f4\u65b0APP\u5c08\u6848\u7684API Level\u6642\uff0c\u767c\u751f\u4e86\u4e0b\u9762\u7684\u932f\u8aa4\u8a0a\u606f\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">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.<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>\u8d81\u8457\u4e0b\u73ed\u6642\u9084\u8a18\u61b6\u7336\u65b0\uff0c\u8d95\u7dca\u5c07\u67e5\u5230\u7684\u89e3\u6cd5\u8a18\u9304\u8d77\u4f86\u3002<\/p>\n\n\n\n<p>Google\u5728Android API Level 31\u4e2d\u52a0\u5165\u4e86exported\u53c3\u6578\u7684\u5f37\u5236\u8981\u6c42\u3002<br>\u4e5f\u5c31\u662f\u8aaa\u7576\u4f60\u7684Activity\u662fAPP\u7684\u5165\u53e3\u3001\u6216\u662fActivity\u6709\u8a3b\u518aintent filter\u6642\uff0c\u5fc5\u9808\u8981\u5728\u8a72Activity\u7684\u8a2d\u5b9a\u4e2d\u52a0\u5165exported\u53c3\u6578\uff0c\u5426\u5247\u7de8\u8b6f\u6703\u5931\u6557\u3002<br>\u81f3\u65bcexported\u53c3\u6578\u7684\u4f5c\u7528\u662f\u4ec0\u9ebc\uff0c\u5b98\u65b9\u6587\u4ef6\u6709\u63d0\u5230\uff1a<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><a rel=\"noreferrer noopener\" href=\"https:\/\/developer.android.com\/guide\/topics\/manifest\/activity-element#exported\" data-type=\"URL\" data-id=\"https:\/\/developer.android.com\/guide\/topics\/manifest\/activity-element#exported\" target=\"_blank\">\u5b98\u65b9\u6587\u4ef6\u9023\u7d50<\/a><\/p><cite>This element sets whether the activity can be launched by components of other applications \u2014 &#8220;<code>true<\/code>&#8221; if it can be, and &#8220;<code>false<\/code>&#8221; if not. If &#8220;<code>false<\/code>&#8220;, the activity can be launched only by components of the same application or applications with the same user ID. If you are using intent filters, you should not set this element &#8220;<code>false<\/code>&#8220;. If you do so, and an app tries to call the activity, system throws an <code><a href=\"https:\/\/developer.android.com\/reference\/android\/content\/ActivityNotFoundException\">ActivityNotFoundException<\/a><\/code>. Instead, you should prevent other apps from calling the activity by not setting intent filters for it.<br>If you do not have intent filters, the default value for this element is &#8220;<code>false<\/code>&#8220;. If you set the element &#8220;<code>true<\/code>&#8220;, the activity is accessible to any app that knows its exact class name, but does not resolve when the system tries to match an implicit intent.<br>This attribute is not the only way to limit an activity&#8217;s exposure to other applications. You can also use a permission to limit the external entities that can invoke the activity (see the <code><a href=\"https:\/\/developer.android.com\/guide\/topics\/manifest\/activity-element#prmsn\">permission<\/a><\/code> attribute).<\/cite><\/blockquote>\n\n\n\n<p>\u4e0a\u9762\u8b1b\u7684\u5be6\u969b\u4e0a\u662f\u8aaa\uff1aexported\u53c3\u6578\u5b9a\u7fa9\u4e86Activity\u662f\u5426\u53ef\u4ee5\u88ab\u5176\u4ed6APP\u555f\u52d5\u3002true\u8868\u793a\u70ba\u53ef\u4ee5\u3001false\u5247\u8868\u793a\u4e0d\u80fd\u3002<\/p>\n\n\n\n<p>\u5982\u679c\u6709\u4f7f\u7528\u5230intent filter\uff0c\u5fc5\u9808\u8981\u5c07\u6b64\u53c3\u6578\u8a2d\u5b9a\u70batrue\uff0c\u4e0d\u7136\u6703\u62cb\u51faActivityNotFoundException\u4f8b\u5916\u3002<\/p>\n\n\n\n<p>\u56e0\u6b64\u6211\u5011\u5fc5\u9808\u8981\u5c07exported\u53c3\u6578\u7d66\u88dc\u4e0a\uff0c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"xml\" class=\"language-xml line-numbers\">&lt;activity\n\tandroid:name=\".MainActivity\"\n\tandroid:exported=\"true\"\n\tandroid:theme=\"@style\/Theme.MyApplication.NoActionBar\"&gt;\n\t&lt;intent-filter&gt;\n\t\t&lt;action android:name=\"android.intent.action.MAIN\" \/&gt;\n\t\t&lt;category android:name=\"android.intent.category.LAUNCHER\" \/&gt;\n\t&lt;\/intent-filter&gt;\n&lt;\/activity&gt;<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>\u53c3\u8003\u4f86\u6e90\uff1a<br><a href=\"https:\/\/developer.android.com\/guide\/topics\/manifest\/activity-element#exported\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/developer.android.com\/guide\/topics\/manifest\/activity-element#exported<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/stackoverflow.com\/questions\/67654506\/manifest-merger-failed-targeting-android-12\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/stackoverflow.com\/questions\/67654506\/manifest-merger-failed-targeting-android-12<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4eca\u5929\u5728\u66f4\u65b0APP\u5c08\u6848\u7684API Level\u6642\uff0c\u767c\u751f\u4e86\u4e0b\u9762\u7684\u932f\u8aa4\u8a0a\u606f\uff1a \u8d81\u8457\u4e0b\u73ed\u6642\u9084\u8a18\u61b6\u7336\u65b0\uff0c\u8d95\u7dca\u5c07\u67e5\u5230\u7684\u89e3\u6cd5\u8a18\u9304 &hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[10,32],"class_list":["post-1139","post","type-post","status-publish","format-standard","hentry","category-2","tag-android-app","tag-32"],"_links":{"self":[{"href":"https:\/\/blog.ray650128.com\/index.php?rest_route=\/wp\/v2\/posts\/1139","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ray650128.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ray650128.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ray650128.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ray650128.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1139"}],"version-history":[{"count":6,"href":"https:\/\/blog.ray650128.com\/index.php?rest_route=\/wp\/v2\/posts\/1139\/revisions"}],"predecessor-version":[{"id":1147,"href":"https:\/\/blog.ray650128.com\/index.php?rest_route=\/wp\/v2\/posts\/1139\/revisions\/1147"}],"wp:attachment":[{"href":"https:\/\/blog.ray650128.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1139"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ray650128.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1139"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ray650128.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1139"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}