添加集成测试flutter包时的依赖问题
Dependency issue when adding integration test flutter package
我正在尝试将以下包添加到 pubspec.yml:
integration_test: ^1.0.1
当我执行 flutter pub get
命令时,在输出终端中打印以下内容:
Because no versions of uuid match >3.0.4 <4.0.0 and uuid 3.0.4 depends on crypto ^3.0.0, uuid ^3.0.4 requires crypto ^3.0.0.
And because every version of integration_test depends on flutter_driver any from sdk which depends on crypto 2.1.5, uuid ^3.0.4 is incompatible with integration_test.
So, because BOTS depends on both uuid ^3.0.4 and integration_test ^1.0.1, version solving failed.
pub get failed (1; So, because BOTS depends on both uuid ^3.0.4 and integration_test ^1.0.1, version solving failed.)
exit code 1
我试图通过将以下内容添加到我的 pubspec.yml 文件来修复它:
dependency_overrides:
crypto: ^3.0.0
archive: ^3.0.0
markdown: ^4.0.0
args: ^2.0.0
但不确定这是否是最佳方法。当我在我的项目中添加这个依赖项和覆盖时,我在执行时得到一个 Java 异常:
flutter run --release --flavor prod
看起来像:
E/AndroidRuntime(18685): java.lang.NoSuchMethodError: No interface method a()Ljava/lang/String; in class Landroid/content/res/XmlResourceParser; or its super classes (declaration of 'android.content.res.XmlResourceParser' appears in /system/framework/framework.jar)
E/AndroidRuntime(18685): at androidx.core.content.FileProvider.parsePathStrategy()
E/AndroidRuntime(18685): at androidx.core.content.FileProvider.getPathStrategy()
E/AndroidRuntime(18685): at androidx.core.content.FileProvider.attachInfo()
E/AndroidRuntime(18685): at android.app.ActivityThread.installProvider(ActivityThread.java:5852)
E/AndroidRuntime(18685): at android.app.ActivityThread.installContentProviders(ActivityThread.java:5444)
E/AndroidRuntime(18685): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5383)
E/AndroidRuntime(18685): at android.app.ActivityThread.-wrap2(ActivityThread.java)
E/AndroidRuntime(18685): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1541)
E/AndroidRuntime(18685): at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime(18685): at android.os.Looper.loop(Looper.java:154)
E/AndroidRuntime(18685): at android.app.ActivityThread.main(ActivityThread.java:6123)
E/AndroidRuntime(18685): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(18685): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
E/AndroidRuntime(18685): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757)
不获取异常的唯一方法是删除 integration_test 依赖项。
如何正确添加此依赖项?
消息告诉您:uuid: ^3.0.4
和 integration_test: ^1.0.1
不兼容,因为它们依赖于同一包的不同版本。
一个解决方案是降低 uuid
的版本直到它工作,但是如果你有其他依赖于 uuid
传递的包,它们可能会崩溃。
另一种是使用捆绑的integration_test
包。您会注意到,在 integration_test
的发布页面上,它表示它已被弃用:https://pub.dev/packages/integration_test
这是因为它已被移入 Flutter SDK,因为它现在是首选的集成测试包。
要使用捆绑版本,您应该将其包含在您的 dev_dependencies
中,例如:
integration_test:
sdk: flutter
但是,捆绑版本可能仍然与 uuid: ^3.0.4
不兼容。
要解决此问题,您需要确保您使用的是 Flutter 2。2.X
我正在尝试将以下包添加到 pubspec.yml:
integration_test: ^1.0.1
当我执行 flutter pub get
命令时,在输出终端中打印以下内容:
Because no versions of uuid match >3.0.4 <4.0.0 and uuid 3.0.4 depends on crypto ^3.0.0, uuid ^3.0.4 requires crypto ^3.0.0.
And because every version of integration_test depends on flutter_driver any from sdk which depends on crypto 2.1.5, uuid ^3.0.4 is incompatible with integration_test.
So, because BOTS depends on both uuid ^3.0.4 and integration_test ^1.0.1, version solving failed.
pub get failed (1; So, because BOTS depends on both uuid ^3.0.4 and integration_test ^1.0.1, version solving failed.)
exit code 1
我试图通过将以下内容添加到我的 pubspec.yml 文件来修复它:
dependency_overrides:
crypto: ^3.0.0
archive: ^3.0.0
markdown: ^4.0.0
args: ^2.0.0
但不确定这是否是最佳方法。当我在我的项目中添加这个依赖项和覆盖时,我在执行时得到一个 Java 异常:
flutter run --release --flavor prod
看起来像:
E/AndroidRuntime(18685): java.lang.NoSuchMethodError: No interface method a()Ljava/lang/String; in class Landroid/content/res/XmlResourceParser; or its super classes (declaration of 'android.content.res.XmlResourceParser' appears in /system/framework/framework.jar)
E/AndroidRuntime(18685): at androidx.core.content.FileProvider.parsePathStrategy()
E/AndroidRuntime(18685): at androidx.core.content.FileProvider.getPathStrategy()
E/AndroidRuntime(18685): at androidx.core.content.FileProvider.attachInfo()
E/AndroidRuntime(18685): at android.app.ActivityThread.installProvider(ActivityThread.java:5852)
E/AndroidRuntime(18685): at android.app.ActivityThread.installContentProviders(ActivityThread.java:5444)
E/AndroidRuntime(18685): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5383)
E/AndroidRuntime(18685): at android.app.ActivityThread.-wrap2(ActivityThread.java)
E/AndroidRuntime(18685): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1541)
E/AndroidRuntime(18685): at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime(18685): at android.os.Looper.loop(Looper.java:154)
E/AndroidRuntime(18685): at android.app.ActivityThread.main(ActivityThread.java:6123)
E/AndroidRuntime(18685): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(18685): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
E/AndroidRuntime(18685): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757)
不获取异常的唯一方法是删除 integration_test 依赖项。
如何正确添加此依赖项?
消息告诉您:uuid: ^3.0.4
和 integration_test: ^1.0.1
不兼容,因为它们依赖于同一包的不同版本。
一个解决方案是降低 uuid
的版本直到它工作,但是如果你有其他依赖于 uuid
传递的包,它们可能会崩溃。
另一种是使用捆绑的integration_test
包。您会注意到,在 integration_test
的发布页面上,它表示它已被弃用:https://pub.dev/packages/integration_test
这是因为它已被移入 Flutter SDK,因为它现在是首选的集成测试包。
要使用捆绑版本,您应该将其包含在您的 dev_dependencies
中,例如:
integration_test:
sdk: flutter
但是,捆绑版本可能仍然与 uuid: ^3.0.4
不兼容。
要解决此问题,您需要确保您使用的是 Flutter 2。2.X