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.71k stars 3.97k forks source link

🐛 [Cloud_firestore] no data in release mode #7163

Closed kivocsa99 closed 3 years ago

kivocsa99 commented 3 years ago

Bug report

Describe the bug when trying to get data from firestore in release mode "null" is always returned but not in debug or profile

Steps to reproduce

Steps to reproduce the behavior:

  1. flutter run --release
  2. no data comes at all from firebase

Expected behavior

as debug and profile it should get all data from firebase

Sample project

repository :

import 'package:cloud_firestore/cloud_firestore.dart';
import '../../../domain/models/yearmodel.dart';
import '../../../domain/years/contracts/i.years.repository.dart';

class YearsRepository implements IYearsRepository {
  final _firestore = FirebaseFirestore.instance;
  static const String yearscollection = "years";

  @override
  Stream<YearsModel> get yearsStream {
    final docRef = _firestore.collection(yearscollection).doc("classes");
    final snapshots = docRef.snapshots();
    return snapshots.map((current) {
      print(current.data());
      return YearsModel.fromJson(current.data()!);
    });
  }
}

ui with flutter hooks and riverpod :

years.when(
                    data: (years) {
                      print(years);
                      return Column(children: [
                        SizedBox(
                          height: 250,
                          child: CupertinoPicker(
                            looping: true,
                            children: years.classes!
                                .map((e) => Center(
                                      child: Text(e.name!),
                                    ))
                                .toList(),
                            itemExtent: 46,
                            onSelectedItemChanged: (index) async {
                              isclinical.value =
                                  years.classes![index].isclinical!;
                              yearId.value = years.classes![index].id!;
                              yearName.value = years.classes![index].name!;
                            },
                          ),
                        ),
                        const SizedBox(
                          height: 10,
                        ),
                        Container(
                          height: 50,
                          width: 210,
                          decoration: BoxDecoration(
                              border: Border.all(color: Colors.blue),
                              borderRadius: BorderRadius.circular(15),
                              color: Colors.white.withOpacity(0.1)),
                          child: Center(
                              child: Text(
                            yearName.value,
                            style: const TextStyle(fontSize: 24),
                          )),
                        )
                      ]);
                    },
                    loading: () => const ShimmerAffect(height: 100, width: 100),
                    error: (error, stack) {
                      print("$error.toString");
                      Center(
                        child: Text("$error"),
                      );

Additional context

when the provider is triggered , it always hits the error: (error, stack) block

Flutter doctor

Run flutter doctor and paste the output below:

Click To Expand ``` kivocsa99@kivocsa99:~$ flutter doctor Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 2.5.2, on Ubuntu 20.04.3 LTS 5.11.0-37-generic, locale en_US.UTF-8) [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0) [✓] Chrome - develop for the web [✓] Android Studio (version 2020.3) [✓] Android Studio [✓] VS Code [✓] Connected device (2 available) • No issues found! ```

Flutter dependencies

Run flutter pub deps -- --style=compact and paste the output below:

Click To Expand ``` ~/AndroidStudioProjectsssd/mscmu$ flutter pub deps -- --style=compactDart SDK 2.14.3Flutter SDK 2.5.2mscmu 1.0.0+1 dependencies: - android_path_provider 0.3.0 [flutter] - audio_session 0.1.6+1 [flutter flutter_web_plugins rxdart meta] - cached_network_image 3.1.0 [flutter flutter_cache_manager octo_image cached_network_image_platform_interface cached_network_image_web] - carousel_slider 4.0.0 [flutter] - cloud_firestore 2.5.3 [cloud_firestore_platform_interface cloud_firestore_web collection firebase_core firebase_core_platform_interface flutter meta] - cupertino_icons 1.0.3 - dartz 0.10.0 - expandable 5.0.1 [flutter] - expandable_text 2.2.0 [flutter] - file_picker 4.1.3 [flutter flutter_web_plugins flutter_plugin_android_lifecycle plugin_platform_interface ffi path] - firebase_auth 3.1.3 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface flutter meta] - firebase_core 1.7.0 [firebase_core_platform_interface firebase_core_web flutter meta] - firebase_messaging 10.0.8 [firebase_core firebase_core_platform_interface firebase_messaging_platform_interface firebase_messaging_web flutter meta] - firebase_storage 10.0.5 [firebase_core firebase_core_platform_interface firebase_storage_platform_interface firebase_storage_web flutter] - flutter 0.0.0 [characters collection meta typed_data vector_math sky_engine] - flutter_downloader 1.7.0 [flutter] - flutter_hooks 0.18.0 [flutter] - flutter_slidable 0.6.0 [flutter] - font_awesome_flutter 9.1.0 [flutter] - form_field_validator 1.1.0 [flutter intl] - freezed_annotation 0.14.3 [collection json_annotation meta] - hooks_riverpod 0.14.0+5 [collection flutter flutter_hooks flutter_riverpod riverpod state_notifier] - http 0.13.4 [async http_parser meta path] - introduction_screen 2.1.0 [flutter dots_indicator] - json_serializable 5.0.2 [analyzer build build_config collection json_annotation meta path source_gen source_helper] - just_audio 0.9.12 [just_audio_platform_interface just_audio_web audio_session rxdart path path_provider async uuid crypto meta flutter] - just_audio_libwinmedia 0.0.4 [flutter just_audio_platform_interface libwinmedia] - logger 1.1.0 - motion_toast 1.5.0 [flutter] - path_provider 2.0.5 [flutter path_provider_linux path_provider_macos path_provider_platform_interface path_provider_windows] - permission_handler 8.2.2 [flutter meta permission_handler_platform_interface] - photo_view 0.13.0 [flutter] - rxdart 0.27.2 - share 2.0.4 [meta mime flutter] - shared_preferences 2.0.8 [flutter meta shared_preferences_linux shared_preferences_macos shared_preferences_platform_interface shared_preferences_web shared_preferences_windows] - shimmer 2.0.0 [flutter] - url_launcher 6.0.12 [flutter meta url_launcher_linux url_launcher_macos url_launcher_platform_interface url_launcher_web url_launcher_windows] dev dependencies: - build_runner 2.1.4 [args async analyzer build build_config build_daemon build_resolvers build_runner_core code_builder collection crypto dart_style frontend_server_client glob graphs http_multi_server io js logging meta mime package_config path pool pub_semver pubspec_parse shelf shelf_web_socket stack_trace stream_transform timing watcher web_socket_channel yaml] - flutter_lints 1.0.4 [lints] - flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters charcode collection matcher meta source_span stream_channel string_scanner term_glyph typed_data] - freezed 0.14.5 [analyzer build build_config collection meta source_gen freezed_annotation] transitive dependencies: - _fe_analyzer_shared 28.0.0 [meta] - analyzer 2.5.0 [_fe_analyzer_shared cli_util collection convert crypto glob meta package_config path pub_semver source_span watcher yaml] - args 2.3.0 - async 2.8.1 [collection meta] - boolean_selector 2.1.0 [source_span string_scanner] - build 2.1.1 [analyzer async convert crypto glob logging meta path] - build_config 1.0.0 [checked_yaml json_annotation path pubspec_parse yaml] - build_daemon 3.0.1 [built_collection built_value http_multi_server logging path pool shelf shelf_web_socket stream_transform watcher web_socket_channel] - build_resolvers 2.0.4 [analyzer async build crypto graphs logging path package_config pool pub_semver stream_transform yaml] - build_runner_core 7.2.2 [async build build_config build_resolvers collection convert crypto glob graphs json_annotation logging meta path package_config pool timing watcher yaml] - built_collection 5.1.1 - built_value 8.1.2 [built_collection collection fixnum meta] - cached_network_image_platform_interface 1.0.0 [flutter flutter_cache_manager] - cached_network_image_web 1.0.1 [flutter flutter_cache_manager cached_network_image_platform_interface] - characters 1.1.0 - charcode 1.3.1 - checked_yaml 2.0.1 [json_annotation source_span yaml] - cli_util 0.3.4 [meta path] - clock 1.1.0 - cloud_firestore_platform_interface 5.4.2 [collection firebase_core flutter meta plugin_platform_interface] - cloud_firestore_web 2.4.3 [cloud_firestore_platform_interface collection firebase_core firebase_core_web flutter flutter_web_plugins js] - code_builder 4.1.0 [built_collection built_value collection matcher meta] - collection 1.15.0 - convert 3.0.1 [typed_data] - crypto 3.0.1 [collection typed_data] - dart_style 2.2.0 [analyzer args path pub_semver source_span] - dots_indicator 2.0.0 [flutter] - fake_async 1.2.0 [clock collection] - ffi 1.1.2 - file 6.1.2 [meta path] - firebase_auth_platform_interface 6.1.1 [firebase_core flutter meta plugin_platform_interface] - firebase_auth_web 3.1.2 [firebase_auth_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins http_parser intl js meta] - firebase_core_platform_interface 4.0.1 [collection flutter meta plugin_platform_interface] - firebase_core_web 1.1.0 [firebase_core_platform_interface flutter flutter_web_plugins js meta] - firebase_messaging_platform_interface 3.0.6 [firebase_core flutter meta plugin_platform_interface] - firebase_messaging_web 2.0.6 [firebase_core firebase_core_web firebase_messaging_platform_interface flutter flutter_web_plugins js meta] - firebase_storage_platform_interface 4.0.3 [collection firebase_core flutter meta plugin_platform_interface] - firebase_storage_web 3.0.3 [async firebase_core firebase_core_web firebase_storage_platform_interface flutter flutter_web_plugins http js meta] - fixnum 1.0.0 - flutter_blurhash 0.6.0 [flutter meta pedantic] - flutter_cache_manager 3.1.2 [clock collection file flutter http path path_provider pedantic rxdart sqflite uuid] - flutter_plugin_android_lifecycle 2.0.3 [flutter] - flutter_riverpod 0.14.0+3 [collection flutter meta riverpod state_notifier] - flutter_web_plugins 0.0.0 [flutter js characters collection meta typed_data vector_math] - frontend_server_client 2.1.2 [async path] - glob 2.0.2 [async collection file path string_scanner] - graphs 2.1.0 [collection] - http_multi_server 3.0.1 [async] - http_parser 4.0.0 [charcode collection source_span string_scanner typed_data] - intl 0.17.0 [clock path] - io 1.0.3 [meta path string_scanner] - js 0.6.3 - json_annotation 4.1.0 [meta] - just_audio_platform_interface 4.0.0 [flutter plugin_platform_interface] - just_audio_web 0.4.2 [just_audio_platform_interface flutter flutter_web_plugins] - libwinmedia 0.0.7 [ffi path] - lints 1.0.1 - logging 1.0.2 - matcher 0.12.10 [stack_trace] - meta 1.7.0 - mime 1.0.0 - octo_image 1.0.0+1 [flutter flutter_blurhash] - package_config 2.0.2 [path] - path 1.8.0 - path_provider_linux 2.1.0 [flutter path path_provider_platform_interface xdg_directories] - path_provider_macos 2.0.2 [flutter] - path_provider_platform_interface 2.0.1 [flutter meta platform plugin_platform_interface] - path_provider_windows 2.0.3 [ffi flutter meta path path_provider_platform_interface win32] - pedantic 1.11.1 - permission_handler_platform_interface 3.7.0 [flutter meta plugin_platform_interface] - platform 3.0.2 - plugin_platform_interface 2.0.2 [meta] - pool 1.5.0 [async stack_trace] - process 4.2.3 [file path platform] - pub_semver 2.1.0 [collection meta] - pubspec_parse 1.1.0 [checked_yaml collection json_annotation pub_semver yaml] - riverpod 0.14.0+3 [collection freezed_annotation meta state_notifier] - shared_preferences_linux 2.0.2 [file meta flutter path path_provider_linux shared_preferences_platform_interface] - shared_preferences_macos 2.0.2 [flutter shared_preferences_platform_interface] - shared_preferences_platform_interface 2.0.0 [flutter] - shared_preferences_web 2.0.2 [flutter flutter_web_plugins meta shared_preferences_platform_interface] - shared_preferences_windows 2.0.2 [flutter file meta path path_provider_platform_interface path_provider_windows shared_preferences_platform_interface] - shelf 1.2.0 [async collection http_parser path stack_trace stream_channel] - shelf_web_socket 1.0.1 [shelf stream_channel web_socket_channel] - sky_engine 0.0.99 - source_gen 1.1.1 [analyzer async build dart_style glob meta path source_span yaml] - source_helper 1.3.0 [analyzer collection source_gen] - source_span 1.8.1 [collection path term_glyph] - sqflite 2.0.0+4 [flutter sqflite_common path] - sqflite_common 2.0.1+1 [synchronized path meta] - stack_trace 1.10.0 [path] - state_notifier 0.7.1 [meta] - stream_channel 2.1.0 [async] - stream_transform 2.0.0 - string_scanner 1.1.0 [charcode source_span] - synchronized 3.0.0 - term_glyph 1.2.0 - test_api 0.4.2 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph matcher] - timing 1.0.0 [json_annotation] - typed_data 1.3.0 [collection] - url_launcher_linux 2.0.2 [flutter] - url_launcher_macos 2.0.2 [flutter] - url_launcher_platform_interface 2.0.4 [flutter plugin_platform_interface] - url_launcher_web 2.0.4 [flutter flutter_web_plugins meta url_launcher_platform_interface] - url_launcher_windows 2.0.2 [flutter] - uuid 3.0.5 [crypto] - vector_math 2.1.0 - watcher 1.0.1 [async path] - web_socket_channel 2.1.0 [async crypto stream_channel] - win32 2.2.9 [ffi] - xdg_directories 0.2.0 [meta path process] - yaml 3.1.0 [collection source_span string_scanner]```

darshankawar commented 3 years ago

@kivocsa99 Please see this open issue and check if it sounds similar to your case.

kivocsa99 commented 3 years ago

@darshankawar it might be the same issue but iam not using agora at all

kivocsa99 commented 3 years ago

@darshankawar the app is not signed and uses the debug sha1 key in firebase console but if it is not signed yet it shouldnot be a problem at all

kivocsa99 commented 3 years ago

@darshankawar other firebase services work like firebase messaging and iam able to get notification with cloud functions so it's not a release key problem !

kivocsa99 commented 3 years ago

@darshankawar have u managed to reprodurce the issue ?

darshankawar commented 3 years ago

@kivocsa99 I tried sample app using the plugin's official example and ran it in release mode , which came back with data properly, as below:

Screenshot 2021-10-11 at 12 03 31 PM

You may try the same and see if it works for you. If this doesn't represent your case, please provide a self contained minimal reproducible code sample without any 3rd party plugins, that we can use to verify this.

Thanks.

kivocsa99 commented 3 years ago

@darshankawar the problem was when i added 3 packages i don't know whichh one have done this bug , so i came across something i have to do in android gradle which is adding this to release block :

buildTypes {
        release {
           minifyEnabled false
           shrinkResources false
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.debug
        }
    }

and that did the trick , the question is why !

darshankawar commented 3 years ago

@kivocsa99 I am not 100% sure, but ideally you won't require to add or set those flags to false. I plugin example I tried doesn't have those entries.

darshankawar commented 3 years ago

Closing this based on your comment above, as resolved.