有没有什么方法可以将Firebase包放在同一个pubspec.yaml中,而不会在编译阶段产生版本冲突或错误

z31licg0  于 2023-08-07  发布在  其他
关注(0)|答案(1)|浏览(70)

什么是正确的SDK和正确的Firebase包版本来无错误地运行项目?

geoflutterfire: 
firebase_core: 
cloud_firestore: 
firebase_auth: 
firebase_storage: 
firebase_messaging:

字符串
像这样的错误

Because no versions of firebase_storage match >11.2.5 <12.0.0 and firebase_storage >=11.2.3 <11.2.5 depends on firebase_core ^2.14.0, firebase_storage >=11.2.3 <11.2.5-∞ or >11.2.5 <12.0.0 requires firebase_core ^2.14.0.
And because firebase_storage 11.2.5 depends on firebase_core ^2.15.0, firebase_storage ^11.2.3 requires firebase_core ^2.14.0.
So, because okleva depends on both firebase_core ^1.10.2 and firebase_storage ^11.2.4, version solving failed.
exit code 1


我搜索解决方案后,按照此链接的步骤。
https://iiro.dev/resolving-dart-package-version-conflicts/
我来吧

+2 ms]     FirebaseAppPlatform.verifyExtends(_delegate);
[        ]                         ^^^^^^^^^^^^^
[+7359 ms] [+13064 ms] ../../.pub-cache/hosted/pub.dev/firebase_core-1.24.0/lib/src/firebase_app.dart:18:25: Error: Member not found: 'FirebaseAppPlatform.verifyExtends'.
[   +5 ms] [   +3 ms]     FirebaseAppPlatform.verifyExtends(_delegate);
[        ] [        ]                         ^^^^^^^^^^^^^
[+1815 ms] ../../.pub-cache/hosted/pub.dev/firebase_auth_platform_interface-6.10.1/lib/src/action_code_info.dart:65:15: Error: The method 'FallThroughError' isn't defined for the class
'ActionCodeInfo'.
[        ]  - 'ActionCodeInfo' is from 'package:firebase_auth_platform_interface/src/action_code_info.dart'
('../../.pub-cache/hosted/pub.dev/firebase_auth_platform_interface-6.10.1/lib/src/action_code_info.dart').
[        ] Try correcting the name to the name of an existing method, or defining a method named 'FallThroughError'.
[        ]         throw FallThroughError();
[        ]               ^^^^^^^^^^^^^^^^
[+2819 ms] ../../.pub-cache/hosted/pub.dev/cloud_firestore_platform_interface-5.7.7/lib/src/platform_interface/utils/load_bundle_task_state.dart:13:13: Error: Method not found:
'FallThroughError'.
[        ]       throw FallThroughError();
[        ]             ^^^^^^^^^^^^^^^^
[+3952 ms] [+8641 ms] ../../.pub-cache/hosted/pub.dev/firebase_auth_platform_interface-6.10.1/lib/src/action_code_info.dart:65:15: Error: The method 'FallThroughError' isn't defined for the
class 'ActionCodeInfo'.
[   +1 ms] [        ]  - 'ActionCodeInfo' is from 'package:firebase_auth_platform_interface/src/action_code_info.dart'
('../../.pub-cache/hosted/pub.dev/firebase_auth_platform_interface-6.10.1/lib/src/action_code_info.dart').
[   +1 ms] [        ] Try correcting the name to the name of an existing method, or defining a method named 'FallThroughError'.
[        ] [        ]         throw FallThroughError();
[        ] [        ]               ^^^^^^^^^^^^^^^^
[+2892 ms] [+2925 ms] ../../.pub-cache/hosted/pub.dev/cloud_firestore_platform_interface-5.7.7/lib/src/platform_interface/utils/load_bundle_task_state.dart:13:13: Error: Method not found:
'FallThroughError'.
[   +2 ms] [        ]       throw FallThroughError();
[        ] [        ]             ^^^^^^^^^^^^^^^^
[+8205 ms] [+8152 ms] Persisting file store
[        ] [  +24 ms] Done persisting file store
[        ] [  +14 ms] "flutter assemble" took 35 170ms.
[        ] [   +5 ms] Target kernel_snapshot failed: Exception
[        ]            #0      KernelSnapshot.build (package:flutter_tools/src/build_system/targets/common.dart:244:7)
[        ]            <asynchronous suspension>
[        ]            #1      _BuildInstance._invokeInternal (package:flutter_tools/src/build_system/build_system.dart:847:9)
[        ]            <asynchronous suspension>
[        ]            #2      Future.wait.<anonymous closure> (dart:async/future.dart:525:21)
[        ]            <asynchronous suspension>
[        ]            #3      _BuildInstance.invokeTarget (package:flutter_tools/src/build_system/build_system.dart:785:32)
[        ]            <asynchronous suspension>
[        ]            #4      FlutterBuildSystem.build (package:flutter_tools/src/build_system/build_system.dart:614:16)
[        ]            <asynchronous suspension>
[        ]            #5      AssembleCommand.runCommand (package:flutter_tools/src/commands/assemble.dart:315:32)
[   +1 ms]            <asynchronous suspension>
[        ]            #6      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1336:27)
[        ]            <asynchronous suspension>
[        ]            #7      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
[        ]            <asynchronous suspension>
[        ]            #8      CommandRunner.runCommand (package:args/command_runner.dart:212:13)
[        ]            <asynchronous suspension>
[        ]            #9      FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:296:9)
[        ]            <asynchronous suspension>
[        ]            #10     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
[        ]            <asynchronous suspension>
[        ]            #11     FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:244:5)
[        ]            <asynchronous suspension>
[        ]            #12     run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:91:9)
[        ]            <asynchronous suspension>
[        ]            #13     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
[   +4 ms]            <asynchronous suspension>
[        ]            #14     main (package:flutter_tools/executable.dart:91:3)
[        ]            <asynchronous suspension>
[        ] [   +5 ms] 
[        ]            #0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
[        ]            #1      AssembleCommand.runCommand (package:flutter_tools/src/commands/assemble.dart:332:7)
[        ]            <asynchronous suspension>
[        ]            #2      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1336:27)
[        ]            <asynchronous suspension>
[        ]            #3      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
[        ]            <asynchronous suspension>
[        ]            #4      CommandRunner.runCommand (package:args/command_runner.dart:212:13)
[        ]            <asynchronous suspension>
[   +1 ms]            #5      FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:296:9)
[        ]            <asynchronous suspension>
[        ]            #6      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
[        ]            <asynchronous suspension>
[        ]            #7      FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:244:5)
[        ]            <asynchronous suspension>
[        ]            #8      run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:91:9)
[        ]            <asynchronous suspension>
[        ]            #9      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
[        ]            <asynchronous suspension>
[        ]            #10     main (package:flutter_tools/executable.dart:91:3)
[        ]            <asynchronous suspension>
[ +277 ms] [ +265 ms] ensureAnalyticsSent: 253ms
[        ] [        ] Running 0 shutdown hooks
[        ] [        ] Shutdown hooks complete
[        ] [        ] exiting with code 1
[ +195 ms] > Task :app:compileFlutterBuildDebug FAILED
[        ] :app:compileFlutterBuildDebug (Thread[Execution worker for ':',5,main]) completed. Took 37.052 secs.
[ +100 ms] FAILURE: Build failed with an exception.
[        ] * Where:
[        ] Script '/Users/benjamimgomes/Development/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 1201
[        ] * What went wrong:
[        ] Execution failed for task ':app:compileFlutterBuildDebug'.
[        ] > Process 'command '/Users/benjamimgomes/Development/flutter/bin/flutter'' finished with non-zero exit value 1
[        ] * Try:
[        ] > Run with --debug option to get more log output.
[        ] > Run with --scan to get full insights.
[        ] * Exception is:
[        ] org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:compileFlutterBuildDebug'.
[        ]      at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:147)
[        ]      at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:282)
[        ]      at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:145)
[   +2 ms]      at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:133)
[        ]      at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:77)
[        ]      at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
[        ]      at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:51)
[        ]      at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
[        ]      at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:56)
[        ]      at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
[        ]      at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:77)
[   +2 ms]      at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:55)
[        ]      at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
[        ]      at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:204)
[        ]      at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:199)
[        ]      at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
[        ]      at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
[        ]      at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)
[   +3 ms]      at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
[        ]      at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:53)
[        ]      at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:73)
[   +2 ms]      at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:52)
[   +1 ms]      at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:74)
[        ]      at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:333)
[   +1 ms]      at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:320)
[        ]      at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:313)
[   +1 ms]      at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:299)
[        ]      at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.lambda$run$0(DefaultPlanExecutor.java:143)
[        ]      at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:227)
[   +1 ms]      at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:218)
[  +73 ms]      at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:140)
[        ]      at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
[        ]      at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
[   +1 ms]      at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
[        ]      at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
[        ]      at java.base/java.lang.Thread.run(Unknown Source)
[        ] Caused by: org.gradle.process.internal.ExecException: Process 'command '/Users/benjamimgomes/Development/flutter/bin/flutter'' finished with non-zero exit value 1
[        ]      at org.gradle.process.internal.DefaultExecHandle$ExecResultImpl.assertNormalExitValue(DefaultExecHandle.java:414)
[        ]      at org.gradle.process.internal.DefaultExecAction.execute(DefaultExecAction.java:38)
[        ]      at org.gradle.process.internal.DefaultExecActionFactory.exec(DefaultExecActionFactory.java:205)
[        ]      at org.gradle.api.internal.project.DefaultProject.exec(DefaultProject.java:1170)
[        ]      at org.gradle.api.internal.project.DefaultProject.exec(DefaultProject.java:1165)
[        ]      at org.gradle.api.Project$exec$10.call(Unknown Source)
[        ]      at BaseFlutterTask.buildBundle(/Users/benjamimgomes/Development/flutter/packages/flutter_tools/gradle/flutter.gradle:1201)
[        ]      at BaseFlutterTask$buildBundle.callCurrent(Unknown Source)
[        ]      at FlutterTask.build(/Users/benjamimgomes/Development/flutter/packages/flutter_tools/gradle/flutter.gradle:1326)
[   +1 ms]      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[        ]      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
[        ]      at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
[        ]      at java.base/java.lang.reflect.Method.invoke(Unknown Source)
[        ]      at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:104)
[        ]      at org.gradle.api.internal.project.taskfactory.StandardTaskAction.doExecute(StandardTaskAction.java:58)
[        ]      at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:51)
[        ]      at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:29)
[        ]      at org.gradle.api.internal.tasks.execution.TaskExecution$3.run(TaskExecution.java:242)
[        ]      at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:29)
[        ]      at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:26)
[   +1 ms]      at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
[        ]      at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
[        ]      at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)
[        ]      at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
[        ]      at org.gradle.internal.operations.DefaultBuildOperationRunner.run(DefaultBuildOperationRunner.java:47)
[        ]      at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:68)
[        ]      at org.gradle.api.internal.tasks.execution.TaskExecution.executeAction(TaskExecution.java:227)
[        ]      at org.gradle.api.internal.tasks.execution.TaskExecution.executeActions(TaskExecution.java:210)
[        ]      at org.gradle.api.internal.tasks.execution.TaskExecution.executeWithPreviousOutputFiles(TaskExecution.java:193)
[        ]      at org.gradle.api.internal.tasks.execution.TaskExecution.execute(TaskExecution.java:171)
[        ]      at org.gradle.internal.execution.steps.ExecuteStep.executeInternal(ExecuteStep.java:89)
[        ]      at org.gradle.internal.execution.steps.ExecuteStep.access$000(ExecuteStep.java:40)
[   +1 ms]      at .execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:140)
[        ]      at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
[        ]      at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
[        ]      at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
[        ]      at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
[        ]      at java.base/java.lang.Thread.run(Unknown Source)
[        ] * Get more help at https://help.gradle.org
[        ] BUILD FAILED in 44s
[   +1 ms] 1 actionable task: 1 executed
[ +124 ms] Watched directory hierarchies: [/Users/benjamimgomes/Development/okleva/android]
[ +619 ms] Running Gradle task 'assembleDebug'... (completed in 45,4s)
[   +7 ms] Exception: Gradle task assembleDebug failed with exit code 1
[   +7 ms] "flutter run" took 54 677ms.
[   +6 ms] 
           #0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
           #1      RunCommand.runCommand (package:flutter_tools/src/commands/run.dart:757:9)
           <asynchronous suspension>
           #2      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1336:27)
           <asynchronous suspension>
           #3      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #4      CommandRunner.runCommand (package:args/command_runner.dart:212:13)
           <asynchronous suspension>
           #5      FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:296:9)
           <asynchronous suspension>
           #6      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #7      FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:244:5)
           <asynchronous suspension>
           #8      run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:91:9)
           <asynchronous suspension>
           #9      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #10     main (package:flutter_tools/executable.dart:91:3)


