AMM0000 android:exported needs to be explicitly specified for element <service#com.microsoft.appcenter.push.TokenService>. Apps targeting Android 12

Raju Gadda 66 Reputation points
2022-08-25T11:59:53.22+00:00

I have updated targetsdkversion from 30 to 31(andtio OS 12) facing the below issue.

java.exe error AMM0000: android:exported needs to be explicitly specified for element <service#com.microsoft.appcenter.push.TokenService>. Apps targeting Android 12

In my application im using firebase push notification service and i added all the services for notification related. The below code im using in Andriodmanifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="preferExternal" package="com.edmatix.parent.shemida" android:versionName="production.release.1.0.0.0" android:versionCode="20220818"> <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="31" android:maxSdkVersion="31" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <application android:label="SHEMIDA INTERNATIONAL SCHOOL" android:requestLegacyExternalStorage="true" android:preserveLegacyExternalStorage="true" android:icon="@drawable/SHEMIDA_Launcher" android:networkSecurityConfig="@xml/network_security_config"> <meta-data android:name="com.google.android.geo.API_KEY" android:value="AIzaSyAnvG581Y_oVWbDcwYNDy6v4CfRdtmU2CY" /> <uses-library android:name="org.apache.http.legacy" android:required="false" /> <receiver android:name="com.google.firebase.iid.FirebaseInstanceIdInternalReceiver" android:exported="false" /> <receiver android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver" android:exported="true" android:permission="com.google.android.c2dm.permission.SEND"> <service android:name="com.microsoft.appcenter.push.TokenService" android:exported="true"/> <service android:name="crc646c47bac7b09c0b0e.MyFirebaseIIDService" android:exported="true"/> <service android:name="crc646c47bac7b09c0b0e.MyFirebaseMessagingService" android:exported="true"/> <receiver android:name="crc64a93b901f58a35d0f.PushReceiver" android:exported="true"/> <service android:name="crc6494e14b9856016c30.PNFirebaseIIDService" android:exported="true"/> <service android:name="crc6494e14b9856016c30.PNFirebaseMessagingService" android:exported="true"/> <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> </manifest>

Kindly help on this.

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

1 answer

Sort by: Most helpful
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 35,471 Reputation points Microsoft Vendor
    2022-08-26T06:53:36.077+00:00

    Hello,

    It is caused by the incompatibility of the NuGet Package with Android 12.

    You could find the following tips by referring to the NuGet Package Page Microsoft.AppCenter.Push:

    This package has been deprecated as it is legacy and is no longer maintained.
    Suggested Alternatives
    Microsoft.Azure.NotificationHubs

    If you don't know how to use Microsoft.Azure.NotificationHubs, please refer to this official guide Azure Notification Hubs for Xamarin.

    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.