Nothing I do seems to want to work. I've followed all the steps on FlutterFire and from a few different places here on Stack Overflow, but I get lots of different issues.
I never get given the token in my console, and when I try to call a Firebase cloud function, I get the following error:
W/co.destis.patc(18740): Accessing hidden method Ldalvik/system/CloseGuard;->get()Ldalvik/system/CloseGuard; (unsupported,core-platform-api, reflection, allowed)
W/co.destis.patc(18740): Accessing hidden method Ldalvik/system/CloseGuard;->open(Ljava/lang/String;)V (unsupported,core-platform-api, reflection, allowed)
W/co.destis.patc(18740): Accessing hidden method Ldalvik/system/CloseGuard;->warnIfOpen()V (unsupported,core-platform-api, reflection, allowed)
W/DynamiteModule(18740): Local module descriptor class for com.google.android.gms.providerinstaller.dynamite not found.
I/DynamiteModule(18740): Considering local module com.google.android.gms.providerinstaller.dynamite:0 and remote module com.google.android.gms.providerinstaller.dynamite:0
W/ProviderInstaller(18740): Failed to load providerinstaller module: No acceptable module found. Local version is 0 and remote version is 0.
W/FirebaseContextProvider(18740): Error getting App Check token. Error: com.google.firebase.FirebaseException: 7:
Here is my main.dart
:
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
await FirebaseAppCheck.instance.activate(
webRecaptchaSiteKey: 'recaptcha-v3-site-key' // I've tried both with and without this
);
await FirebaseAppCheck.instance.setTokenAutoRefreshEnabled(true); // Same here
runApp(const MyApp());
}
I've got this in my MainActivity.kt
at the moment, but whenever I uncomment the function definition, the APK fails to load:
import android.os.Bundle
import com.google.firebase.FirebaseApp
import com.google.firebase.appcheck.FirebaseAppCheck
import com.google.firebase.appcheck.debug.DebugAppCheckProviderFactory
import io.flutter.embedding.android.FlutterActivity
class MainActivity : FlutterActivity() {
// override fun onCreate(savedInstanceState: Bundle?) {
// FirebaseApp.initializeApp(this)
// val firebaseAppCheck = FirebaseAppCheck.getInstance()
// firebaseAppCheck.installAppCheckProviderFactory(DebugAppCheckProviderFactory.getInstance())
// super.onCreate(savedInstanceState)
// }
}
If I uncomment it I get the following when I try to build (to a physical device):
E/AndroidRuntime(20018): FATAL EXCEPTION: main
E/AndroidRuntime(20018): Process: uk.co.destis.patch, PID: 20018
E/AndroidRuntime(20018): java.lang.RuntimeException: Unable to start activity ComponentInfo{uk.co.destis.patch/uk.co.destis.patch.MainActivity}: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process uk.co.destis.patch. Make sure to call FirebaseApp.initializeApp(Context) first.
E/AndroidRuntime(20018): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3635)
E/AndroidRuntime(20018): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3792)
E/AndroidRuntime(20018): at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
E/AndroidRuntime(20018): at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
E/AndroidRuntime(20018): at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
E/AndroidRuntime(20018): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2210)
E/AndroidRuntime(20018): at android.os.Handler.dispatchMessage(Handler.java:106)
E/AndroidRuntime(20018): at android.os.Looper.loopOnce(Looper.java:201)
E/AndroidRuntime(20018): at android.os.Looper.loop(Looper.java:288)
E/AndroidRuntime(20018): at android.app.ActivityThread.main(ActivityThread.java:7839)
E/AndroidRuntime(20018): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(20018): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
E/AndroidRuntime(20018): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
E/AndroidRuntime(20018): Caused by: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process uk.co.destis.patch. Make sure to call FirebaseApp.initializeApp(Context) first.
E/AndroidRuntime(20018): at com.google.firebase.FirebaseApp.getInstance(FirebaseApp.java:183)
E/AndroidRuntime(20018): at com.google.firebase.appcheck.FirebaseAppCheck.getInstance(FirebaseAppCheck.java:29)
E/AndroidRuntime(20018): at uk.co.destis.patch.MainActivity.onCreate(MainActivity.kt:13)
E/AndroidRuntime(20018): at android.app.Activity.performCreate(Activity.java:8050)
E/AndroidRuntime(20018): at android.app.Activity.performCreate(Activity.java:8030)
E/AndroidRuntime(20018): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1329)
E/AndroidRuntime(20018): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3608)
E/AndroidRuntime(20018): ... 12 more