flutter 由于“android:exported”属性设置问题,已拒绝上传的应用程序包

lbsnaicq  于 2022-11-17  发布在  Flutter
关注(0)|答案(1)|浏览(257)

我已经发布了一些变化,我的应用程序。但这一次Google Play控制台拒绝了应用程序,由于以下原因,有人能帮助我是否错过了这里的错误?
我用了,Flutter SDK Version 2.2.3
build.gradle文件如下所示:

defaultConfig {
        applicationId "com.testApp"
        minSdkVersion 21
        targetSdkVersion 31
        versionCode 1.0
        versionName 1.0
    }

您上传了一个APK或Android应用捆绑包,其中包含带有Intent过滤器的Activity、Activity别名、服务或广播接收器,但未设置“android:exported”属性。此文件无法安装在Android 12或更高版本上。请参阅:developer.android.com/about/versions/12/behavior-changes-12#exported

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.testApp">

    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

    <queries>
        <intent>
            <action android:name="android.intent.action.VIEW" />
            <data android:scheme="https" />
        </intent>
    </queries>

    <application
        android:name="io.flutter.app.FlutterApplication"
        android:icon="@mipmap/ic_launcher"
        android:label="Test App"
        android:allowBackup="false"
        android:fullBackupContent="@xml/my_backup_rules">
        <service
            android:name=".AndroidNotificationService"
            android:exported="true"
            android:enabled="true"
             />

        <receiver android:exported="true" android:name=".NotificationServiceAutoStart">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
            </intent-filter>
        </receiver>

        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:screenOrientation="portrait"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            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>

        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    </application>

</manifest>
rdrgkggo

rdrgkggo1#

我已经解决了这个问题。这里的问题是在receiver上。
我把android:name=".NotificationServiceAutoStart">改成了android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver"
完整代码如下,

<receiver
        android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver"
        android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED" />
        </intent-filter>
    </receiver>

相关问题