您上传了一个 APK 或 Android 应用程序包,其中包含带有意图过滤器的活动、活动别名、服务或广播接收器,但没有“an”

Sye*_*eed 109 android android-manifest google-play google-play-console android-12

问题:您上传的 APK 或 Android App Bundle 具有带有意图过滤器的活动、活动别名、服务或广播接收器,但未设置“android:exported”属性。此文件无法安装在 Android 12 或更高版本上。请参阅developer.android.com/about/versions/12/behavior-changes-12#exported

我的 AndroidManifest.xml 文件

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.c4life.guardianangel">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>


<application
   tools:replace="android:label"
   android:label="GA"
   android:exported="true"
   android:icon="@mipmap/ic_launcher">
   <meta-data android:name="com.google.android.geo.API_KEY"
       android:value="[insert API key here]"/>
    <activity
        android:name=".MainActivity"
        android:exported="true"
        android:launchMode="singleTop"
        android:theme="@style/LaunchTheme"
        android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
        android:hardwareAccelerated="true"
        android:windowSoftInputMode="adjustResize">
        <meta-data
          android:name="io.flutter.embedding.android.NormalTheme"
          android:resource="@style/NormalTheme"
          />
        <meta-data
          android:name="io.flutter.embedding.android.SplashScreenDrawable"
          android:resource="@drawable/launch_background"
          />
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>
   <service android:name="changjoopark.com.flutter_foreground_plugin.FlutterForegroundService" android:exported="false"/>
    <meta-data
        android:name="flutterEmbedding"
        android:value="2" />


</application>

<uses-sdk
    android:targetSdkVersion="30"
    tools:overrideLibrary="changjoopark.com.flutter_foreground_plugin" />
Run Code Online (Sandbox Code Playgroud)

MAN*_*ISH 109

根据谷歌新政策,如果您的应用程序面向 Android 12 或更高版本,并包含使用 Intent 过滤器的活动、服务或广播接收器,则必须为这些应用程序组件显式声明 android :exported: true属性。

对于 FLUTTER 和 REACT NATIVE 项目:将此行添加到项目的AndroidManifest.xml文件中:

android:exported="true"
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

现在只需重建您的项目即可。在大多数情况下,这就像一个魅力。

如果上述解决方案不起作用或者您的项目位于 Android Native 中,请按照以下说明进行操作:在主清单文件中,检查可以使用意图过滤器且不带android:exported标记的所有活动、服务和接收器。添加android:exported="true"android:exported="false"为这些标签

您可能会问我何时需要将android:exported="true"android:exported="false"添加到使用意图过滤器的活动、服务或广播接收器。如果应用程序组件包含 LAUNCHER 类别,请将 android:exported 设置为true,否则将 android:exported 设置为false

如果添加 android: 在主清单文件中导出不适合您,请按照以下步骤操作:

  • 打开AndroidManifest.xml文件并在底部选择Merged Manifest。像这样 :在此输入图像描述

  • 如果您无法预览合并清单,则在build.gradle文件中设置compileSdkVersion 30targetSdkVersion 30并同步您的项目,现在尝试再次打开合并清单,我希望这次您能够正确预览合并清单。但如果没有预览,请不要担心,您仍然可以导航到项目中使用的不同第三方库中的各个清单文件。

  • 注意:还要检查各个第三方库清单文件如果有任何活动、服务或接收器使用那么您必须使用android:exported属性覆盖主清单文件中的相同活动、服务或接收器。

例如,在我的例子中,我在主清单文件中为每个活动、服务或接收器定义了android:exported,但在我的项目中,我使用Razorpay依赖项,因此在Razorpay的清单中我发现有一个活动和正在使用的 接收器属性没有android: 导出,所以我在我的主清单文件中声明了它们。如下所示 :

 <activity
        android:name="com.razorpay.CheckoutActivity"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
        android:theme="@style/CheckoutTheme"
        android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <data
                android:host="rzp.io"
                android:scheme="io.rzp" />
        </intent-filter>
    </activity>

    <receiver android:name="com.razorpay.RzpTokenReceiver"
        android:exported="true"
        android:permission="android.permission.INTERNET">
        <intent-filter>
            <action android:name="rzp.device_token.share" />
        </intent-filter>
    </receiver>
Run Code Online (Sandbox Code Playgroud)

注意:在您的情况下,您可能需要检查更多文件并检查活动和服务,并在主清单文件中提及它们。

  • 完成所有这些操作后,您可以在build.gradle文件中更改回targetSdkVersion 31compileSdkVersion 31

  • 伟大的!!查看 obj/Debug/Android 中的输出清单文件,我找到带有“intent-filter”的服务,但没有设置“android:exported” (2认同)

