Detox: Detox doesn't work with React-Native 0.59 on Android
Describe the bug After upgrading React Native to version 0.59 detox fails compiling the Android project. The standalone Android project builds and works ok when not using detox. The output of the build process is the following:
> Task :detox:compileMinReactNative44DebugRenderscript FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all files for configuration ':detox:minReactNative44DebugCompileClasspath'.
...
The full error output continues for a while (and is pasted at the end of this issue).
It looks like react native 0.59 upgraded many android libraries to newer versions, and the resolution in the detox project is failing for the following libraries:
- com.google.code.findbugs:jsr305:2.0.1
- com.squareup.okhttp3:okhttp:3.4.1
- com.squareup.okio:okio:1.9.0
In all those cases the version provided by React Native is newer than the one being used by detox or any of its dependencies.
To Reproduce Upgrade a working project to RN 0.59, and build any android configuration. Ex:
detox build -c android.emu.debug
Expected behavior Detox should work with newer react native version
Environment (please complete the following information):
- Detox: 11.0.0
- React Native: 0.59.0
- Node: v8.15.0
- Device: Android Emulator Nexus_5X_API_28
- OS: Android
Device and Verbose Detox Logs
yarn run v1.13.0
$ yarn test:android:debug:build && yarn test:android:debug:test --watch
$ detox build -c android.emu.debug
cd android && ENVFILE=.env.e2e ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug && cd ..
> Configure project :app
Reading env from: .env.e2e
> Configure project :react-native-reanimated
WARNING: API 'variant.getJavaCompile()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variant.getJavaCompile(), use -Pandroid.debug.obsoleteApi=true on the command line to display a stack trace.
> Task :detox:compileMinReactNative44DebugRenderscript FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all files for configuration ':detox:minReactNative44DebugCompileClasspath'.
> Could not resolve com.google.code.findbugs:jsr305:2.0.1.
Required by:
project :detox
> Cannot find a version of 'com.google.code.findbugs:jsr305' that satisfies the version constraints:
Dependency path 'Happy:detox:unspecified' --> 'androidx.test.espresso:espresso-core:3.1.1' --> 'com.google.code.findbugs:jsr305:2.0.1'
Dependency path 'Happy:detox:unspecified' --> 'com.facebook.react:react-native:0.59.0' --> 'com.google.code.findbugs:jsr305:3.0.2'
Dependency path 'Happy:detox:unspecified' --> 'com.facebook.react:react-native:0.59.0' --> 'com.facebook.infer.annotation:infer-annotation:0.11.2' --> 'com.google.code.findbugs:jsr305:3.0.1'
Constraint path 'Happy:detox:unspecified' --> 'com.google.code.findbugs:jsr305' strictly '2.0.1' because of the following reason: minReactNative44DebugRuntimeClasspath uses version 2.0.1
Constraint path 'Happy:detox:unspecified' --> 'com.google.code.findbugs:jsr305' strictly '2.0.1' because of the following reason: minReactNative44DebugRuntimeClasspath uses version 2.0.1
> Could not resolve com.squareup.okhttp3:okhttp:3.4.1.
Required by:
project :detox
> Cannot find a version of 'com.squareup.okhttp3:okhttp' that satisfies the version constraints:
Dependency path 'Happy:detox:unspecified' --> 'com.squareup.okhttp3:okhttp:3.4.1'
Constraint path 'Happy:detox:unspecified' --> 'com.squareup.okhttp3:okhttp' strictly '3.4.1' because of the following reason: minReactNative44DebugRuntimeClasspath uses version 3.4.1
Dependency path 'Happy:detox:unspecified' --> 'com.squareup.okhttp3:okhttp:3.4.1'
Constraint path 'Happy:detox:unspecified' --> 'com.squareup.okhttp3:okhttp' strictly '3.4.1' because of the following reason: minReactNative44DebugRuntimeClasspath uses version 3.4.1
Dependency path 'Happy:detox:unspecified' --> 'com.squareup.okhttp3:okhttp:3.4.1'
Constraint path 'Happy:detox:unspecified' --> 'com.squareup.okhttp3:okhttp' strictly '3.4.1' because of the following reason: minReactNative44DebugRuntimeClasspath uses version 3.4.1
Dependency path 'Happy:detox:unspecified' --> 'com.squareup.okhttp3:okhttp:3.4.1'
Dependency path 'Happy:detox:unspecified' --> 'com.facebook.react:react-native:0.59.0' --> 'com.squareup.okhttp3:okhttp:3.12.1'
Dependency path 'Happy:detox:unspecified' --> 'com.squareup.okhttp3:okhttp-ws:3.4.1' --> 'com.squareup.okhttp3:okhttp:3.4.1'
Dependency path 'Happy:detox:unspecified' --> 'com.facebook.react:react-native:0.59.0' --> 'com.facebook.fresco:imagepipeline-okhttp3:1.10.0' --> 'com.squareup.okhttp3:okhttp:3.10.0'
Dependency path 'Happy:detox:unspecified' --> 'com.facebook.react:react-native:0.59.0' --> 'com.squareup.okhttp3:okhttp-urlconnection:3.12.1' --> 'com.squareup.okhttp3:okhttp:3.12.1'
> Could not resolve com.squareup.okio:okio:1.9.0.
Required by:
project :detox
> Cannot find a version of 'com.squareup.okio:okio' that satisfies the version constraints:
Dependency path 'Happy:detox:unspecified' --> 'com.facebook.react:react-native:0.59.0' --> 'com.squareup.okio:okio:1.15.0'
Dependency path 'Happy:detox:unspecified' --> 'com.squareup.okhttp3:okhttp:3.12.1' --> 'com.squareup.okio:okio:1.15.0'
Dependency path 'Happy:detox:unspecified' --> 'com.facebook.react:react-native:0.59.0' --> 'com.squareup.okhttp3:okhttp:3.12.1' --> 'com.squareup.okio:okio:1.15.0'
Constraint path 'Happy:detox:unspecified' --> 'com.squareup.okio:okio' strictly '1.9.0' because of the following reason: minReactNative44DebugRuntimeClasspath uses version 1.9.0
Constraint path 'Happy:detox:unspecified' --> 'com.squareup.okio:okio' strictly '1.9.0' because of the following reason: minReactNative44DebugRuntimeClasspath uses version 1.9.0
> Could not resolve com.squareup.okhttp3:okhttp:3.4.1.
Required by:
project :detox
project :detox > com.squareup.okhttp3:okhttp-ws:3.4.1
> Cannot find a version of 'com.squareup.okhttp3:okhttp' that satisfies the version constraints:
Dependency path 'Happy:detox:unspecified' --> 'com.squareup.okhttp3:okhttp:3.4.1'
Constraint path 'Happy:detox:unspecified' --> 'com.squareup.okhttp3:okhttp' strictly '3.4.1' because of the following reason: minReactNative44DebugRuntimeClasspath uses version 3.4.1
Dependency path 'Happy:detox:unspecified' --> 'com.squareup.okhttp3:okhttp:3.4.1'
Constraint path 'Happy:detox:unspecified' --> 'com.squareup.okhttp3:okhttp' strictly '3.4.1' because of the following reason: minReactNative44DebugRuntimeClasspath uses version 3.4.1
Dependency path 'Happy:detox:unspecified' --> 'com.squareup.okhttp3:okhttp:3.4.1'
Constraint path 'Happy:detox:unspecified' --> 'com.squareup.okhttp3:okhttp' strictly '3.4.1' because of the following reason: minReactNative44DebugRuntimeClasspath uses version 3.4.1
Dependency path 'Happy:detox:unspecified' --> 'com.squareup.okhttp3:okhttp:3.4.1'
Dependency path 'Happy:detox:unspecified' --> 'com.facebook.react:react-native:0.59.0' --> 'com.squareup.okhttp3:okhttp:3.12.1'
Dependency path 'Happy:detox:unspecified' --> 'com.squareup.okhttp3:okhttp-ws:3.4.1' --> 'com.squareup.okhttp3:okhttp:3.4.1'
Dependency path 'Happy:detox:unspecified' --> 'com.facebook.react:react-native:0.59.0' --> 'com.facebook.fresco:imagepipeline-okhttp3:1.10.0' --> 'com.squareup.okhttp3:okhttp:3.10.0'
Dependency path 'Happy:detox:unspecified' --> 'com.facebook.react:react-native:0.59.0' --> 'com.squareup.okhttp3:okhttp-urlconnection:3.12.1' --> 'com.squareup.okhttp3:okhttp:3.12.1'
> Could not resolve com.google.code.findbugs:jsr305:2.0.1.
Required by:
project :detox > androidx.test.espresso:espresso-core:3.1.1
> Cannot find a version of 'com.google.code.findbugs:jsr305' that satisfies the version constraints:
Dependency path 'Happy:detox:unspecified' --> 'androidx.test.espresso:espresso-core:3.1.1' --> 'com.google.code.findbugs:jsr305:2.0.1'
Dependency path 'Happy:detox:unspecified' --> 'com.facebook.react:react-native:0.59.0' --> 'com.google.code.findbugs:jsr305:3.0.2'
Dependency path 'Happy:detox:unspecified' --> 'com.facebook.react:react-native:0.59.0' --> 'com.facebook.infer.annotation:infer-annotation:0.11.2' --> 'com.google.code.findbugs:jsr305:3.0.1'
Constraint path 'Happy:detox:unspecified' --> 'com.google.code.findbugs:jsr305' strictly '2.0.1' because of the following reason: minReactNative44DebugRuntimeClasspath uses version 2.0.1
Constraint path 'Happy:detox:unspecified' --> 'com.google.code.findbugs:jsr305' strictly '2.0.1' because of the following reason: minReactNative44DebugRuntimeClasspath uses version 2.0.1
> Could not resolve com.google.code.findbugs:jsr305:3.0.2.
Required by:
project :detox > com.facebook.react:react-native:0.59.0
> Cannot find a version of 'com.google.code.findbugs:jsr305' that satisfies the version constraints:
Dependency path 'Happy:detox:unspecified' --> 'androidx.test.espresso:espresso-core:3.1.1' --> 'com.google.code.findbugs:jsr305:2.0.1'
Dependency path 'Happy:detox:unspecified' --> 'com.facebook.react:react-native:0.59.0' --> 'com.google.code.findbugs:jsr305:3.0.2'
Dependency path 'Happy:detox:unspecified' --> 'com.facebook.react:react-native:0.59.0' --> 'com.facebook.infer.annotation:infer-annotation:0.11.2' --> 'com.google.code.findbugs:jsr305:3.0.1'
Constraint path 'Happy:detox:unspecified' --> 'com.google.code.findbugs:jsr305' strictly '2.0.1' because of the following reason: minReactNative44DebugRuntimeClasspath uses version 2.0.1
Constraint path 'Happy:detox:unspecified' --> 'com.google.code.findbugs:jsr305' strictly '2.0.1' because of the following reason: minReactNative44DebugRuntimeClasspath uses version 2.0.1
> Could not resolve com.squareup.okhttp3:okhttp:3.12.1.
Required by:
project :detox > com.facebook.react:react-native:0.59.0
project :detox > com.facebook.react:react-native:0.59.0 > com.squareup.okhttp3:okhttp-urlconnection:3.12.1
> Cannot find a version of 'com.squareup.okhttp3:okhttp' that satisfies the version constraints:
Dependency path 'Happy:detox:unspecified' --> 'com.squareup.okhttp3:okhttp:3.4.1'
Constraint path 'Happy:detox:unspecified' --> 'com.squareup.okhttp3:okhttp' strictly '3.4.1' because of the following reason: minReactNative44DebugRuntimeClasspath uses version 3.4.1
Dependency path 'Happy:detox:unspecified' --> 'com.squareup.okhttp3:okhttp:3.4.1'
Constraint path 'Happy:detox:unspecified' --> 'com.squareup.okhttp3:okhttp' strictly '3.4.1' because of the following reason: minReactNative44DebugRuntimeClasspath uses version 3.4.1
Dependency path 'Happy:detox:unspecified' --> 'com.squareup.okhttp3:okhttp:3.4.1'
Constraint path 'Happy:detox:unspecified' --> 'com.squareup.okhttp3:okhttp' strictly '3.4.1' because of the following reason: minReactNative44DebugRuntimeClasspath uses version 3.4.1
Dependency path 'Happy:detox:unspecified' --> 'com.squareup.okhttp3:okhttp:3.4.1'
Dependency path 'Happy:detox:unspecified' --> 'com.facebook.react:react-native:0.59.0' --> 'com.squareup.okhttp3:okhttp:3.12.1'
Dependency path 'Happy:detox:unspecified' --> 'com.squareup.okhttp3:okhttp-ws:3.4.1' --> 'com.squareup.okhttp3:okhttp:3.4.1'
Dependency path 'Happy:detox:unspecified' --> 'com.facebook.react:react-native:0.59.0' --> 'com.facebook.fresco:imagepipeline-okhttp3:1.10.0' --> 'com.squareup.okhttp3:okhttp:3.10.0'
Dependency path 'Happy:detox:unspecified' --> 'com.facebook.react:react-native:0.59.0' --> 'com.squareup.okhttp3:okhttp-urlconnection:3.12.1' --> 'com.squareup.okhttp3:okhttp:3.12.1'
> Could not resolve com.squareup.okio:okio:1.15.0.
Required by:
project :detox > com.facebook.react:react-native:0.59.0
project :detox > com.squareup.okhttp3:okhttp:3.12.1
> Cannot find a version of 'com.squareup.okio:okio' that satisfies the version constraints:
Dependency path 'Happy:detox:unspecified' --> 'com.facebook.react:react-native:0.59.0' --> 'com.squareup.okio:okio:1.15.0'
Dependency path 'Happy:detox:unspecified' --> 'com.squareup.okhttp3:okhttp:3.12.1' --> 'com.squareup.okio:okio:1.15.0'
Dependency path 'Happy:detox:unspecified' --> 'com.facebook.react:react-native:0.59.0' --> 'com.squareup.okhttp3:okhttp:3.12.1' --> 'com.squareup.okio:okio:1.15.0'
Constraint path 'Happy:detox:unspecified' --> 'com.squareup.okio:okio' strictly '1.9.0' because of the following reason: minReactNative44DebugRuntimeClasspath uses version 1.9.0
Constraint path 'Happy:detox:unspecified' --> 'com.squareup.okio:okio' strictly '1.9.0' because of the following reason: minReactNative44DebugRuntimeClasspath uses version 1.9.0
> Could not resolve com.google.code.findbugs:jsr305:3.0.1.
Required by:
project :detox > com.facebook.react:react-native:0.59.0 > com.facebook.infer.annotation:infer-annotation:0.11.2
> Cannot find a version of 'com.google.code.findbugs:jsr305' that satisfies the version constraints:
Dependency path 'Happy:detox:unspecified' --> 'androidx.test.espresso:espresso-core:3.1.1' --> 'com.google.code.findbugs:jsr305:2.0.1'
Dependency path 'Happy:detox:unspecified' --> 'com.facebook.react:react-native:0.59.0' --> 'com.google.code.findbugs:jsr305:3.0.2'
Dependency path 'Happy:detox:unspecified' --> 'com.facebook.react:react-native:0.59.0' --> 'com.facebook.infer.annotation:infer-annotation:0.11.2' --> 'com.google.code.findbugs:jsr305:3.0.1'
Constraint path 'Happy:detox:unspecified' --> 'com.google.code.findbugs:jsr305' strictly '2.0.1' because of the following reason: minReactNative44DebugRuntimeClasspath uses version 2.0.1
Constraint path 'Happy:detox:unspecified' --> 'com.google.code.findbugs:jsr305' strictly '2.0.1' because of the following reason: minReactNative44DebugRuntimeClasspath uses version 2.0.1
> Could not resolve com.squareup.okhttp3:okhttp:3.10.0.
Required by:
project :detox > com.facebook.react:react-native:0.59.0 > com.facebook.fresco:imagepipeline-okhttp3:1.10.0
> Cannot find a version of 'com.squareup.okhttp3:okhttp' that satisfies the version constraints:
Dependency path 'Happy:detox:unspecified' --> 'com.squareup.okhttp3:okhttp:3.4.1'
Constraint path 'Happy:detox:unspecified' --> 'com.squareup.okhttp3:okhttp' strictly '3.4.1' because of the following reason: minReactNative44DebugRuntimeClasspath uses version 3.4.1
Dependency path 'Happy:detox:unspecified' --> 'com.squareup.okhttp3:okhttp:3.4.1'
Constraint path 'Happy:detox:unspecified' --> 'com.squareup.okhttp3:okhttp' strictly '3.4.1' because of the following reason: minReactNative44DebugRuntimeClasspath uses version 3.4.1
Dependency path 'Happy:detox:unspecified' --> 'com.squareup.okhttp3:okhttp:3.4.1'
Constraint path 'Happy:detox:unspecified' --> 'com.squareup.okhttp3:okhttp' strictly '3.4.1' because of the following reason: minReactNative44DebugRuntimeClasspath uses version 3.4.1
Dependency path 'Happy:detox:unspecified' --> 'com.squareup.okhttp3:okhttp:3.4.1'
Dependency path 'Happy:detox:unspecified' --> 'com.facebook.react:react-native:0.59.0' --> 'com.squareup.okhttp3:okhttp:3.12.1'
Dependency path 'Happy:detox:unspecified' --> 'com.squareup.okhttp3:okhttp-ws:3.4.1' --> 'com.squareup.okhttp3:okhttp:3.4.1'
Dependency path 'Happy:detox:unspecified' --> 'com.facebook.react:react-native:0.59.0' --> 'com.facebook.fresco:imagepipeline-okhttp3:1.10.0' --> 'com.squareup.okhttp3:okhttp:3.10.0'
Dependency path 'Happy:detox:unspecified' --> 'com.facebook.react:react-native:0.59.0' --> 'com.squareup.okhttp3:okhttp-urlconnection:3.12.1' --> 'com.squareup.okhttp3:okhttp:3.12.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 2s
135 actionable tasks: 1 executed, 134 up-to-date
child_process.js:650
throw err;
^
Error: Command failed: cd android && ENVFILE=.env.e2e ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug && cd ..
at checkExecSyncError (child_process.js:607:13)
at Object.execSync (child_process.js:647:13)
at Object.<anonymous> (/Users/elyalvarado/Workspace/Happy/HappyRN/node_modules/detox/local-cli/detox-build.js:26:6)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Function.Module.runMain (module.js:694:10)
at startup (bootstrap_node.js:204:16)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 15
- Comments: 38 (4 by maintainers)
For those of you using
patch-package
, here’s the patch file:@d4vidi With Detox
12.1.3
it works on ReactNative 0.59.3 without the need of making any changes in detox’sbuild.gradle
. Great work from you @d4vidi fixing it, and from all the community that participated in finding a work-around while it was fixed.Just for protocol I managed to get my app to build on .59 with detox 12 by changing /node_modules/detox/android/detox/build.gradle
to
and
to the android block
I was able to patch this by going into the
node_modules/detox/android/detox/build.gradle
file, and manually updating those deps:The
jsr305
one is a bit nasty, because that’s from a deeper dependency. I fix that by forcing the right version in theandroid
section of that same file:Facing the same errors here with RN 0.59.1. I’ve pretty much the same environment:
Environment:
Please give the latest Detox -
12.1.3
a try with this one. Follow the migration guide as needed.I have RN 0.59.2 and Detox 12.1.1 the following patch to detox (based on @kbrandwijk suggestions) makes it work for me:
I don’t want the hassle of having to keep a fork up to date, so I’m using patch-package to automatically apply the same patch on any upgrade, keep it in version control, and avoid yarn removing my patch. I highly recommend it for this cases.
If anybody wants to apply this patch manually and check if it works, you can copy and paste the content of the patch into a file (
/tmp/detox+12.1.1.patch
) and then run the following command in your project folder:I’m still having the described issue on detox 11.0.2 and RN 0.59.1
detox 11.0.2
Redoing what https://github.com/wix/Detox/issues/1208#issuecomment-473874358 says, but for detox 11.0.2 made these errors go away for me (until react native changes the versions again).
The:
…mentioned in https://github.com/wix/Detox/issues/1208#issuecomment-474253424 sounds like the kind of thing that should work here, but doesn’t. One problem I can see is that the “implementation” is for the app, not test code. If replace “implementation” with “androidTestImplementation” still get version conflicts for the same three libraries.
This is for detox 11.0.2.
In any case, we’re still partly stuck due to the RN issue I’ve mentioned. Please help us out by upvoting 😃
@elyalvarado sorry, I’ve somehow had that overlooked.
Please try the following:
11.0.1
is out – please upgrade! This is important since we got rid of the build flavors 🎉build.gradle
:A bit nasty but it oughta do it.
FYI: Selecting the correct build flavor does not prevent these errors. If a build flavor is present, it’s dependency constraints are taken into account. That’s why I actually had to comment out the other one to even make it work.
@elyalvarado There are few things to consider in this context:
minReactNative46
and notminReactNative44
). On Android Studio, you can do so in theBuild Variants
tab. Otherwise you have to set up proper configuration for themissingDimensionStrategy
field (see Android guide).11.0.1
, so if your not in a hurry, hold it off for a day or twoSame thing here after upgrading to Detox 11.0.0