firebase / flutterfire

🔥 A collection of Firebase plugins for Flutter apps.
https://firebase.google.com/docs/flutter/setup
BSD 3-Clause "New" or "Revised" License
8.63k stars 3.95k forks source link

Local module descriptor class for com.google.android.gms.providerinstaller.dynamite not found. Flutter #10031

Closed rubenvisser22 closed 1 year ago

rubenvisser22 commented 1 year ago

Bug report

Describe the bug Flutter is not writing data to my firebase collection

Steps to reproduce

https://www.youtube.com/watch?v=EA7973HI93E&list=PL4cUxeGkcC9j--TKIdkb3ISfRbJeJYQwC&index=18

Steps to reproduce the behavior:

Run the app, register a user.

Expected behavior

I expected that the user will be made and data to the collection added

the output

 Ignoring header X-Firebase-Locale because its value was null.
D/FirebaseAuth(17181): Notifying id token listeners about user ( fTnXUNwmPUajE9ybOeP3GLW0e392 ).
D/FirebaseAuth(17181): Notifying auth state listeners about user ( fTnXUNwmPUajE9ybOeP3GLW0e392 ).
W/DynamiteModule(17181): Local module descriptor class for com.google.android.gms.providerinstaller.dynamite not found.
I/DynamiteModule(17181): Considering local module com.google.android.gms.providerinstaller.dynamite:0 and remote module com.google.android.gms.providerinstaller.dynamite:0
W/ProviderInstaller(17181): 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/Firestore(17181): (24.4.0) [WriteStream]: (e9a00e8) Stream closed with status: Status{code=UNAVAILABLE, description=Channel shutdownNow invoked, cause=null}.
W/DynamiteModule(17181): Local module descriptor class for com.google.android.gms.providerinstaller.dynamite not found.

my database.dart code:

import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:my_app/models/user.dart';
import 'package:my_app/services/database.dart';

class AuthService {
  final FirebaseAuth _auth = FirebaseAuth.instance;

// create MyUser object based on User
  MyUser? _userFromFirebaseUser(User? user) {
    return user != null ? MyUser(uid: user.uid) : null;
  }

// auth change user stream
  Stream<MyUser?> get user {
    return _auth.authStateChanges().map(_userFromFirebaseUser);
  }

//sign in anonymously
  Future signInAnon() async {
    try {
      UserCredential result = await _auth.signInAnonymously();
      User? user = result.user;
      return _userFromFirebaseUser(user);
    } catch (e) {
      print(e.toString());
      return null;
    }
  }

  // sign in with email and password
  Future SignInWithEmailAndPassword(String email, String password) async {
    try {
      UserCredential result = await _auth.signInWithEmailAndPassword(
          email: email, password: password);
      User? user = result.user;
      return _userFromFirebaseUser(user);
    } catch (e) {
      print(e.toString());
      return null;
    }
  }

  // register with email and password
  Future registerWithEmailAndPassword(String email, String password) async {
    try {
      UserCredential result = await _auth.createUserWithEmailAndPassword(
          email: email, password: password);
      User? user = result.user;
      // create new document for the user  with uid
      await DatabaseService(uid: user?.uid)
          .updateUserData('How do you feel', 'I am mad', 'angry');
      return _userFromFirebaseUser(user);
    } on FirebaseAuthException catch (e) {
      print(e.toString());
      return null;
    }
  }

  // sign out
  Future signOut() async {
    try {
      return await _auth.signOut();
    } catch (e) {
      print(e.toString());
      return null;
    }
  }
}
## my database.dart:

---
import 'package:cloud_firestore/cloud_firestore.dart';

class DatabaseService {
  // collection reference
  final String? uid;
  DatabaseService({this.uid});

  final CollectionReference pollearnCollection =
      FirebaseFirestore.instance.collection('Pollearn');

  Future updateUserData(String question, String answer, String emotion) async {
    Map<String, String> data = {
      'question': question,
      'answer': answer,
      'emotion': emotion,
    };
    return await pollearnCollection.doc(uid).set(data);
  }
}

Flutter doctor

Flutter (Channel stable, 3.3.8, on Microsoft Windows [Version 10.0.19044.2251], locale en-GB) • Flutter version 3.3.8 on channel stable at C:\src\flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 52b3dc25f6 (3 weeks ago), 2022-11-09 12:09:26 +0800 • Engine revision 857bd6b74c • Dart version 2.18.4 • DevTools version 2.15.0

[√] Android toolchain - develop for Android devices (Android SDK version 33.0.0) • Android SDK at C:\Users\ruben\AppData\Local\Android\sdk • Platform android-33, build-tools 33.0.0 • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866) • All Android licenses accepted.

[√] Chrome - develop for the web • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.3.4) • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community • Visual Studio Community 2022 version 17.3.32901.215 • Windows 10 SDK version 10.0.19041.0

[√] Android Studio (version 2021.3) • Android Studio at C:\Program Files\Android\Android Studio • Flutter plugin can be installed from: https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)

[√] IntelliJ IDEA Community Edition (version 2019.3) • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.3.4 • Flutter plugin can be installed from: https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: https://plugins.jetbrains.com/plugin/6351-dart

[√] VS Code (version 1.73.1) • VS Code at C:\Users\ruben\AppData\Local\Programs\Microsoft VS Code • Flutter extension version 3.54.0

[√] Connected device (4 available) • AOSP on IA Emulator (mobile) • emulator-5554 • android-x86 • Android 9 (API 28) (emulator) • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19044.2251] • Chrome (web) • chrome • web-javascript • Google Chrome 108.0.5359.71 • Edge (web) • edge • web-javascript • Microsoft Edge 107.0.1418.62

