Detox successfully builds but does not install app on Android emulator - react-native

I'm getting a successful detox build, and the emulator starts up, but the app is just never installed.
react-native run-android (without Detox) works fine.
The only error I'm seeing (including in verbose mode) is: "No instrumentation runner found", but I'm guessing that just means Detox can't find the app (which was never installed).
How can I get Detox to actually install the app onto the emulator? The only clue I see is that the package name has .test appended in this case which may be an issue, but I'm not at all sure of that.
(I tried to adb install the test app but that doesn't fix the issue, and also nothing shows up in the emulator when I run the command: adb -e install android/app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk. This installation command works fine for our standard debug apk.)
Log:
BUILD SUCCESSFUL in 25s
1029 actionable tasks: 1 executed, 1028 up-to-date
detox[66003] INFO: [test.js] configuration="android.emu.debug" reportSpecs=true readOnlyEmu=false useCustomLogger=true forceAdbInstall=false DETOX_START_TIMESTAMP=1597412615185 node_modules/.bin/jest --config e2e/config.json '--testNamePattern=^((?!:ios:).)*$' --maxWorkers 1 e2e
detox[66004] INFO: [DetoxServer.js] server listening on localhost:55217...
detox[66004] ERROR: Error: No instrumentation runner found on device emulator-11448 for package com.myco.myapp.test
detox[66004] INFO: Example is assigned to undefined
detox[66004] INFO: Example: should have welcome screen
detox[66004] INFO: Example: should have welcome screen [SKIPPED]
detox[66003] ERROR: [cli.js] Error: Command failed: node_modules/.bin/jest --config e2e/config.json '--testNamePattern=^((?!:ios:).)*$' --maxWorkers 1 e2e
detoxrc entry:
"android.emu.debug": {
"binaryPath": "android/app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk",
"testBinaryPath": "android/app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk",
"build": "cd android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug && cd ..",
"type": "android.emulator",
"device": {
"avdName": "Pixel_API_28_AOSP"
}
},

This had to do with APK paths. Detox tries to compute a debug APK path, and if it's wrong it will come up with these errors. (If you build multiple versions of your APKs for different architectures, Detox doesn't appear to be able to handle that.)
The solution is to point to both of your APKs - the debug app ("binary"), and the instrumentation APK ("test binary"):
"binaryPath": "android/app/build/outputs/apk/debug/app-x86_64-debug.apk",
"testBinaryPath": "android/app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk",

Related

(JS/react-native) How can I solve this error for building react-native app for iOS

Hey guys I'm so new to JS and react-native as well. I was trying to solve this error but I couldn't get it at all! meh
This is what I struggled :
error React Native CLI uses autolinking for native dependencies, but the following modules are linked manually:
- react-native-ble-plx (to unlink run: "react-native unlink react-native-ble-plx")
This is likely happening when upgrading React Native from below 0.60 to 0.60 or above. Going forward, you can unlink this dependency via "react-native unlink <dependency>" and it will be included in your app automatically. If a library isn't compatible with autolinking, disregard this message and notify the library maintainers.
Read more about autolinking: https://github.com/react-native-community/cli/blob/master/docs/autolinking.md
error Could not find the following native modules: RNCAsyncStorage, react-native-ble-plx. Did you forget to run "pod install" ?
info Found Xcode workspace "Sat008.xcworkspace"
info Building (using "xcodebuild -workspace Sat008.xcworkspace -configuration Debug -scheme Sat008 -destination id=61F7DB8A-467A-4027-95C3-B030C17EAA17")
...............
error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65. To debug build logs further, consider building your app with Xcode.app, by opening Sat008.xcworkspace. Run CLI with --verbose flag for more details.
Command line invocation:
/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -workspace Sat008.xcworkspace -configuration Debug -scheme Sat008 -destination id=61F7DB8A-467A-4027-95C3-B030C17EAA17
Prepare build
note: Using legacy build system
=== BUILD TARGET Sat008 OF PROJECT Sat008 WITH CONFIGURATION Debug ===
Check dependencies
The file “Pods-Sat008.debug.xcconfig” couldn’t be opened because there is no such file. (/Users/hyunmincho/Documents/React-Native/SAT_008_DEV/Earthrise-Anders/app/ios/Pods/Target Support Files/Pods-Sat008/Pods-Sat008.debug.xcconfig)
PhaseScriptExecution [CP]\ Check\ Pods\ Manifest.lock /Users/hyunmincho/Library/Developer/Xcode/DerivedData/Sat008-fynygwtjzergqceioiaqjhnwrfbp/Build/Intermediates.noindex/Sat008.build/Debug-iphonesimulator/Sat008.build/Script-D12BA90C2EB97176F46BC0FF.sh
cd /Users/hyunmincho/Documents/React-Native/SAT_008_DEV/Earthrise-Anders/app/ios
/bin/sh -c /Users/hyunmincho/Library/Developer/Xcode/DerivedData/Sat008-fynygwtjzergqceioiaqjhnwrfbp/Build/Intermediates.noindex/Sat008.build/Debug-iphonesimulator/Sat008.build/Script-D12BA90C2EB97176F46BC0FF.sh
diff: /Podfile.lock: No such file or directory
diff: /Manifest.lock: No such file or directory
error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.
** BUILD FAILED **
The following build commands failed:
PhaseScriptExecution [CP]\ Check\ Pods\ Manifest.lock /Users/hyunmincho/Library/Developer/Xcode/DerivedData/Sat008-fynygwtjzergqceioiaqjhnwrfbp/Build/Intermediates.noindex/Sat008.build/Debug-iphonesimulator/Sat008.build/Script-D12BA90C2EB97176F46BC0FF.sh
(1 failure)