小智 44

就我而言,我只需将此行添加到我的清单中:

android:exported="true"
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

  • 这对我的 Flutter 项目有用 (3认同)

mah*_*mnj 20

仅添加exported:true到 Android 清单活动并不能解决我的问题。可能是因为您的应用程序依赖的库没有exported:true只要您的应用程序依赖的所有库都更新了,您将来就不应该遇到此错误exported:true

你必须

  • 在Android Studio中打开项目
  • 打开 Androidmanifest.xml
  • 在底部选择合并清单

在此输入图像描述

  • 现在,请确保您将导出添加为true,并修复该行(蓝色)上指定的那些警告,点击蓝色文本不会将您带到上述步骤中的这些标签“服务”、“活动”、“接收器”之一,然后查找其对应的库存在合并错误

例如,这里的合并错误显示了问题flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService

在此输入图像描述

因此,请转到错误上方以蓝色列出的特定库的清单,您可以在其中将导出添加为 true。(这也将解决合并错误)

在此输入图像描述

services在标签中添加exported为true

在此输入图像描述

视频演示:https://www.youtube.com/watch?v =hy0J8MNnE6g


小智 14

我终于解决了这个问题

1:安装模拟器与android v 12

2:运行您的应用程序,编译器会告诉您什么服务/接收器...等引起了问题

现在您必须将其添加到您的清单中并将android:exported="true"添加到其中

就我而言,问题与本地通知包有关,我收到了修复此接收器 com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver的消息, 因此我将其添加到主要活动之外的清单中

 <receiver android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver"
 android:exported="true">
       <intent-filter>
           <action android:name="android.intent.action.BOOT_COMPLETED"/>
           <action android:name="android.intent.action.MY_PACKAGE_REPLACED"/>
       </intent-filter>
   </receiver>
Run Code Online (Sandbox Code Playgroud)

它按预期工作


Mah*_*ndy 5

“导出”属性描述是否可以允许其他人使用它。

因此,如果您在某个 Activity 上设置了“exported=false”,则其他应用程序甚至 Android 系统本身都无法启动它。只有您可以从您自己的应用程序内部做到这一点。

因此,在标记为 LAUNCHER Activity 的 Activity 上设置“exported=false”基本上会告诉系统它永远无法启动您的应用程序。


小智 5

如果使用 targetSdkVersion=31

    package="com.name.app"><!-- Channnge your package -->
    <queries>
        <intent>
            <action android:name="android.intent.action.VIEW" />
            <data android:scheme="https" />
        </intent>
        <intent>
            <action android:name="android.intent.action.DIAL" />
            <data android:scheme="tel" />
        </intent>
        <intent>
            <action android:name="android.intent.action.SEND" />
            <data android:mimeType="*/*" />
        </intent>
    </queries>
   <application
        android:label="Tut Elimi"
        android:icon="@mipmap/ic_launcher">
       <service android:name="com.example.app.backgroundService"
           android:exported="true">
           <intent-filter>
               <action android:name="com.example.app.START_BACKGROUND" />
           </intent-filter>
       </service>
       <meta-data
           android:name="com.google.android.gms.ads.APPLICATION_ID"
           android:value=""/>
        <activity
            android:name=".MainActivity"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize"
            android:exported="true">

            <!-- Specifies an Android theme to apply to this Activity as soon as
                 the Android process has started. This theme is visible to the user
                 while the Flutter UI initializes. After that, this theme continues
                 to determine the Window background behind the Flutter UI. -->
            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />
            <meta-data
                android:name="io.flutter.embedding.android.SplashScreenDrawable"
                android:resource="@drawable/splash"
                />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
            <intent-filter>
                <action android:name="FLUTTER_NOTIFICATION_CLICK" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
            <!-- Displays an Android View that continues showing the launch screen
                 Drawable until Flutter paints its first frame, then this splash
                 screen fades out. A splash screen is useful to avoid any visual
                 gap between the end of Android's launch screen and the painting of
                 Flutter's first frame. -->
        </activity>
        <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
       <receiver android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver"
           android:exported="true">
           <intent-filter>
               <action android:name="android.intent.action.BOOT_COMPLETED"/>
               <action android:name="android.intent.action.MY_PACKAGE_REPLACED"/>
           </intent-filter>
       </receiver>
       <service
           android:name="com.name.app.BackgroundService"
           android:enabled="true"
           android:exported="true" />
       <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    </application>  

</manifest>  ````   
Run Code Online (Sandbox Code Playgroud)