Majoren
Majoren

Reputation: 1043

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?

Upvotes: 1

Views: 1056

Answers (3)

Volodymyr Buberenko
Volodymyr Buberenko

Reputation: 648

As the accepted answer provides some ambiguous info and requires people to go through comments to understand solution I would write a proper answer.

The reason of the issue is missing exported property in one of declared components (activity, service or broadcast receiver) in AndroidManifest.xml file of the app. Since Android 12 every of listed components must declare this property for security reasons.

Here is a documentation about exported property for these components:

Upvotes: 1

Igbokwenu
Igbokwenu

Reputation: 51

Also note that running the "flutter clean" and then the "flutter pub get" command in the project folder might be needed to capture the changes whenever you modify an "essential" file like a .xml file.

Upvotes: 1

Nisa Efendioglu
Nisa Efendioglu

Reputation: 1321

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>

Upvotes: 3

Related Questions