react-native-nested-scroll-view: processDebugManifest FAILED

I'm using the module: react-native-sticky-parallax-header.
I follow all the steps at https://www.npmjs.com/package/react-native-sticky-parallax-header without problems:
yarn add react-native-sticky-parallax-header
react-native link react-native-nested-scroll-view
yarn add patch-package postinstall-postinstall
"scripts": {
+ "postinstall": "patch-package"
}
But when I do react-native run-android, I get:
info Starting JS server...
info Building and installing the app on the device (cd android && gradlew.bat app:installDebug)...
Downloading https://services.gradle.org/distributions/gradle-4.10.2-all.zip
...............................................................................................................
Unzipping C:\Users\Diogo\.gradle\wrapper\dists\gradle-4.10.2-all\9fahxiiecdb76a5g3aw9oi8rv\gradle-4.10.2-all.zip to C:\Users\Diogo\.gradle\wrapper\dists\gradle-4.10.2-all\9fahxiiecdb76a5g3aw9oi8rv
Welcome to Gradle 4.10.2!
> Task :react-native-nested-scroll-view:processDebugManifest FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Failed to create directory 'C:\Users\Diogo\Documents\ProjetosMobile\newproject\node_modules\react-native-nested-scroll-view\android\build\intermediates\merged_manifests\debug'
> root project > Resolve dependencies of :classpath
* 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.
> IDLE
* Get more help at https://help.gradle.org
BUILD FAILED in 3m 43s
2 actionable tasks: 2 executed
error Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
error Command failed: gradlew.bat app:installDebug. Run CLI with --verbose flag for more details.
I wear:
react-native-cli: 2.0.1
react-native: 0.59.8
node: v10.13.0

detox app could not be found, did you run './gradlew assembleAndroidTest'?

I am doing detox test for react native android version 0.57. I am getting this error.
Error is
Error: 'D:\folder\android\app\build\outputs\apk\androidTest\dev\debug\app-dev-debug-androidTest.apk' could not be found, did you run './gradlew assembleAndroidTest' ?
Package.json
"android.emu.debug": {
"binaryPath": "android/app/build/outputs/apk/dev/debug/app-dev-debug.apk",
"build": "cd android && .\\gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug && cd ..",
"type": "android.attached",
"name": "192.168.83.101:5555"
}
Error picture
Detox has strange behavior where it mutates your path to your apk, if you specify it using binaryPath.
To specify the exact path to your apk, add an entry for testBinaryPath that points to the APK you want Detox to use.
This error is usually caused but not having built the test apk. It can usually be resolved by running
detox build -c android.emu.debug
If you make changes to your application you should always run the above script before running any test.
I usually run the following script to make sure that the build is uptodate before testing.
detox build -c android.emu.debug && detox test -c android.emu.debug
change path android/app/build/outputs/apk/dev/debug/app-dev-debug.apk to android/app/build/outputs/apk/debug/app-debug.apk
and detox automatically will create apk to path android/app/build/outputs/apk/AndroidTest/debug/app-debug-androidTest.apk

