Search code examples
flutterfirebaseflutter-dependencies

Flutter firebase_auth and firebase_core depency errors


I am trying to run my old project after updating flutter sdk to the latest 3.10, but I am getting this error

my pubspec.yaml has the following dependencies

dependencies:
  firebase_auth:
  firebase_core:
  intl: ^0.18.1
  flutter_spinkit: ^5.1.0
  web_socket_channel: ^2.0.0
  flutter_native_splash: ^2.2.18
  firebase_database:
  fluttertoast: ^8.0.7
  shared_preferences: ^2.0.8 # Add this line
  url_launcher: ^6.0.0
  http: ^1.0.0
  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

dev_dependencies:
  flutter_launcher_icons: ^0.13.1
  flutter_test:
    sdk: flutter

  # The "flutter_lints" package below contains a set of recommended lints to
  # encourage good coding practices. The lint set provided by the package is
  # activated in the `analysis_options.yaml` file located at the root of your
  # package. See that file for information about deactivating specific lint
  # rules and activating additional ones.
  flutter_lints: ^2.0.0

dependency_overrides:
  firebase_core_platform_interface: 4.5.1

Running flutter doctor shows no issues.

This is the error message I'm getting:

../../AppData/Local/Pub/Cache/hosted/pub.dev/firebase_core-2.13.0/lib/src/firebase_app.dart:18:25: Error: Member not found: 'FirebaseAppPlatform.verify'.

FirebaseAppPlatform.verify(_delegate);
                    ^^^^^^

Target kernel_snapshot failed: Exception

FAILURE: Build failed with an exception.

  • Where:
    Script 'C:\src\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1201

  • What went wrong: Execution failed for task ':app:compileFlutterBuildDebug'. Process 'command 'C:\src\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 40s
Exception: Gradle task assembleDebug failed with exit code 1

I have tried running flutter upgrade but its not working as well.


Solution

  • Found a way to fix it

    firstly, make sure all dependencies' versions are not specified. Then run flutter pub get after this try to run the project and it should through a fullthroughError after this error has been thrown, open the action_code_info.dart and edit the 'ActionCodeInfo' it should look something like this ActionCodeInfoOperation get operation { switch (_operation) { case 0: return ActionCodeInfoOperation.unknown; case 1: return ActionCodeInfoOperation.passwordReset; case 2: return ActionCodeInfoOperation.verifyEmail; case 3: return ActionCodeInfoOperation.recoverEmail; case 4: return ActionCodeInfoOperation.emailSignIn; case 5: return ActionCodeInfoOperation.verifyAndChangeEmail; case 6: return ActionCodeInfoOperation.revertSecondFactorAddition; default: throw Exception(); // or throw UnsupportedError('FallThroughError'); } }

    Dart was throwing that error because FallThroughError was not defined, so by editing this file that comes with the package I managed to fix the runtime error and run the code Hope this really helps someone.