Search code examples
javaandroidfirebasefirebase-app-check

Unable to initialise App Check for Android app


I am trying to run a callable cloud function on the emulator but I'm failing because the app check is not successful

Here's the launcher activity of my app. The activity calling the function is different.

super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash_screen);

        Objects.requireNonNull(getSupportActionBar()).hide();

        FirebaseApp.initializeApp(this);
        FirebaseAppCheck firebaseAppCheck = FirebaseAppCheck.getInstance();
        firebaseAppCheck.installAppCheckProviderFactory(SafetyNetAppCheckProviderFactory.getInstance());

The error I'm getting is:

W/FirebaseContextProvider: Error getting App Check token; using placeholder token instead.
Error: com.google.firebase.FirebaseException: Error returned from API. code: 403 body: App attestation failed: 1:<number>:android<number>:

I don't get how I should be initialising App Check instead.


Solution

  • SafetyNet Attestation fails in flutter because access to your Firebase resources without a valid device is not possible.

    There is this wonderful guide to set this up in FlutterFire do check https://firebase.flutter.dev/docs/app-check/usage/