ReactNative fails to deploy build to iOS simulator but does deploy it to Android emulator

ReactNative fails to deploy build to iOS simulator but does deploy it to Android emulator
Attached are screenshots showing this on both.
Steps:
Created react native app
react-native init proto
Run app on Android emulator after I started emulator
react-native run-android
this is running fine on Android emulator
Run app on iOS simmulator
react-native run-ios
This produces error as per screenshot
Error
** BUILD FAILED **
The following build commands failed:
CompileC /Users/dinob/reactnativework/proto/ios/build/Build/Intermediates/React.build/Debug-iphonesimulator/React.build/Objects-normal/x86_64/RCTShadowView+Internal.o Views/RCTShadowView+Internal.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)
Installing build/Build/Products/Debug-iphonesimulator/proto.app
An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=2):
Failed to install the requested application
An application bundle was not found at the provided path.
Provide a valid path to the desired application bundle.
Print: Entry, ":CFBundleIdentifier", Does Not Exist
Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier build/Build/Products/Debug-iphonesimulator/proto.app/Info.plist
Print: Entry, ":CFBundleIdentifier", Does Not Exist
Versions
MacBookPro OSX El Capitain
react-native 0.55.3
react-native-cli 2.0.1
npm 5.5.1
node v8.9.1
watchman 4.9.0
Please have a look here for help with troubleshooting
I would suggest you try all the solutions described in that thread to try and fix this issue. Good Luck!

Error launching React Native app from command line

I have a React Native app and recently upgraded to React Native 0.55. I previously could run the command react-native run-ios --simulator="iPhone X" to launch the app in the Simulator. Now I cannot, but I can still run the app in Xcode using build and run.
Here is the error from the react-native run-ios --simulator="iPhone X" output:
▸ Compiling RCTBundleURLProvider.m
❌ /dev/node_modules/react-native/React/Base/RCTBundleURLProvider.m:15:53: use of undeclared identifier 'undefined'; did you mean 'underline'?
const NSUInteger kRCTBundleURLProviderDefaultPort = RCT_METRO_PORT;
^~~~~~~~~~~~~~
▸ Compiling RCTLayoutAnimationGroup.m
▸ Compiling RCTNavigator.m
▸ Compiling RCTTabBar.m
** BUILD FAILED **
The following build commands failed:
CompileC /dev/ios/build/Build/Intermediates.noindex/React.build/Debug-iphonesimulator/React.build/Objects-normal/x86_64/RCTBundleURLProvider.o Base/RCTBundleURLProvider.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)
Installing Build/Products/Debug-iphonesimulator/MyApp.app
An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=2):
Failed to install the requested application
An application bundle was not found at the provided path.
Provide a valid path to the desired application bundle.
Print: Entry, ":CFBundleIdentifier", Does Not Exist
Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier Build/Products/Debug-iphonesimulator/MyApp.app/Info.plist
Print: Entry, ":CFBundleIdentifier", Does Not Exist
In case it helps, here's the output of react-native info:
Environment:
OS: macOS High Sierra 10.13.3
Node: 9.5.0
Yarn: 1.3.2
npm: 5.6.0
Watchman: 4.9.0
Xcode: Xcode 9.2 Build version 9C40b
Android Studio: 3.0 AI-171.4443003
Packages: (wanted => installed)
react: ^16.3.0-alpha.1 => 16.3.0-alpha.3
react-native: 0.55.0 => 0.55.0
What's wrong with my setup and how should I fix it?
As a workaround you should try
react-native run-ios --port 8088 or RCT_METRO_PORT=8081 react-native run-ios but unsure if that works.
RCT_METRO_PORT var was added in commit 33d710e8c58ef1dc69816a59ac1cf390894e7cb9 and looks like it breaks versions 0.54/0.55 to run ios apps from the cli.
In the meantime I continue using xcode to run my react-native apps.
Hopefully it can be patched or cherry picked or ultimately be fixed on the next major release.
There is an open GitHub issue about it.