有没有办法把firebase包放在同一个pubspec.yaml中,而不会在编译阶段产生版本冲突或错误?

zmeyuzjn

zmeyuzjn1#

经过多次尝试。我找到了这个解决方案:
1.我做得很干净。
1.删除pubspec.lock

  1. flutter pub添加包
    注意:为了避免版本错误,我注意到一些软件包需要先安装,然后再安装其他软件包。这就是我的工作顺序。
  • 地动山摇
  • Firebase 型芯
  • 云火库
  • Firebase 储存
  • firebase_auth
  • firebase消息传递

与FirebaseAppPlatform相关的错误。verifyExtends(_delegate);我想这是因为我的lib文件夹上的项目文件是用其他版本的firebase软件包创建的。当我用默认的flutter main.dart文件替换所有的lib文件时,应用程序构建没有错误。因此,解决方案是使用用于创建lib文件的包版本覆盖firebase包。

dependencies:
    geoflutterfire: ^3.0.2
    firebase_core: ^1.24.0
    cloud_firestore: ^3.5.1
    firebase_storage: ^10.3.11
    firebase_auth: ^3.11.2
    firebase_messaging: ^13.1.0

  dependency_overrides:
    firebase_storage: ^11.2.4
    firebase_core: ^2.12.0
    cloud_firestore: ^4.7.0
    firebase_auth: ^4.6.0

字符串
此解决方案基于此答案https://stackoverflow.com/a/75330203/10296934
感谢Roopa M的帮助评论。

相关问题