Skip to content

Flutter/Android: You uploaded an APK which has activity […] but without the ‘android:exported’ property. exported=”true” not working

After uploading my app to the google play store for internal testing, I get the following error message:

You uploaded an APK or Android App Bundle which has an activity, activity alias, service or broadcast receiver with intent filter, but without the 'android:exported' property set. This file can't be installed on Android 12 or higher. See: developer.android.com/about/versions/12/behavior-changes-12#exported

I’ve tried setting the android:exported="true" in my manifest like so:

<receiver 
    android:name="com.ryanheise.audioservice.MediaButtonReceiver"
    android:exported="true"
>            
    <intent-filter>
        <action android:name="android.intent.action.MEDIA_BUTTON" />
    </intent-filter>
</receiver>

But I’m still getting the same error. In my build.gradle files I have these configs:

compileSdkVersion 31
minSdkVersion 21
targetSdkVersion 31

buildscript {
    ext.kotlin_version = '1.6.10'
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.5'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.5.1'
    }
}

Feels like I have tried everything. Could this be an SDK version issue, or what could I be missing here?

Answer

What is exported receiver?

android:exported. Whether the broadcast receiver can receive messages from non-system sources outside its application — ” true ” if it can, and ” false ” if not.

You need to add the exported attribute for each of the activity pages in your AndroidManifest.xml file.

Example :

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

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

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:usesCleartextTraffic="true"
        android:supportsRtl="true"
        android:theme="@style/Theme.AppCompat">
        <activity android:name="com.nisaefendioglu.weather.view.MainActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>