[√] HTTP Host Availability • All required HTTP hosts are available

• No issues found!

PASTE OUTPUT INSIDE HERE


Flutter dependencies

Dart SDK 2.18.4 Flutter SDK 3.3.8 my_app 1.0.0+1

dependencies:

dev dependencies:

transitive dependencies:


darshankawar commented 1 year ago

Thanks for the report @rubenvisser22 Is the error occurring when you run it on emulator specifically ? or with physical device too ? Can you try the plugin example and see if using it, you get same behavior or not ?

rubenvisser22 commented 1 year ago

Thanks for the report @rubenvisser22 Is the error occurring when you run it on emulator specifically ? or with physical device too ? Can you try the plugin example and see if using it, you get same behavior or not ?

Hi thanks for the reply! Yes it is when I run the code on the emulators(pixel 4 and 6 ). I can't test it on a physical device, because I don't have an andriod.

darshankawar commented 1 year ago

I am unable to replicate this on Android using plugin example or code sample provided above, although per log, it seems to be warning (W/DynamiteModule) ,but there have been similar reports as below, so keeping this issue open and labeling for team's attention and insights:

https://github.com/firebase/flutterfire/issues/9967 https://github.com/firebase/flutterfire/issues/7660 https://github.com/firebase/flutterfire/issues/7257 https://github.com/firebase/flutterfire/issues/5810

Lyokone commented 1 year ago

Reading your flutter doctor it seems that you're using an old version of the emulator:

• AOSP on IA Emulator (mobile) • emulator-5554 • android-x86 • Android 9 (API 28) (emulator)

Can you try to update your emulator with an image that has the Google Services properly included?

You can also try this on a real device? As @darshankawar mentioned this is a warning and shouldn't prevent you from writing to Firebase, you must have something else wrong in your configuration. You can check the example apps included in this repository to get a working example.

rubenvisser22 commented 1 year ago

Reading your flutter doctor it seems that you're using an old version of the emulator:

• AOSP on IA Emulator (mobile) • emulator-5554 • android-x86 • Android 9 (API 28) (emulator)

Can you try to update your emulator with an image that has the Google Services properly included?

You can also try this on a real device? As @darshankawar mentioned this is a warning and shouldn't prevent you from writing to Firebase, you must have something else wrong in your configuration. You can check the example apps included in this repository to get a working example.

Hi I tried changing the image twice both return this in flutter doctor -v : sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64 • Android 13 (API 33) (emulator)

Changing the image twice and updating google service did not work...

Lyokone commented 1 year ago

@rubenvisser22 Do you have the warning and cannot use Firebase or do you have the warning and can use Firebase? Did you try on a real device? (Your computer / emulator might be misconfigured)

rubenvisser22 commented 1 year ago

@Lyokone I have the warning and can use Firebase, because one time flutter did create a collection in firebase. but that was the only time. I don't know why it did it then, since there was the same warning then.

I can't try it on a real device, because I don't have an andriod device (except my computer).

I also tried the following: turn the emulator on and off. tried different emulator updated google play services turnt bluetooth off turnt internet off and on enabled sign in with mail and password adding in andriodManifest.xml

    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />
Lyokone commented 1 year ago

@rubenvisser22 Can you go on the Internet using Chrome on your Android Emulator?

rubenvisser22 commented 1 year ago

@Lyokone Yes I can

Lyokone commented 1 year ago

I'm out of ideas to help you since I cannot reproduce the issue. I would suggest creating a new empty project to see if you still cannot access Firebase.

rubenvisser22 commented 1 year ago

@Lyokone Okay, Thanks for the effort!

google-oss-bot commented 1 year ago

Hey @rubenvisser22. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot commented 1 year ago

Since there haven't been any recent updates here, I am going to close this issue.

@rubenvisser22 if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.

secorapp commented 1 year ago

Hello there,

I had this issue using Flutter and was able to fix the problem by doing two things:

1. Specify my Computer IP Address in the firebase.json file:

Instead of this:

{
  "emulators": {
    "firestore": {
       "port": 8080
    },
    "ui": {
      "enabled": true,
       "port": 4004
    },
    "singleProjectMode": true
  }
}

Do this: (note the "host" key in the json): -- For some reason, note this can also be "host": "0.0.0.0" but NOT "host": "127.0.0.1"

{
  "emulators": {
    "firestore": {
      "host": "10.0.0.58", 
      "port": 8080
    },
    "ui": {
      "enabled": true,
      "host": "localhost",
      "port": 4004
    },
    "singleProjectMode": true
  }
}

2. Indicate my Computer IP Address in the Flutter code:

Instead of this:

import 'package:cloud_firestore/cloud_firestore.dart';
final FirebaseFirestore fbFirestoreInstance = FirebaseFirestore.instance;

Do this:

import 'dart:io' show Platform;

import 'package:cloud_firestore/cloud_firestore.dart';

    final String emulatorHost = Platform.isAndroid ? '10.0.0.58' : 'localhost';
   final FirebaseFirestore fbFsEmulatorInstance = FirebaseFirestore.instance;
    fbFsEmulatorInstance.settings = Settings(
      host: '$emulatorHost:8080',
      sslEnabled: false,
      persistenceEnabled: false,
    );

**Note this works for me in the Android Emulator, but not with a real Android device. I guess this is because the Android Emulator is running in my laptop and so, the network connection is coming from the same MAC Address? - Not sure about this. In any case, both real and virtual android devices work fine with the real Firebase back-end service.