Я получаю сообщение об ошибке «привязка еще не инициализирована» при попытке подключить Firebase с флаттером.IOS

Программируем под IOS
Ответить Пред. темаСлед. тема
Anonymous
 Я получаю сообщение об ошибке «привязка еще не инициализирована» при попытке подключить Firebase с флаттером.

Сообщение Anonymous »

Пожалуйста, мы будем благодарны за любую помощь, но поиск в Google, похоже, не дает здесь никаких правильных решений. Что меня еще больше смущает, так это то, что эта ошибка теперь появляется даже при попытке запуска приложений без Firebase или даже асинхронных функций, что делает для меня практически невозможным выполнение чего-либо еще во Flutter.
Я пытался изучить Firebase и получил выполнил шаги, показанные здесь, без особых проблем.
При поиске в Google решения проблемы, с которой я столкнулся (сообщение об ошибке в конце сообщения), обычное исправление, которое я видел, — это добавление только этой строки в основную функцию. .

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

WidgetsFlutterBinding.ensureInitialized();
Однако он у меня уже есть, и я все равно снова получаю ту же ошибку. Вот моя основная функция void.

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

void main() async{
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
runApp(const App());
}
Вот какая ошибка:

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

Launching lib\main.dart on sdk gphone x86 64 in debug mode...
../../flutter/packages/flutter/lib/src/foundation/binding.dart:309:24: Error: String starting with ' must end with '.
ErrorSummary('Binding has not yet been iException has occurred.Exception has occurred.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:311:93: Error: Expected ',' before this.
The "instance" getter on the ServicesBinding binding mixin is only available once that binding has been initialized.
^^^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:311:98: Error: Expected ',' before this.
The "instance" getter on the ServicesBinding binding mixin is only available once that binding has been initialized.
^^^^^^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:311:106: Error: Expected ',' before this.
The "instance" getter on the ServicesBinding binding mixin is only available once that binding has been initialized.
^^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:311:110: Error: Expected ',' before this.
The "instance" getter on the ServicesBinding binding mixin is only available once that binding has been initialized.
^^^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:311:115: Error: Expected ',' before this.
The "instance" getter on the ServicesBinding binding mixin is only available once that binding has been initialized.
^^^^^^^^^^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:311:115: Error: Undefined name 'initialized'.
The "instance" getter on the ServicesBinding binding mixin is only available once that binding has been initialized.
^^^^^^^^^^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:312:30: Error: 'done' isn't a type.
Typically, this is done by calling "WidgetsFlutterBinding.ensureInitialized()" or "runApp()" (the latter calls the former). Typically this call is done in the "void main()" method. The "ensureInitialized" method is idempotent; calling it multiple times is not harmful. After ca
^^^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:312:22: Error: Expected identifier, but got 'this'.
Typically, this is done by calling "WidgetsFlutterBinding.ensureInitialized()" or "runApp()" (the latter calls the former). Typically this call is done in the "void main()" method. The "ensureInitialized" method is idempotent; calling it multiple times is not harmful. After ca
^^^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:312:35: Error: Expected ',' before this.
Typically, this is done by calling "WidgetsFlutterBinding.ensureInitialized()" or "runApp()" (the latter calls the former). Typically this call is done in the "void main()" method.  The "ensureInitialized" method is idempotent; calling it multiple times is not harmful. After ca
^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:312:38: Error: Expected ',' before this.
Typically, this is done by calling "WidgetsFlutterBinding.ensureInitialized()" or "runApp()" (the latter calls the former). Typically this call is done in the "void main()" method. The "ensureInitialized" method is idempotent; calling it multiple times is not harmful. After ca
^^^^^^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:312:46: Error: Expected ',' before this.
Typically, this is done by calling "WidgetsFlutterBinding.ensureInitialized()" or "runApp()" (the latter calls the former). Typically this call is done in the "void main()" method. The "ensureInitialized" method is idempotent; calling it multiple times is not harmful. After ca
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:312:90: Error: Expected ',' before this.
Typically, this is done by calling "WidgetsFlutterBinding.ensureInitialized()" or "runApp()" (the latter calls the former). Typically this call is done in the "void main()" method. The "ensureInitialized" method is idempotent; calling it multiple times is not harmful. After ca
^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:312:93: Error: Expected ',' before this.
Typically, this is done by calling "WidgetsFlutterBinding.ensureInitialized()" or "runApp()" (the latter calls the former). Typically this call is done in the "void main()" method. The "ensureInitialized" method is idempotent; calling it multiple times is not harmful. After ca
^^^^^^^^^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:312:109: Error: Expected ',' before this.
Typically, this is done by calling "WidgetsFlutterBinding.ensureInitialized()" or "runApp()" (the latter calls the former). Typically this call is done in the "void main()" method. The "ensureInitialized" method is idempotent; calling it multiple times is not harmful. After ca
^^^^^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:312:116: Error: Expected ',' before this.
Typically, this is done by calling "WidgetsFlutterBinding.ensureInitialized()" or "runApp()" (the latter calls the former). Typically this call is done in the "void main()" method. The "ensureInitialized" method is idempotent; calling it multiple times is not harmful. After ca
^^^^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:312:122: Error: Expected ',' before this.
Typically, this is done by calling "WidgetsFlutterBinding.ensureInitialized()" or "runApp()" (the latter calls the former). Typically this call is done in the "void main()" method. The "ensureInitialized" method is idempotent; calling it multiple times is not harmful. After ca
^^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:312:126: Error: Expected ',' before this.
Typically, this is done by calling "WidgetsFlutterBinding.ensureInitialized()" or "runApp()" (the latter calls the former). Typically this call is done in the "void main()" method. The "ensureInitialized" method is idempotent; calling it multiple times is not harmful. After ca
^^^^^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:312:105: Error: Undefined name 'the'.
Typically, this is done by calling "WidgetsFlutterBinding.ensureInitialized()" or "runApp()" (the latter calls the former). Typically this call is done in the "void main()" method. The "ensureInitialized" method is idempotent; calling it multiple times is not harmful.  After ca
^^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:312:109: Error: Undefined name 'latter'.
Typically, this is done by calling "WidgetsFlutterBinding.ensureInitialized()" or "runApp()" (the latter calls the former). Typically this call is done in the "void main()" method. The "ensureInitialized" method is idempotent; calling it multiple times is not harmful. After ca
^^^^^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:312:116: Error: Undefined name 'calls'.
Typically, this is done by calling "WidgetsFlutterBinding.ensureInitialized()" or "runApp()" (the latter calls the former). Typically this call is done in the "void main()" method. The "ensureInitialized" method is idempotent; calling it multiple times is not harmful. After ca
^^^^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:312:122: Error: Undefined name 'the'.
Typically, this is done by calling "WidgetsFlutterBinding.ensureInitialized()" or "runApp()" (the latter calls the former). Typically this call is done in the "void main()" method. The "ensureInitialized" method is idempotent; calling it multiple times is not harmful. After ca
^^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:312:126: Error: Undefined name 'former'.
Typically, this is done by calling "WidgetsFlutterBinding.ensureInitialized()" or "runApp()" (the latter calls the former). Typically this call is done in the "void main()" method. The "ensureInitialized" method is idempotent; calling it multiple times is not harmful. After ca
^^^^^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:312:145: Error: Expected ',' before this.
Typically, this is done by calling "WidgetsFlutterBinding.ensureInitialized()" or "runApp()" (the latter calls the former). Typically this call is done in the "void main()" method. The "ensureInitialized" method is idempotent; calling it multiple times is not harmful. After ca
^^^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:312:150: Error: Expected ',' before this.
Typically, this is done by calling "WidgetsFlutterBinding.ensureInitialized()" or "runApp()" (the latter calls the former). Typically this call is done in the "void main()" method. The "ensureInitialized" method is idempotent; calling it multiple times is not harmful. After ca
^^^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:312:158: Error: 'done' isn't a type.
Typically, this is done by calling "WidgetsFlutterBinding.ensureInitialized()" or "runApp()" (the latter calls the former). Typically this call is done in the "void main()" method. The "ensureInitialized" method is idempotent; calling it multiple times is not harmful. After ca
^^^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:312:150: Error: Undefined name 'call'.
Typically, this is done by calling "WidgetsFlutterBinding.ensureInitialized()" or "runApp()" (the latter calls the former). Typically this call is done in the "void main()" method. The "ensureInitialized" method is idempotent; calling it multiple times is not harmful. After ca
^^^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:312:163: Error: Expected ',' before this.
Typically, this is done by calling "WidgetsFlutterBinding.ensureInitialized()" or "runApp()" (the latter calls the former). Typically this call is done in the "void main()" method. The "ensureInitialized" method is idempotent; calling it multiple times is not harmful.  After ca
^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:312:163: Error: 'in' can't be used as an identifier because it's a keyword.
Try renaming this to be an identifier that isn't a keyword.
Typically, this is done by calling "WidgetsFlutterBinding.ensureInitialized()" or "runApp()" (the latter calls the former). Typically this call is done in the "void main()" method. The "ensureInitialized" method is idempotent; calling it multiple times is not harmful. After ca
^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:312:166: Error: Expected ',' before this.
Typically, this is done by calling "WidgetsFlutterBinding.ensureInitialized()" or "runApp()" (the latter calls the former). Typically this call is done in the "void main()" method. The "ensureInitialized" method is idempotent; calling it multiple times is not harmful. After ca
^^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:312:170: Error: Expected ',' before this.
Typically, this is done by calling "WidgetsFlutterBinding.ensureInitialized()" or "runApp()" (the latter calls the former). Typically this call is done in the "void main()" method. The "ensureInitialized" method is idempotent; calling it multiple times is not harmful. After ca
^^^^^^^^^^^^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:312:184: Error: Expected ',' before this.
Typically, this is done by calling "WidgetsFlutterBinding.ensureInitialized()" or "runApp()" (the latter calls the former). Typically this call is done in the "void main()" method. The "ensureInitialized" method is idempotent; calling it multiple times is not harmful. After ca
^^^^^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:312:184: Error: Undefined name 'method'.
Typically, this is done by calling "WidgetsFlutterBinding.ensureInitialized()" or "runApp()" (the latter calls the former). Typically this call is done in the "void main()" method. The "ensureInitialized" method is idempotent; calling it multiple times is not harmful. After ca
^^^^^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:312:196: Error: Expected ',' before this.
Typically, this is done by calling "WidgetsFlutterBinding.ensureInitialized()" or "runApp()" (the latter calls the former). Typically this call is done in the "void main()" method. The "ensureInitialized" method is idempotent; calling it multiple times is not harmful. After ca
^^^^^^^^^^^^^^^^^^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:312:216: Error: Expected ',' before this.
Typically, this is done by calling "WidgetsFlutterBinding.ensureInitialized()" or "runApp()" (the latter calls the former). Typically this call is done in the "void main()" method. The "ensureInitialized" method is idempotent; calling it multiple times is not harmful. After ca
^^^^^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:312:226: Error: 'idempotent' isn't a type.
Typically, this is done by calling "WidgetsFlutterBinding.ensureInitialized()" or "runApp()" (the latter calls the former). Typically this call is done in the "void main()" method. The "ensureInitialized" method is idempotent; calling it multiple times is not harmful. After ca
^^^^^^^^^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:312:216: Error: Undefined name 'method'.
Typically, this is done by calling "WidgetsFlutterBinding.ensureInitialized()" or "runApp()" (the latter calls the former). Typically this call is done in the "void main()" method.  The "ensureInitialized" method is idempotent; calling it multiple times is not harmful.  After ca
^^^^^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:310:25: Error: Undefined name 'Binding'.
FlutterError (Binding has not yet been initialized.
^^^^^^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:310:33: Error: Undefined name 'has'.
FlutterError (Binding has not yet been initialized.
^^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:310:37: Error: Undefined name 'not'.
FlutterError (Binding has not yet been initialized.
^^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:310:41: Error: Undefined name 'yet'.
FlutterError (Binding has not yet been initialized.
^^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:310:45: Error: Undefined name 'been'.
FlutterError (Binding has not yet been initialized.
^^^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:311:26: Error: Undefined name 'getter'.
The "instance" getter on the ServicesBinding binding mixin is only available once that binding has been initialized.
^^^^^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:311:33: Error: Undefined name 'on'.
The "instance" getter on the ServicesBinding binding mixin is only available once that binding has been initialized.
^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:311:36: Error: Undefined name 'the'.
The "instance" getter on the ServicesBinding binding mixin is only available once that binding has been initialized.
^^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:311:40: Error: Undefined name 'ServicesBinding'.
The "instance" getter on the ServicesBinding binding mixin is only available once that binding has been initialized.
^^^^^^^^^^^^^^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:311:56: Error: Undefined name 'binding'.
The "instance" getter on the ServicesBinding binding mixin is only available once that binding has been initialized.
^^^^^^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:311:78: Error: Undefined name 'available'.
The "instance" getter on the ServicesBinding binding mixin is only available once that binding has been initialized.
^^^^^^^^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:311:88: Error: Undefined name 'once'.
The "instance" getter on the ServicesBinding binding mixin is only available once that binding has been initialized.
^^^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:311:93: Error: Undefined name 'that'.
The "instance" getter on the ServicesBinding binding mixin is only available once that binding has been initialized.
^^^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:311:98: Error: Undefined name 'binding'.
The "instance" getter on the ServicesBinding binding mixin is only available once that binding has been initialized.
^^^^^^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:311:106: Error: Undefined name 'has'.
The "instance" getter on the ServicesBinding binding mixin is only available once that binding has been initialized.
^^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:311:110: Error: Undefined name 'been'.
The "instance" getter on the ServicesBinding binding mixin is only available once that binding has been initialized.
^^^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:312:35: Error: Undefined name 'by'.
Typically, this is done by calling "WidgetsFlutterBinding.ensureInitialized()"  or "runApp()" (the latter calls the former). Typically this call is done in the "void main()" method. The "ensureInitialized" method is idempotent; calling it multiple times is not harmful. After ca
^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:312:38: Error: Undefined name 'calling'.
Typically, this is done by calling "WidgetsFlutterBinding.ensureInitialized()" or "runApp()" (the latter calls the former). Typically this call is done in the "void main()" method. The "ensureInitialized" method is idempotent; calling it multiple times is not harmful. After ca
^^^^^^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:312:90: Error: Undefined name 'or'.
Typically, this is done by calling "WidgetsFlutterBinding.ensureInitialized()" or "runApp()" (the latter calls the former). Typically this call is done in the "void main()" method. The "ensureInitialized" method is idempotent; calling it multiple times is not harmful. After ca
^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:312:145: Error: Expected identifier, but got 'this'.
Typically, this is done by calling "WidgetsFlutterBinding.ensureInitialized()" or "runApp()" (the latter calls the former). Typically this call is done in the "void main()" method. The "ensureInitialized" method is idempotent; calling it multiple times is not harmful. After ca
^^^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:312:163: Error: Undefined name 'in'.
Typically, this is done by calling "WidgetsFlutterBinding.ensureInitialized()" or "runApp()" (the latter calls the former). Typically this call is done in the "void main()" method. The "ensureInitialized" method is idempotent; calling it multiple times is not harmful. After ca
^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:312:166: Error: Undefined name 'the'.
Typically, this is done by calling "WidgetsFlutterBinding.ensureInitialized()" or "runApp()" (the latter calls the former). Typically this call is done in the "void main()" method. The "ensureInitialized" method is idempotent; calling it multiple times is not harmful. After ca
^^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:310:24: Error: Too many positional arguments: 1 allowed, but 34 found.
Try removing the extra positional arguments.
FlutterError (Binding has not yet been initialized.
^
../../flutter/packages/flutter/lib/src/foundation/assertions.dart:789:11: Context: Found this candidate, but the arguments don't match.
factory FlutterError(String message) {
^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:309:23: Error: Too many positional arguments: 1 allowed, but 2 found.
Try removing the extra positional arguments.
ErrorSummary('Binding has not yet been iException has occurred.Exception has occurred.
^
../../flutter/packages/flutter/lib/src/foundation/assertions.dart:311:3: Context: Found this candidate, but the arguments don't match.
ErrorSummary(super.message) : super(level: DiagnosticLevel.summary);
^^^^^^^^^^^^
../../flutter/packages/flutter/lib/src/foundation/binding.dart:312:236: Error: Expected ']' before this.
Typically, this is done by calling "WidgetsFlutterBinding.ensureInitialized()" or "runApp()" (the latter calls the former). Typically this call is done in the "void main()" method. The "ensureInitialized" method is idempotent; calling it multiple times is not harmful.  After ca
^
Target kernel_snapshot failed: Exception

FAILURE: Build failed with an exception.

* Where:
Script 'C:\Users\kaust\OneDrive\Documents\Flutter\flutter\packages\flutter_tools\gradle\src\main\groovy\flutter.groovy' line: 1297

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\Users\kaust\OneDrive\Documents\Flutter\flutter\bin\flutter.bat'' finished with non-zero exit value 1

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 6s
Exception: Gradle task assembleDebug failed with exit code 1

Exited (1).

Будем благодарны за любую помощь.
Как уже говорилось, WidgetsFlutterBinding.ensureInitialized() не работает.
Я не уверен, поможет ли это, но я попытался запустить следующую команду gradle:

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

cd android
./gradlew build --warning-mode all
и получите следующий вывод в терминале:

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

> Task :gradle:compileGroovy FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':gradle:compileGroovy'.
> BUG! exception in phase 'semantic analysis' in source unit 'C:\Users\kaust\OneDrive\Documents\Flutter\flutter\packages\flutter_tools\gradle\src\main\groovy\flutter.groovy' Unsupported class file major version 64

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 8s
2 actionable tasks: 1 executed, 1 up-to-date
Что меня больше всего беспокоит, так это то, что теперь ни один из моих проектов Flutter не работает и все показывают одну и ту же ошибку, даже те, к которым не подключена Firebase. На данный момент я даже не уверен, является ли это проблемой с Firebase или чем-то еще.
Я не знаю, как это интерпретировать, но надеюсь, что кто-то более знающий, чем я, поможет мне понять.

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

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

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

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

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

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

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