Protect against security threats with SafetyNet

SafetyNet provides a set of services and APIs that help protect your app against security threats, including device tampering, bad URLs, potentially harmful apps, and fake users.

Before you begin

To prepare your app, complete the steps in the following sections.

App prerequisites

Make sure that your app's build file uses the following values:

  • A minSdkVersion of 19 or higher
  • A compileSdkVersion of 28 or higher

Configure your app

In your project-level build.gradle file, include Google's Maven repository and Maven central repository in both your buildscript and allprojects sections:

buildscript {
    repositories {
        google()
        mavenCentral()
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

Add the Google Play services dependency for the Google Pay API to your module's Gradle build file, which is commonly app/build.gradle:

dependencies {
  implementation 'com.google.android.gms:play-services-safetynet:17.0.1'
}

Lessons

SafetyNet Attestation API
Learn how the SafetyNet Attestation API provides a cryptographically-signed attestation, assessing the integrity of the Android device your app is running on.
SafetyNet Safe Browsing API
Learn how the SafetyNet Safe Browsing API provides services for determining whether a URL has been marked as a known threat by Google.
SafetyNet reCAPTCHA API
Learn how the SafetyNet reCAPTCHA API protects your app from malicious traffic.
SafetyNet Verify Apps API
Learn how the SafetyNet Verify Apps API protects devices against potentially harmful apps.

Additional resources