Reputation: 87
So I'm writing this in case anyone has any ideas. I cannot get Firebase / Firestore working on my Android emulator with my Flutter project.
At this point, all I'm trying to do is sign in anonymously, and check if a document exists by printing something in the terminal to confirm my app has a connection to Firebase / Firestore in a skeleton app.
firebase_auth: ^3.7.0
cloud_firestore: ^3.4.6
firebase_core: ^1.21.1
Sign in anonymously.
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
await FirebaseAuth.instance.signInAnonymously();
runApp(const MyApp());
}
...
And call this method to tell me if the document exists (it does).
Future testFirebase() async {
await FirebaseFirestore.instance
.collection("fruit")
.doc("peach")
.get()
.then((document) {
if (document.exists) {
print("exists");
} else {
print("does not exist");
}
});
}
Doing this causes the app to hang. Then after about 5 minutes, I get a slew of error messages
W/System (13182): Ignoring header X-Firebase-Locale because its value was null.
D/FirebaseAuth(13182): Notifying id token listeners about user ( fUMAwRpjESeaRik9ABkzTNE7bH92 ).
D/FirebaseAuth(13182): Notifying auth state listeners about user ( fUMAwRpjESeaRik9ABkzTNE7bH92 ).
W/DynamiteModule(13182): Local module descriptor class for com.google.android.gms.providerinstaller.dynamite not found.
I/DynamiteModule(13182): Considering local module com.google.android.gms.providerinstaller.dynamite:0 and remote module com.google.android.gms.providerinstaller.dynamite:0
W/ProviderInstaller(13182): Failed to load providerinstaller module: No acceptable module com.google.android.gms.providerinstaller.dynamite found. Local version is 0 and remote version is 0.
I/flutterconntes(13182): The ClassLoaderContext is a special shared library.
I/chatty (13182): uid=10156(com.example.flutterconntest) AsyncTask #1 identical 1 line
I/flutterconntes(13182): The ClassLoaderContext is a special shared library.
D/nativeloader(13182): classloader namespace configured for unbundled product apk. library_path=/product/priv-app/PrebuiltGmsCore/lib/x86:/product/priv-app/PrebuiltGmsCore/PrebuiltGmsCore.apk!/lib/x86:/product/lib:/system/product/lib
W/ProviderInstaller(13182): Failed to report request stats: com.google.android.gms.common.security.ProviderInstallerImpl.reportRequestStats [class android.content.Context, long, long]
W/flutterconntes(13182): Accessing hidden field Ldalvik/system/BaseDexClassLoader;->pathList:Ldalvik/system/DexPathList; (greylist, reflection, allowed)
W/flutterconntes(13182): Accessing hidden field Ldalvik/system/DexPathList;->nativeLibraryDirectories:Ljava/util/List; (greylist, reflection, allowed)
W/flutterconntes(13182): Accessing hidden field Ldalvik/system/DexPathList;->systemNativeLibraryDirectories:Ljava/util/List; (greylist, reflection, allowed)
W/flutterconntes(13182): Accessing hidden field Ldalvik/system/DexPathList;->nativeLibraryPathElements:[Ldalvik/system/DexPathList$NativeLibraryElement; (greylist, reflection, allowed)
W/flutterconntes(13182): Accessing hidden method Ldalvik/system/DexPathList;->makePathElements(Ljava/util/List;)[Ldalvik/system/DexPathList$NativeLibraryElement; (greylist, reflection, allowed)
V/NativeCrypto(13182): Registering com/google/android/gms/org/conscrypt/NativeCrypto's 286 native methods...
W/flutterconntes(13182): Accessing hidden method Ljava/security/spec/ECParameterSpec;->getCurveName()Ljava/lang/String; (greylist, reflection, allowed)
I/ProviderInstaller(13182): Installed default security provider GmsCore_OpenSSL
I/TetheringManager(13182): registerTetheringEventCallback:com.example.flutterconntest
W/Firestore(13182): (24.2.2) [OnlineStateTracker]: Could not reach Cloud Firestore backend. Backend didn't respond within 10 seconds
W/Firestore(13182):
W/Firestore(13182): This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.
W/Firestore(13182): (24.2.2) [WatchStream]: (9bc0685) Stream closed with status: Status{code=UNAVAILABLE, description=Channel shutdownNow invoked, cause=null}.
W/DynamiteModule(13182): Local module descriptor class for com.google.android.gms.providerinstaller.dynamite not found.
I/DynamiteModule(13182): Considering local module com.google.android.gms.providerinstaller.dynamite:0 and remote module com.google.android.gms.providerinstaller.dynamite:0
W/ProviderInstaller(13182): Failed to load providerinstaller module: No acceptable module com.google.android.gms.providerinstaller.dynamite found. Local version is 0 and remote version is 0.
W/ProviderInstaller(13182): Failed to report request stats: com.google.android.gms.common.security.ProviderInstallerImpl.reportRequestStats [class android.content.Context, long, long]
However, on my physical devices running Android Go and Android 12, it works perfectly.
I have:
<uses-permission android:name="android.permission.INTERNET"/>
and <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
to AndroidManifest main & debugminSdkVersion 22
request.auth != null
android:usesCleartextTraffic="true"
to AndroidManifestAnd bearing in mind, the physical device works perfectly from from the start without me having to do much of anything. But after reading Stack Overflow for days, I'm at a loss.
If anyone has any ideas that I haven't tried, please do let me know :) Thanks.
Upvotes: 2
Views: 959
Reputation: 81
I had the same issue. Firebase components were working with a huge delay. I had to install earlier emulator version. The problem occured only on my old laptop, my PC was unaffected.
https://developer.android.com/studio/emulator_archive
Upvotes: 3