Не удалось получить доступ к серверной части Cloud Firestore. Бэкэнд не ответил в течение 10 секунд — Flutter Android StAndroid

Форум для тех, кто программирует под Android
Ответить Пред. темаСлед. тема
Anonymous
 Не удалось получить доступ к серверной части Cloud Firestore. Бэкэнд не ответил в течение 10 секунд — Flutter Android St

Сообщение Anonymous »

Я использую flutter в Android Studio.
Я получаю это на своей консоли:

Код: Выделить всё

W/Firestore(26053): (24.2.2) [OnlineStateTracker]: Could not reach Cloud Firestore backend. Backend didn't respond within 10 seconds
W/Firestore(26053):
W/Firestore(26053): 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.
E/flutter (26053): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: [cloud_firestore/unavailable] The service is currently unavailable. This is a most likely a transient condition and may be corrected by retrying with a backoff.
E/flutter (26053): #0      checkIfDocExists (package:crypto_app/Functions/firestorehelper.dart:29:5)
E/flutter (26053): 
E/flutter (26053): #1      _MainPagesState._checkUsername (package:crypto_app/UI/mainpages.dart:63:21)
E/flutter (26053): 
E/flutter (26053):
W/Firestore(26053): (24.2.2) [WatchStream]: (a4a9ed6) Stream closed with status: Status{code=UNAVAILABLE, description=Channel shutdownNow invoked, cause=null}.
Я пробовал:
  • поместите во всех трех файлах AndroidManifest.xml
  • поместите в AndroidManifest.xml в разделе main
  • Включен Multidex
  • Использовалось другое соединение Wi-Fi
  • Проверил второй день с той же проблемой
  • Минимальная версия SDK — 21.
  • Скопировал код в новый проект.
Вот моя основная функция:

Код: Выделить всё

Future main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
name: 'Retrospect',
options: DefaultFirebaseOptions.currentPlatform,
);

runApp(MyApp());
}
Мне следует правильно инициализировать приложение, потому что я получаю его в консоли:

Код: Выделить всё

I/FirebaseApp(26053): Device unlocked: initializing all Firebase APIs for app Retrospect
I/flutter (26053): Refreshing
W/DynamiteModule(26053): Local module descriptor class for com.google.android.gms.providerinstaller.dynamite not found.
I/DynamiteModule(26053): Considering local module com.google.android.gms.providerinstaller.dynamite:0 and remote module com.google.android.gms.providerinstaller.dynamite:0
W/ProviderInstaller(26053): 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/DynamiteModule(26053): Класс дескриптора локального модуля для com.google.android.gms.providerinstaller.dynamite не найден., что мне тоже не удалось решить.
Вот мои зависимости от файла pubspec.yaml:

Код: Выделить всё

dependencies:
flutter:
sdk: flutter

# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
firebase_core: ^1.20.1
cloud_firestore: ^3.4.4
http: ^0.13.4
path_provider: ^2.0.11
get_storage: ^2.0.3
Я считаю, что использую последние версии firebase_core и cloud_firestore.
Мои зависимости и плагины файла app/build.gradle:

Код: Выделить всё

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'com.google.gms.google-services'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "com.android.support:multidex:1.0.3"
implementation 'com.google.android.material:material:1.6.1'
implementation 'com.google.android.gms:play-services-ads:21.1.0'
implementation platform('com.google.firebase:firebase-bom:30.3.2')
implementation 'com.google.firebase:firebase-analytics-ktx'
implementation 'com.google.firebase:firebase-storage-ktx'
}
Мой файл build.gradle:

Код: Выделить всё

buildscript {
ext.kotlin_version = '1.6.10'
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:7.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.13'
}
}

allprojects {
repositories {
google()
mavenCentral()
}
}
Расположение файла google-services.json:
[img]https://i.sstatic .net/a0hF3.png[/img]

Вот мои правила в Firestore (правила не должны быть проблемой, поскольку я смог успешно читать данные с помощью Python.

Код: Выделить всё

rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if
request.time < timestamp.date(2022, 12, 12);
}
}
}
Наконец, вот функция, которую я вызываю:

Код: Выделить всё

import 'package:cloud_firestore/cloud_firestore.dart';

Future checkIfDocExists(String docId) async {
try {
// Get reference to Firestore collection
var collectionRef = FirebaseFirestore.instance.collection('accounts');

var doc = await collectionRef.doc(docId).get();
return doc.exists;
} catch (e) {
throw e;
}
}
Что вызывает эту ошибку? (Я вообще не могу получить доступ к Cloud Firestore через flutter).
Я не видел, чтобы мой антивирус (Защитник Windows) или брандмауэр что-либо блокировали, но при необходимости я могу предоставить журналы.


Подробнее здесь: https://stackoverflow.com/questions/733 ... -10-second
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «Android»