0

I've follow and setup exact like this guide for Android: https://github.com/wix/Detox/blob/master/docs/Introduction.Android.md this is my detox configuration in package.json :

"detox": {
    "configurations": {
      "android": {
        "binaryPath": "android/app/build/outputs/apk/release/app-release.apk",
        "build": "cd android && ./gradlew app:assembleRelease app:assembleAndroidTest -DtestBuildType=release && cd ..",
        "type": "android.emulator",
        "name": "Pixel_3a_XL_API_30"
      }
    },
    "test-runner": "jest",
    "behavior": {
      "init": {
        "launchApp": false
      },
      "cleanup": {
        "shutdownDevice": false
      }
    }
  }

and i'm using this commandline to build android:

react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/ && rm -rf android/app/src/main/res/raw/* && detox build -c android

After build, Android throw this exception:

react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/  && rm -rf android/app/src/main/res/raw/* && detox build -c android
warn The following packages use deprecated "rnpm" config that will stop working from next release:
  - react-native-orientation: https://github.com/yamill/react-native-orientation#readme
  - react-native-wheel-datepicker: https://github.com/pinguinjkeke/react-native-wheel-datepicker#readme
Please notify their maintainers about it. You can find more details at https://github.com/react-native-community/cli/blob/master/docs/configuration.md#migration-guide.
Loading dependency graph...warn The following packages use deprecated "rnpm" config that will stop working from next release:
  - react-native-orientation: https://github.com/yamill/react-native-orientation#readme
  - react-native-wheel-datepicker: https://github.com/pinguinjkeke/react-native-wheel-datepicker#readme
Please notify their maintainers about it. You can find more details at https://github.com/react-native-community/cli/blob/master/docs/configuration.md#migration-guide.
Loading dependency graph, done.
Loading dependency graph...info Writing bundle output to:, android/app/src/main/assets/index.android.bundle
info Done writing bundle output
info Copying 618 asset files
info Done copying assets
zsh: sure you want to delete all 16 files in /Users/baopn/Documents/bitbucket/academy-mobile/android/app/src/main/res/raw [yn]? y
detox[31002] INFO:  [build.js] cd android && ./gradlew app:assembleRelease app:assembleAndroidTest -DtestBuildType=release && cd ..
Configuration on demand is an incubating feature.

> Configure project :app
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)

> Configure project :react-native-wheel-datepicker
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html

> Configure project :react-native-orientation
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html

> Configure project :react-native-firebase
react-native-firebase: using React Native prebuilt binary from /Users/baopn/Documents/bitbucket/academy-mobile/node_modules/react-native/android

> Task :app:processReleaseGoogleServices
Parsing json file: /Users/baopn/Documents/bitbucket/academy-mobile/android/app/google-services.json

> Task :app:processReleaseManifest
/Users/baopn/Documents/bitbucket/academy-mobile/android/app/src/main/AndroidManifest.xml:15:9-25:20 Warning:
        provider#cl.json.RNShareFileProvider@android:authorities was tagged at AndroidManifest.xml:15 to replace other declarations but no other declaration present
/Users/baopn/Documents/bitbucket/academy-mobile/android/app/src/main/AndroidManifest.xml Warning:
        meta-data#android.support.FILE_PROVIDER_PATHS@android:resource was tagged at AndroidManifest.xml:0 to replace other declarations but no other declaration present
/Users/baopn/Documents/bitbucket/academy-mobile/android/app/src/main/AndroidManifest.xml:24:9-31:50 Warning:
        activity#com.google.firebase.auth.internal.FederatedSignInActivity@android:launchMode was tagged at AndroidManifest.xml:24 to replace other declarations but no other declaration present

> Task :app:transformResourcesWithMergeJavaResForReleaseAndroidTest FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformResourcesWithMergeJavaResForReleaseAndroidTest'.
> More than one file was found with OS independent path 'targetInvocationEspresso.json'

* 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

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.4.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 17s
541 actionable tasks: 10 executed, 531 up-to-date
detox[31002] ERROR: [cli.js] Error: Command failed: cd android && ./gradlew app:assembleRelease app:assembleAndroidTest -DtestBuildType=release && cd ..
  • Maybe this could help? - https://stackoverflow.com/questions/49423572/android-unable-to-build-apk-more-than-one-file-was-found-with-os-independent-p – d4vidi Aug 10 '20 at 09:54
  • I've tried but still nothing changes, as the exception is different – Pham Ngoc Bao Aug 10 '20 at 10:43
  • I now realize `targetInvocationEspresso.json` is a Detox resource. Could you double check that you've integrated Detox to your project (natively) as a non-compiling project (i.e. an `.aar`)? Use [this guide](https://github.com/wix/Detox/blob/master/docs/Introduction.Android.md) for reference – d4vidi Aug 11 '20 at 07:12
  • I've setup exact like the guide as mentioned before, the only thing i haven't mentioned is that i have added these detox libs in `package.json`: "detox": "^17.3.4", "detox-expo-helpers": "^0.6.0", "expo-detox-hook": "^1.0.10", – Pham Ngoc Bao Aug 12 '20 at 08:39
  • Could it be the reason to duplicate resources? @d4vidi – Pham Ngoc Bao Aug 12 '20 at 08:42
  • Might be. Can you try replicating onto a light app without expo and see? – d4vidi Aug 12 '20 at 14:39
  • I can delete them on my current project and re-test, but the issue occured anyway :( – Pham Ngoc Bao Aug 14 '20 at 02:40
  • > Task :detox:compileReleaseJavaWithJavac Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. > Task :app:transformResourcesWithMergeJavaResForReleaseAndroidTest FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:transformResourcesWithMergeJavaResForReleaseAndroidTest'. > More than one file was found with OS independent path 'targetInvocationEspresso.json' – Pham Ngoc Bao Aug 14 '20 at 02:40
  • @d4vidi can you please take a look? – Pham Ngoc Bao Aug 18 '20 at 02:44
  • Please try to set up an open demo app, I might be able to check it out there – d4vidi Aug 18 '20 at 08:13

1 Answers1

0

I faced the same problem then I discovered that I implemented the main approach and the alternate approach from the detox guide, which is difficult to spot. The alternate approach starts here https://github.com/wix/Detox/blob/master/docs/Introduction.Android.md#setting-detox-up-as-a-compiling-dependency

So just remove the extra steps in the alternate approach, then the detox build command will most likely work or you will face a different error. (I got another error and I fixed it by applying the answer from https://stackoverflow.com/a/58281958/311701, you already have the fix applied in your package.json detox build command)

Guy
  • 2,883
  • 1
  • 32
  • 39