I am trying to add the following package to pubspec.yml:

integration_test: ^1.0.1

And when I execute flutter pub get command the following is printed in the output terminal:

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

I tried to fix it by adding the following to my pubspec.yml file:

  crypto: ^3.0.0
  archive: ^3.0.0
  markdown: ^4.0.0
  args: ^2.0.0

But not sure if this is the best approach. When I add this dependencies and overrides in my project I get a Java exception when executing :

flutter run --release --flavor prod

Which looks like:

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)

And the only way of not getting that exception is removing integration_test dependency.

How can I correctly add this dependency ?

Solution 1: cameron1024

The message is telling you: uuid: ^3.0.4 and integration_test: ^1.0.1 are incompatible, because they depend on different versions of the same package.

One solution is to lower the version of uuid until it works, but if you have other packages that depend on uuid transitively they may break.

The other is to use the bundled integration_test package. You'll notice that on the pub page for integration_test, it says it is deprecated: https://pub.dev/packages/integration_test

This is because it has been moved into the Flutter SDK, given that it is now the preferred integration testing package.

To use the bundled version, you should include it in your dev_dependencies like:

  sdk: flutter

However, the bundled version may still be incompatible with uuid: ^3.0.4.

To fix this, you will need to make sure you are on Flutter 2.2.X