上传了一个 APK,其中包含带有 Intentfilter 的活动、活动别名、服务或广播接收器,但没有设置“android:导出”属性

vai*_*rma 46 store playback flutter

当我将应用程序包上传到 Play 控制台时遇到问题:

您上传了一个 APK 或 Android 应用程序包,其中包含带有意图过滤器的活动、活动别名、服务或广播接收器,但未设置“android:exported”属性。此文件无法安装在 Android 12 或更高版本上。

但我的清单文件包含该属性。

清单文件

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="**********">
    <!-- io.flutter.app.FlutterApplication is an android.app.Application that
         calls FlutterMain.startInitialization(this); in its onCreate method.
         In most cases you can leave this as-is, but you if you want to provide
         additional functionality it is fine to subclass or reimplement
         FlutterApplication and put your custom class here. -->
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-feature android:name="android.hardware.camera" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <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" />
    <uses-permission android:name="android.permission.WAKE_LOCK"/>
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.ACTIVITY_RECOGNITION" />
    <uses-permission android:name="com.google.android.gms.permission.ACTIVITY_RECOGNITION" />

    <application
        android:name="io.flutter.app.FlutterApplication"
        android:label="*****"
        android:requestLegacyExternalStorage="true"
        android:usesCleartextTraffic="true"
        android:icon="@mipmap/ic_launcher">

        <meta-data
          android:name="com.google.firebase.messaging.default_notification_icon"
          android:resource="@drawable/ic_stat_artboard_1" />

        <meta-data android:name="com.google.android.geo.API_KEY"
            android:value="Z*********"/>

        <provider
            android:name="vn.hunghd.flutterdownloader.DownloadedFileProvider"
            android:authorities="im.mingguang.mingguang_app.flutter_downloader.provider"
            android:grantUriPermissions="true"
            android:requestLegacyExternalStorage="true">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/provider_paths"/>
        </provider>

        <provider
            android:name="androidx.core.content.FileProvider"
            android:authorities="${applicationId}.provider"
            android:grantUriPermissions="true">

            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/provider_paths"/>
        </provider>

        <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:exported="true"
            android:windowSoftInputMode="adjustResize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.DEFAULT"/>
                <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>
        </activity>
        <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    </application>
</manifest>
Run Code Online (Sandbox Code Playgroud)

Play 管理中心错误

在此输入图像描述

小智 21

我通过写解决了

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

activity下面的android:name=".MainActivity".

显示图像

  • 这对我不起作用 (3认同)

小智 13

大约在 2022 年 1 月 11 日,Play 商店在上传 APK 时引入了 lint 检查,以验证exported清单中的属性设置是否正确。

像DexGuard这样混淆属性名称的工具将导致 Play Store linter 失败,因为它将无法检查exported属性。

要解决此问题,请配置混淆工具以将属性名称保留在清单中。

这是我们用于 DexGuard 的规则:

-keepresourcexmlattributenames manifest/**
Run Code Online (Sandbox Code Playgroud)

  • 我确认使用 Dexguard 时解决方法是有效的 (3认同)

its*_*ain 10

我将android:exported="true" 添加到我的主要活动中,但这并没有解决我的问题。

但是,我怀疑这是某些软件包最近才实施的更改。我检查了我的 pub 是否已过时,并且有一些旧版本的关键软件包(就我而言,我是 Firebase 存储上落后的主要版本)。一旦我更新到文件pubspec.yaml中的最新可能版本,编译后的文件就会被上传到 Google Play。


MAN*_*ISH 6

清单文件中,检查使用不带android:exported标记的意图过滤器的所有活动服务接收器

在主清单文件中,您可以简单地将android:exported属性添加到活动标记中,因此添加 android:exported="" 并在这些引号内设置一个布尔值。

您可能会问:我什么时候需要将android:exported="true"android:exported="false"添加到使用意图过滤器的活动、服务或广播接收器?如果应用程序组件包含 LAUNCHER 类别,请将android:exported设置为true。在大多数其他情况下,将android:exported设置为 false。

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

更多解释,可以参考对同一问题的回答。


归档时间:

查看次数:

33848 次

最近记录:

3 年,5 月 前