1

I'm trying to use App Check from Firebase in a Flutter project for my Android app, but as usual I've problems with Google.

It is said on the documentation to add this code to our Android code:

// kotlin code
FirebaseApp.initializeApp(/*context=*/this)
val firebaseAppCheck = FirebaseAppCheck.getInstance()
firebaseAppCheck.installAppCheckProviderFactory(
    DebugAppCheckProviderFactory.getInstance()
)

So naturally, I edit my /android/app/src/main/kotlin/com/example/my_app/MainActivity.kt file like so:

package fr.my_app.app

import io.flutter.embedding.android.FlutterActivity
import android.os.Bundle
import com.google.firebase.FirebaseApp

class MainActivity: FlutterActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        FirebaseApp.initializeApp(/*context=*/this)
        val firebaseAppCheck = FirebaseAppCheck.getInstance()
        firebaseAppCheck.installAppCheckProviderFactory(
            DebugAppCheckProviderFactory.getInstance()
        )
        super.onCreate(savedInstanceState)
    }
}

According to the FlutterFire documentation, we have to add a package:

import com.google.firebase.appcheck.FirebaseAppCheck

And there the problems begin:

  • Android Studio, nor VSC nor IntelliJ IDEA, detect this package. They highlight the word appcheck in red and say Unresolved reference: appcheck. I understand that this package doesn't exist.
  • As a consequence, I have a failure when trying to build the app with flutter run:
blablabla\MainActivity.kt: Unresolved reference: DebugAppCheckProviderFactory

My goal

Accessing Firebase features with App Check in debug mode (Android only)

Notes

  • I followed the whole official documentation
  • I have my build.gradle up to date
  • I have my pubspec.yaml up to date
  • I have all my softwares up to date

What did I do wrong?

EDITS

All right I have found the correct packages here

Now another problem! It should print in the console the debug token for me to add it in the Firebase Console, but nothing happens. I mean that no debug token is given in the console, only an error when trying to access Firebase features:

E/StorageException(12120): {  "error": {    "code": 401,    "message": "Firebase App Check token is invalid."  }}
E/StorageException(12120): java.io.IOException: {  "error": {    "code": 401,    "message": "Firebase App Check token is invalid."  }}
E/StorageException(12120):      at com.google.firebase.storage.network.NetworkRequest.parseResponse(NetworkRequest.java:445)
E/StorageException(12120):      at com.google.firebase.storage.network.NetworkRequest.parseErrorResponse(NetworkRequest.java:462)
E/StorageException(12120):      at com.google.firebase.storage.network.NetworkRequest.processResponseStream(NetworkRequest.java:453)
E/StorageException(12120):      at com.google.firebase.storage.network.NetworkRequest.performRequest(NetworkRequest.java:272)
E/StorageException(12120):      at com.google.firebase.storage.network.NetworkRequest.performRequest(NetworkRequest.java:289)
E/StorageException(12120):      at com.google.firebase.storage.internal.ExponentialBackoffSender.sendWithExponentialBackoff(ExponentialBackoffSender.java:76)
E/StorageException(12120):      at com.google.firebase.storage.internal.ExponentialBackoffSender.sendWithExponentialBackoff(ExponentialBackoffSender.java:68)
E/StorageException(12120):      at com.google.firebase.storage.ListTask.run(ListTask.java:65)
E/StorageException(12120):      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/StorageException(12120):      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/StorageException(12120):      at java.lang.Thread.run(Thread.java:923)

Am I the only one having trouble with Firebase like all the time? All the questions I asked on StackOverflow are about this thing.

ThomasG2201
  • 676
  • 6
  • 25
  • Does this answer your question? [Using Firebase App Check is not working (debug)](https://stackoverflow.com/questions/67759156/using-firebase-app-check-is-not-working-debug) – Martin Zeitler Dec 25 '21 at 02:38
  • It doesn't, I'm stuck with this java exception. The problem is that the console doesn't print what it should print: the generated debug token. I tested the web version of this feature and it works perfectly fine. – ThomasG2201 Dec 25 '21 at 11:43
  • Have you resolved this ? Could you post your whole main activity with imports ? – Ced Apr 07 '22 at 20:29
  • I've never found a solution and I'm still waiting for the developers to do something about it. There are several opened issues on GitHub – ThomasG2201 Apr 12 '22 at 10:23

0 Answers0