Android Emulator cannot access Firebase with App Check in Enforcement mode
Discussed in https://github.com/firebase/flutterfire/discussions/9284
Originally posted by lukertaylor August 1, 2022 Hello,
I have set-up App Check and followed the instructions (https://firebase.google.com/docs/app-check/android/debug-provider#kotlin+ktx_1) to successfully generate debug secrets on a physical Android device and the Android Emulator.
After installing the Debug Tokens in the Android Firebase app, the physical Android device works fine, but the Android Emulator cannot access Firestore:
/Firestore(): (24.2.1) [WriteStream]: () Stream closed with status: Status{code=PERMISSION_DENIED, description=Missing or insufficient permissions., cause=null}. W/Firestore(): (24.2.1) [Firestore]: Write failed at [path removed] 3: Status{code=PERMISSION_DENIED, description=Missing or insufficient permissions., cause=null} E/flutter (): [ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: [cloud_firestore/permission-denied] The caller does not have permission to execute the specified operation.
Is there a workaround? Or can I only debug on a physical Android device?
Thank you for any help received.
Luke
I have found a workaround, which is to only load the App Check plug-in when building in release mode:
if (kReleaseMode) { await FirebaseAppCheck.instance.activate(); }
@lukertaylor Currently it seems the app_check only works on real device and not on emulators. See this issue comment and see if it helps in your case.
@darshankawar I found a different, and much simpler, workaround that I thought others might find helpful.
@lukertaylor Can you also try this solution and see if it helps ?
@darshankawar sorry but that isn't helpful. I am not using a Cloud Function.
I posted the issue and a workaround.
I was able to get it to work using a MethodChannel: https://stackoverflow.com/a/73330541/5066615
I have found a workaround, which is to only load the App Check plug-in when building in release mode:
if (kReleaseMode) { await FirebaseAppCheck.instance.activate(); }
I guess your app will stop working as soon as you enable the AppCheck in the Firebase Console, since the backend will expect the token.
No that is not the case. As long as the debug token has been registered.
On Wed, 17 Aug 2022, 14:36 Eduardo Baião, @.***> wrote:
I have found a workaround, which is to only load the App Check plug-in when building in release mode:
if (kReleaseMode) { await FirebaseAppCheck.instance.activate(); }
I guess your app will stop working as soon as you enable the AppCheck in the Firebase Console, since the backend will expect the token.
— Reply to this email directly, view it on GitHub https://github.com/firebase/flutterfire/issues/9291#issuecomment-1217952349, or unsubscribe https://github.com/notifications/unsubscribe-auth/APIAQOOMDN2S5SRJL2WESGLVZTMEXANCNFSM55NQ7D6A . You are receiving this because you were mentioned.Message ID: @.***>
This shouldn't be an issue now you can set whatever provider you wish on android i.e. debug provider.