Uploaded an APK which has an activity, activity alias, service or broadcast receiver with intentfilter, but without 'android : exported' property set
Asked Answered
A

16

46

I'm having an issue when I'm uploading an app bundle to the play console that:

You uploaded an APK or Android App Bundle which has an activity, activity alias, service or broadcast receiver with intent filter, but without 'android:exported' property set. This file can't be installed on Android 12 or higher.

But my manifest file includes the property.

Manifest file

<?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>

Play Console Error

Enter image description here

Apomixis answered 12/1, 2022 at 15:52 Comment(0)
C
10

I added android:exported="true" to my main activity, but that didn't fix the issue for me.

However, I suspected this is a change that some packages have only recently implemented. I checked my pub outdated, and had a few older versions of key packages (in my case I was a major version behind on Firebase storage). Once I had updated to the latest possible versions in file pubspec.yaml the compiled file was accepted on upload to the Google Play.

Clothilde answered 14/1, 2022 at 6:39 Comment(1)
Yes, you're right, doing this fixes the error because some packages use the old version of flutter and after update the packages, solve the error message when upload app to store.A
J
21

I solved it by writing

android:exported="true"

in activity below the android:name=".MainActivity".

Image shown

Justinajustine answered 12/1, 2022 at 23:56 Comment(6)
this worked for me tho I have no idea if setting to 'false' or 'true' would be the right choice. I do have some intent filter in my app so I set it to 'true'Shipman
it doesn't work for meApomixis
what to do then?Apomixis
Please review Why not upload images of code/errors when asking a question? (e.g., "Images should only be used to illustrate problems that can't be made clear in any other way, such as to provide screenshots of a user interface.") and do the right thing (it covers answers as well). Thanks in advance.Faultfinder
true : broadcast receiver enabled to events by the same and others applications false‍ : broadcast receiver can receive events only by the same applicationMarris
NOTE: You need to add "android:exported" to all activities that has "intent-filter". Also check the merged manifest using Android Studio to ensure not a package you are using is outdated.Consecution
M
13

On about the 11th of January 2022, the Play Store introduced a lint check when uploading APKs to verify exported attributes are set correctly in the manifest.

Tools like DexGuard that obfuscate attribute names will cause the Play Store linter to fail, since it will be unable to check for exported attributes.

To fix this, configure obfuscation tools to keep attribute names in the manifest.

Here is the rule we used for DexGuard:

-keepresourcexmlattributenames manifest/**
Macon answered 13/1, 2022 at 21:34 Comment(2)
I confirm that workaround is effective when using DexguardGalen
Does it really end in /**?Faultfinder
C
10

I added android:exported="true" to my main activity, but that didn't fix the issue for me.

However, I suspected this is a change that some packages have only recently implemented. I checked my pub outdated, and had a few older versions of key packages (in my case I was a major version behind on Firebase storage). Once I had updated to the latest possible versions in file pubspec.yaml the compiled file was accepted on upload to the Google Play.

Clothilde answered 14/1, 2022 at 6:39 Comment(1)
Yes, you're right, doing this fixes the error because some packages use the old version of flutter and after update the packages, solve the error message when upload app to store.A
G
6

In your manifest file, check all the activities, services, and receivers that uses intent-filter without the android:exported tag.

In your main manifest file, you can simply add the android:exported property to the activity tag, so add android:exported="" and set a Boolean value inside these quotation marks.

You might ask: When do I need to add android:exported="true" or android:exported="false" to the activities, services, or broadcast receivers that use intent filters? If the app component includes the LAUNCHER category, set android:exported to true. In most other cases, set android:exported to false.

Note: also check individual third-party library manifest files if there is any activity, service or receiver using them. You have to override the same activity, service or receiver in your main manifest file with the android:exported property.

For more explanation, you can refer to my answer on same problem.

Giro answered 13/1, 2022 at 13:52 Comment(0)
S
4

If your app targets Android 12 or higher and contains activities, services, or broadcast receivers that use intent filters, you must explicitly declare the android:exported attribute for these app components.

If the app component includes the LAUNCHER category, set android:exported to true. In most other cases, set android:exported to false.

The following code snippet shows an example of a service that contains an intent filter whose android:exported attribute is set to false:

<service android:name="com.example.app.backgroundService"
         android:exported="false">

    <intent-filter>
        <action android:name="com.example.app.START_BACKGROUND" />
    </intent-filter>
</service>

<receiver android:name="com.example.app.serives.SilentPushReceiver"
          android:exported="false">

    <intent-filter>
        <!-- Receive silent push notifications. -->
        <action
            android:name="uz.usoft.kidya.action.ymp.SILENT_PUSH_RECEIVE"/>
    </intent-filter>
</receiver>

<activity android:name="com.example.app.SplashScreenActivity"
          android:exported="true">

    <intent-filter>
        <action android:name="android.intent.action.MAIN" />

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

<activity
    android:name="com.example.app.MainActivity"
    android:exported="false"/>

About information: Safer component exporting

Sidneysidoma answered 13/1, 2022 at 6:33 Comment(0)
S
4

its_broke_again's answer works perfectly for me. I'm describing the steps to make things a little easier.

  1. Enter the following commands in the terminal

    flutter pub upgrade --major-versions
    flutter clean
    flutter build appbundle
    
  2. Add android:exported="true" in file AndroidManifest.xml

    <activity
        android:name=".MainActivity"
        android:exported="true"
        <!-- ... -->
    </activity>
    
Samale answered 18/1, 2022 at 12:58 Comment(0)
P
3

I downgraded to targetSdkVersion 30 and compileSdkVersion 30 in file build.gradle.

It should work fine.

In my case geocoding was the package which caused the problem So it wouldn't build with the 30 SdkVersion, so I had to deleted the exception which refers to Android S "API 31".

Pinafore answered 15/1, 2022 at 12:3 Comment(2)
Yes, maybe help only if you don't need new features of API 31, is recommended to update the packages (on pub.dev) to solve the error message when upload app to store.A
I fixed the problem in the right way in this post #70695872Pinafore
F
3

For Flutter:

If you changed AndroidManifest and you still face the same error, the problem is caused by a package. To identify the package, search for '<intent-filter' in the "build" folder, and then find if '<intent-filter' has a parent without android:exported="true/false".

Then you should upgrade the package.

If you are using the latest version, then you need to contact the package developer, or clone it and use your GitHub version.

Enter image description here

Fundy answered 22/1, 2022 at 9:11 Comment(0)
P
1

For me, adding android:exported="true" to MainActivity was not enough.

But I also had to remove the Huawei agcp and hms for push notification to let it work.

It seems that it uses an activity, activity alias, service or broadcast without android:exported.

Psychoanalysis answered 13/1, 2022 at 7:12 Comment(1)
What are "agcp" and "hms"? Can you add some context to your answer? (But ********************************************************** without ********************************************* "Edit:", "Update:", or similar - the answer should appear as if it was written today)Faultfinder
C
1

An Android manifest file highlights the error. Generally, wherever we have used intent filter, it requires us to set the attribute android:exported="true".

The default activity should be set as "true". The rest can be set either to "true" or "false", depending on whether we want other apps to fire our activity/service.

Cleisthenes answered 20/1, 2022 at 5:22 Comment(0)
W
0

If your app targets Android 12 or higher and contains activities, services, or broadcast receivers that use intent filters, you must explicitly declare the android:exported attribute for these app components.

Warning: If an activity, service, or broadcast receiver uses intent filters and doesn't have an explicitly-declared value for android:exported, your app can't be installed on a device that runs Android 12 or higher.

If the app component includes the LAUNCHER category, set android:exported to true. In most other cases, set android:exported to false.

The following code snippet shows an example of a service that contains an intent filter whose android:exported attribute is set to false:

<service android:name="com.example.app.backgroundService"
         android:exported="false">
    <intent-filter>
        <action android:name="com.example.app.START_BACKGROUND" />
    </intent-filter>
</service>
Wayfarer answered 15/1, 2022 at 10:25 Comment(0)
W
0

I had the same error and for two days I was trying to fix it. Firstly, android:exported="true" did not work for me, because I added to only one activity.

  1. I updated the Unity version (it did not work at that time, and maybe had an effect)
  2. I added android:exported="true" in every activity field, and then voilà, it worked.

My Unity game now looks like:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="com.unity3d.player" android:installLocation="preferExternal" tools:ignore="MissingLeanbackSupport">
  <uses-permission android:name="android.permission.INTERNET" />
  <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
  <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
  <uses-permission android:name="com.google.android.finsky.permission.BIND_GET_INSTALL_REFERRER_SERVICE" />
  <uses-feature android:glEsVersion="0x00020000" />
  <application android:name="androidx.multidex.MultiDexApplication" android:fullBackupContent="false" android:allowBackup="false" android:theme="@android:style/Theme.NoTitleBar" tools:ignore="GoogleAppIndexingWarning,MissingTvBanner" tools:replace="fullBackupContent,allowBackup">
    <!-- UNITY -->
    <activity android:name="com.unity3d.player.UnityPlayerActivity" android:label="@string/app_name" android:screenOrientation="fullSensor" android:launchMode="singleTask" android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale|layoutDirection|density" android:resizeableActivity="false" android:hardwareAccelerated="false" android:exported="true">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
        <category android:name="android.intent.category.LEANBACK_LAUNCHER" />
      </intent-filter>
      <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
      <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="false" />
      <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
      <meta-data android:name="android.notch_support" android:value="true" />
    </activity>
    <!-- FULLSCREEN FIX -->
    <meta-data android:name="android.max_aspect" android:value="2.16" />
    <!-- 3rdParty MANIFEST -->
    <activity android:name="com.facebook.unity.FBUnityLoginActivity" android:exported="true" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
    <activity android:name="com.facebook.unity.FBUnityDialogsActivity" android:exported="true" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
    <activity android:name="com.facebook.unity.FBUnityGamingServicesFriendFinderActivity" android:exported="true" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
    <activity android:name="com.facebook.unity.FBUnityAppLinkActivity" android:exported="true" />
    <activity android:name="com.facebook.unity.FBUnityDeepLinkingActivity" android:exported="true" />
    <activity android:name="com.facebook.unity.FBUnityGameRequestActivity" android:exported="true"/>
    <activity android:name="com.facebook.unity.FBUnityCreateGameGroupActivity" android:exported="true"/>
    <activity android:name="com.facebook.unity.FBUnityJoinGameGroupActivity" android:exported="true"/>
    <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="fb901505887229125" />
    <meta-data android:name="com.facebook.sdk.AutoLogAppEventsEnabled" android:value="true" />
    <meta-data android:name="com.facebook.sdk.AdvertiserIDCollectionEnabled" android:value="true" />
    <provider android:name="com.facebook.FacebookContentProvider" android:authorities="com.facebook.app.FacebookContentProvider901505887229125" android:exported="true" />
    <meta-data android:name="unity.splash-mode" android:value="0" />
    <meta-data android:name="unity.splash-enable" android:value="True" />
    <meta-data android:name="unity.allow-resizable-window" android:value="False" />
    <meta-data android:name="notch.config" android:value="portrait|landscape" />
    <meta-data android:name="unity.build-id" android:value="31d4e179-c52c-49d7-a4f5-da548e453521" />
    <receiver android:name="com.unity.androidnotifications.UnityNotificationManager" android:exported="true" />
    <receiver android:name="com.unity.androidnotifications.UnityNotificationRestartOnBootReceiver" android:exported="true" android:enabled="false">
      <intent-filter>
        <action android:name="android.intent.action.BOOT_COMPLETED" />
      </intent-filter>
    </receiver>
  </application>
  <uses-feature android:name="android.hardware.vulkan.version" android:required="false" />
  <uses-feature android:name="android.hardware.touchscreen" android:required="false" />
  <uses-feature android:name="android.hardware.touchscreen.multitouch" android:required="false" />
  <uses-feature android:name="android.hardware.touchscreen.multitouch.distinct" android:required="false" />
</manifest>

You can see android:exported="true" added in every activity and receiver.

Wife answered 16/1, 2022 at 7:50 Comment(0)
S
0

In my Flutter app, I just had to change 1 line in <activity> in file android/app/src/main/AndroidMainfest.xml.

<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">  <!-- I added this line -->

       <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>

Also, I am using compileSdkversion 31 and targetSdkVersion 31.

Scheme answered 17/1, 2022 at 12:43 Comment(0)
P
0

Reading the document Safer component exporting, it looks like if your app targets Android 12 or higher and contains activities, services, or broadcast receivers that use intent filters, you must explicitly declare the android:exported property for these app components.

If your app is small, you might just need to add the android:exported property in the AndroidManifest.xml for every node using intent-filter.


But if you're using many external dependencies, modifying only the main manifest file might not be enough.

You might need to do it for every third-party library that you have in your project that contains an intent-filter node without the android:exported property.

You can find the list of all the activity, activity alias, service or broadcast into the merged manifest.

If you cannot find it using Android Studio:

  1. Downgrade targetSdkVersion: 30 and compileSdkVersion: 30 in the build.gradle to be able to build.
  2. Build the project on an android device
  3. Then you can check the merged manifest into /project_name/build/app/intermediates/merged_manifests/debug/out/AndroidManifest.xml.

Now you can check every individual third-party library where the android:exported is missing. And declare them explicitly in the main manifest file.

Then you can change back to targetSdkVersion: 31 and compileSdkVersion: 31 and check if it is working.

Personalty answered 20/1, 2022 at 3:18 Comment(0)
W
0

After unit testing, we found the problem was from the package epub_viewer: ^0.2.5. The AndroidManifest.xml file of this package was empty:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.jideguru.epub_viewer">
</manifest>

And also doesn't have any activity or service, but this solution works for me, by adding these lines of code to my AndroidManifest.xml file:

<activity
    android:name="com.folioreader.ui.activity.SearchActivity"
    android:exported="true"
    tools:node="merge" />

Google Play accepted my AppBundle.

Witty answered 11/8, 2022 at 5:35 Comment(0)
A
-1

You need to change all the used libraries in file pubspec.yaml to an updated version whether they are using the 'exported' thingy in the manifest file.

Antisyphilitic answered 17/1, 2022 at 9:25 Comment(1)
What is "exported"? An attribute? Something else?Faultfinder

© 2022 - 2024 — McMap. All rights reserved.