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.

Vuyiswa Maseko 351 Reputation points
2022-04-22T15:23:01.593+00:00

Good Day

i have a manifest that looks like this

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="138" android:versionName="1.138" package="com.mypackage.app" android:installLocation="preferExternal">
 <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="31" />
 <!-- Permissions -->
 <uses-permission android:name="android.permission.READ_PHONE_STATE" />
 <uses-permission android:name="android.Manifest.permission.READ_PHONE_STATE" />
 <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
 <uses-permission android:name="android.permission.INTERNET" />
 <uses-permission android:name="android.permission.WAKE_LOCK" />
 <uses-permission android:name="android.permission.VIBRATE" />
 <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
 <uses-permission android:name="android.permission.INSTANT_APP_FOREGROUND_SERVICE" />
 <!-- SignalOne Push Notification -->
 <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
 <uses-permission android:name="android.permission.CAMERA" />
 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
 <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
 <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
 <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
 <permission android:name="${applicationId}.permission.C2D_MESSAGE" android:protectionLevel="signature" />
 <uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" />
 <application android:label="Trova" android:icon="@drawable/logo_180" android:hardwareAccelerated="true" android:networkSecurityConfig="@xml/network_security_config" android:largeHeap="true">
 <!--Foreground Service-->
 <service android:name="com.vimalsoft.trova.startServiceAndroid" android:enabled="true" android:exported="false" />
 <provider android:name="androidx.core.content.FileProvider" android:authorities="${applicationId}.fileprovider" android:exported="false" android:grantUriPermissions="true">
 <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths"></meta-data>
 </provider>
 <!-- Start the Service if applicable on boot -->
 <receiver android:enabled="true" android:exported="false" android:name="com.mypackage.app.BootReceiver">
 <intent-filter>
 <category android:name="android.intent.category.DEFAULT" />
 <action android:name="android.intent.action.BOOT_COMPLETED" />
 <action android:name="android.intent.action.QUICKBOOT_POWERON" />
 <!--For HTC devices-->
 <action android:name="com.htc.intent.action.QUICKBOOT_POWERON" />
 </intent-filter>
 </receiver>
<!--Firebase Push notification-->
    <receiver android:name="com.google.firebase.iid.FirebaseInstanceIdInternalReceiver" android:exported="true" />
    <receiver android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver" android:exported="true" android:permission="com.google.android.c2dm.permission.SEND">
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
            <category android:name="${applicationId}" />
        </intent-filter>
    </receiver>
 </application>
 <uses-feature android:name="android.hardware.telephony" android:required="false" />
</manifest>

When i try to upload it in Playstore i get this error

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. See: developer.android.com/about/versions/12/behavior-changes-12#exported

Thanks

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,292 questions
{count} votes

Accepted answer
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 35,121 Reputation points Microsoft Vendor
    2022-05-04T01:50:54.957+00:00

    Hello,

    For this issue, we could try the following steps to resolve it.

    Step1.

    Referring to the official documentation Working with the Android Manifest., we should use IntentFilter property in Activity.cs and Service.cs files instead of modifying AndroidManifest.xml.

    AndroidManifest.xml is a powerful file in the Android platform that allows you to describe the functionality and requirements of your application to Android. However, working with it is not easy. Xamarin.Android helps to minimize this difficulty by allowing you to add custom attributes to your classes, which will then be used to automatically generate the manifest for you. Our goal is that 99% of our users should never need to manually modify AndroidManifest.xml.

    Step2.

    If the error occurred again, we should look at the resulting AndroidManifest in the obj/Debug/Android folder and see what is actually being exported.

    It was caused by that some plugins did not support Android 12.

    Best Regards,

    Alec Liu.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


1 additional answer

Sort by: Most helpful
  1. Vuyiswa Maseko 351 Reputation points
    2022-05-06T20:14:39.513+00:00

    Good Day

    The reason i took time to fix this issue i was testing everything that you sent me. what you sent me give a light for me . but it was not the solution . So i found out that there is a bug on the "Plugin.FirebasePushNotification" plugin which always produce the following in the Manifest

     <service android:name="crc6893e11b9853011c20.PNFirebaseMessagingService"  >
      <intent-filter>
        <action android:name="com.google.firebase.MESSAGING_EVENT" />
      </intent-filter>
    </service> 
    

    Even though you can try to create a service that inherit from PNFirebaseMessagingService instead of FirebaseMessagingService and decorate the service like this

    [Service(DirectBootAware = true, Exported = false, Enabled = true)]
    [IntentFilter(new[] { "com.google.firebase.INSTANCE_ID_EVENT" })]
    [IntentFilter(new[] { "com.google.firebase.MESSAGING_EVENT" })]
    public class CustomFirebaseMessagingII_D_Service : PNFirebaseMessagingService
    { 
    

    you will still get the service declared without an "export" option in the manifest and playstore will continue to reject due to the android 12 requirements. So to overcome this ,you need to take the generated entry in the manifest that you find in the obj\Release\120\android\manifest\AndroidManifest.xml as copy it your manifest and add that "Export=false" as below

    <service android:name="crc6893e11b9853011c20.PNFirebaseMessagingService" android:exported="false" >
      <intent-filter>
        <action android:name="com.google.firebase.MESSAGING_EVENT" />
      </intent-filter>
    </service>
    

    and save the manifest . Delete the obj folder and and bin folder , rebuild again . The new merged manifest will now contain the export = false. Then you can deploy to playstore and playstore will accepted it.

    Thanks

    0 comments No comments