I have flutter application running on real android device. I am using auth, firestore, storage, cloud functions. I am trying to use firebase emulators but with no luck. Here are things I tried:
In my main function in Flutter I am calling this function:
Future<void> useEmulators() async {
// this is the ip of my mac on the router
final ip = "192.168.1.133";
await FirebaseAuth.instance.useAuthEmulator(ip, 9099);
await FirebaseStorage.instance.useStorageEmulator(ip, 9199);
FirebaseFirestore.instance.useFirestoreEmulator(ip, 8080, sslEnabled: false);
FirebaseFunctions.instanceFor(region: 'us-east4')
.useFunctionsEmulator(ip, 5001);
}
I am calling this function from my main() like this:
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
// this is where the function is called
await useEmulators();
FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
final sharedPreferences = await SharedPreferences.getInstance();
await preloadSVGs();
final hiveDbService = HivedbService();
await hiveDbService.init();
return runApp(
ProviderScope(
// observers: [Logger()],
overrides: [
sharedPreferencesProvider.overrideWithValue(sharedPreferences),
hiveDbServiceProvider.overrideWithValue(hiveDbService),
],
child: App(),
),
);
}
Then I updated firebase.json like this:
{
"firestore": {
"rules": "firestore.rules",
"indexes": "firestore.indexes.json"
},
"functions": {
"predeploy": ["npm --prefix \"$RESOURCE_DIR\" run lint"],
"source": "functions",
"runtime": "nodejs12"
},
"storage": {
"rules": "storage.rules"
},
"emulators": {
"auth": {
"host": "192.168.1.133",
"port": 9099
},
"functions": {
"host": "192.168.1.133",
"port": 5001
},
"firestore": {
"host": "192.168.1.133",
"port": 8080
},
"ui": {
"enabled": true,
"port": 4000
},
"pubsub": {
"host": "192.168.1.133",
"port": 8085
},
"storage": {
"host": "192.168.1.133",
"port": 9199
}
}
}
I updated AndroidManifest.xml like this:
<application android:usesCleartextTraffic="true">
</application>
I ran the emulators like this:
firebase emulators:start
When I try to sign up, nothing happens.
I expect that a new auth record or document to be created but nothing happens. The app keep waiting for a while and it times out.
Could someone please tell me what I am doing wrong??
Thanks in advance.