Fix: The SafetyNet Attestation API is being discontinued and replaced by the new Play Integrity API

When I was trying to publish my app on Google play services, it is showing me below error:

The developer of play-services-safetynet (com.google.android.gms:play-services-safetynet) has reported critical issues with version 17.0.0. Consider upgrading before publishing a new release.

The SafetyNet Attestation API is being discontinued and replaced by the new Play Integrity API. Begin migration as soon as possible to avoid user disruption. The Play Integrity API includes all the integrity signals that SafetyNet Attestation offers and more, like Google Play licensing and better error messaging. Learn more and start migrating at https://developer.android.com/training/safetynet/deprecation-timeline

What The SafetyNet Attestation API is being discontinued and replaced by the new Play Integrity APIWarning Mean?

This Warning is basically seen when you are not using the safety net anywhere into your code.

Just include the Safety net services into your code or use the updated firebase auth SDK and warning will be removed.

For developers to make sure that applications are running in a secure environment, Google Play Services has created a set of APIs called SafetyNet. App developers may decide whether or not to utilize SafetyNet since it is optional.

If an app’s developer doesn’t want it to run on devices that are rooted, modified, running a custom ROM, or infected with malware, SafetyNet disables the program.

Examples of applications that utilize SafetyNet to detect if your smartphone is rooted or not includes Netflix, Snapchat, and banking apps. SafetyNet then disables access to those functions.

Note for Apps which are using SafetyNets Already:

Google stated in June 2022 that we should begin integrating with the Play Integrity API soon. All the integrity signals that SafetyNet Attestation provides are available in Play Integrity API in addition to others.

As of right now, SafetyNet Attestation will still work for your application.

Developers who have switched to the new API will be allowed to keep using the old SafetyNet Attestation on earlier versions of their applications beyond June 30, 2023, but those who have not will not be able to.

Google announced that SafetyNet Attestation will be completely phased out at the end of June 2024.

How to Fix ‘The SafetyNet Attestation API is being discontinued and replaced by the new Play Integrity API’ Warning?

Just to fix the warning error, include the SafetyNet feature to your code and it will fix the warning message immediately for you. Use the below code to fix the warning:

implementation platform('com.google.firebase:firebase-bom:30.2.0')
    implementation 'com.google.firebase:firebase-core'
    implementation('com.google.firebase:firebase-auth') {
        exclude module: "play-services-safetynet"
    }

Once the above mentioned lines have been added to code, it will fix the What The developer of play-services-safetynet (com.google.android.gms:play-services-safetynet) has reported critical issues with version 17.0.0.

Consider upgrading before publishing a new release Warning for now and later once google releases the updated firebase auth SDK, update to that and warning will be removed.