Build command in detox - detox

Looking at this doc: https://github.com/wix/Detox/blob/master/docs/APIRef.Configuration.md
It says that the
Build command (either xcodebuild, react-native run-ios, etc...), will
be later available through detox CLI tool.
I'm trying to setup the build command to work with Android. Am I supposed to add react-native run-android to the build command? What do they mean by Detox CLI tool?

The build field is optional, and should contain whichever execution logic needed in order to have the .apk file set and ready in the path specified in binaryPath. You are more than welcome to refer to the Detox example project, which was set up as a reference exactly for these type of questions.
In any case, from the react-native CLI tool's help: react-native run-android = builds your app and starts it on a connected Android emulator or device. That makes it not very suitable, as we typically want to build the app, and have detox launch the emulator (optional) and install the app on the device(s), as needed.

Related

Failed to intall the app in react native, how can I fix this?

I was trying execute myapp to android but an error occurred.
To clarify what happened, first time I install nodejs and Android Studio.
Later I used the following commands:
npx react-native init 'app'
cd app
npx react-native run-android
Its my fisrt time messing with react native, I was following this page:
https://learn.microsoft.com/pt-br/windows/dev-environment/javascript/react-native-for-android
And the error is:
The error
I want coding in real time for android app.
How can I fix this?
Looks like the terminal output gives you several steps to do/check.
Make sure you have properly set up your android environment. Use this link to do so. You can use Expo-Cli or React-Native-Cli.
SDK location not found. This could be an off-shoot error of not properly doing step 1. However, to cover all of your bases, ensure you have properly set up your Android Emulator. This doc is a great walkthrough.
Once your Android studio and AVD Manager is properly set up, and your development environment is properly set, you should have no issues!
Please let me know if doing the above to steps did or did not solve your errors.
If you follow the steps, https://reactnative.dev/docs/environment-setup and https://developer.android.com/studio/run/emulator there will be no problem.
As a React Native fan on Windows 10, I'd like to mention just few points you need to check.
First, please check following user variables in Environment Variables ( You can see it from System Properties).
adb="C:\Users{username}\AppData\Local\Android\Sdk\platform-tools"
ANDROID_HOME="C:\Users{username}\AppData\Local\Android\Sdk"
JAVA_HOME="C:\Program Files\OpenJDK\openjdk-11.0.15_10"
Path: check if contains {ANDROID_HOME}\platform-tools
Eg:"C:\Users{username}\AppData\Local\Android\Sdk\platform-tools"
Second, if you are using Android Sdk emulator, please make sure that it configured correctly in emulator list in Android Studio.
For an instance, I created a android emulator using android sdk-29 and you can check the followings.
Third, I recommend you, deploy first app on emulator in Android Studio.
Because we need to download gradle zip file and others, it's essential to run your first android app in Android Studio.
When you confirmed your first android app(Deploy empty project app is also okay), you can run your React Native App by Expo-cli or react-native-cli.

Creating Android and iOS app from react-native

I have created one react-native app using expo and atom editor. It's running fine in android device and iOS simulator but with the help of expo. What I want is to generate Apk(debug) so that I can directly run on device. How can I do it ? I followed this(Dmitry Mugtasimov's answer). should I run all those command inside project folder ? Also I don't find index.js file inside my project folder. Also if someone know how to run on iOS simulator by creating app like file(don't know what is that in Ios because from android background). Please help, thanks
Since you have used Expo to develop your react-native app you can build the android app by going to the project folder and running the bellow command in the terminal
expo build:android
The building process will take around 5-10 minutes. When your build is done, expo build:status will give you your .apk file url. If not, it will say your build is still in progress and to try again later.
Also to build the iOS app you can run,
expo build:ios
To build the iOS standalone app you will need to have an Apple Developer account, but for Android standalone app you don't need a Google Play Developer account.
For the above commands to work you need to have expo-cli installed, For this you can run the bellow command,
npm install -g expo-cli
More Info: https://docs.expo.io/versions/latest/distribution/building-standalone-apps/
If you don't have an Apple Developer Account. You can build the iOS
standalone simulator build using the command,
expo build:ios -t simulator
And then wait for build to finish then download and unpack YourAppName.tar.gz. Then, start the iOS simulator and run xcrun simctl install booted YourAppName.app to run the .ica file.
More info: Expo / React-Native, Is it there a way to test-run standalone iOS apps on a device/simulator?

What are the difference between these React Native start commands?

I have been using react native for a couple months now. However, I really don't know the difference between the starting commands. Currently, I use npm on my project. However, I know yarn can be used. These are the commands I really don't understand the difference with:
exp start, exp ios, exp android
react-native run-ios, react-native run-android
npm start, npm ios, npm android
Which ones are better in what cases and why? Currently, I am using exp but others use react-native run-ios. I used to use npm ios.
Thank you in advance.
It might help to have an overview of the React Native architecture.
In react native, when you write, say, <View/>, it gets sent across the bridge to the native code and dynamically translated into UIView on iOS or android.view.View on Android. Every basic component in the react-native package has been implemented this way. If you want additional native functionality on both platforms, say a library which uses native map components, you will end up having to include the native libraries separately into your Android build.gradle and your iOS .xcodeproj.
The exp CLI is used to start apps built with the Expo SDK. Expo is essentially a prebuilt app with a certain set of native components already included for convenience; all you supply is your JSX; thus the recommendation to "eject" to a regular react native app if you need to use any other libraries.
react-native run-ios and run-android builds the native .app or .apk using the iOS or Android toolchains, starts the Metro Bundler, which minifies and serves the JSX and other assets such as images over to your device in debug mode (You might see something like Loading from localhost:8081).
On Android, it starts the adb server to push the APK with all the native libraries included onto your device, if you have USB debugging enabled. run-ios does the same with the .app; if you install to a simulator it has automatically configured AppDelegate.m to communicate with localhost:8081, whereas live reload over USB has to be configured manually on a physical device.
react-native start simply starts the Metro bundler, which is useful if you already have the app installed.
Commands that begin with npm are defined as scripts in your package.json file. As of RN 0.57, npm start simply calls node node_modules/react-native/local-cli/cli.js start; which is the same as running react-native start; according to the docs react-native-cli installed separately will call the locally installed version of the CLI in node_modules.

Integrate viro-react into react-native project

Anyone here managed to integrate viro-react into react-native project? I followed the instruction in
the documentation
After that, I executed the project but not able to run.
This is the error that I got
Even though I run with gradlew installOvrDebug, still it failed.
If your configurations are correct then try running with any of these variants
ArDebug, GvrDebug or OvrDebug
Example running apllication with Augmented Reality:
Android
react-native run-android --variant=ArDebug
iOS
react-native run-ios --variant=ArDebug
I solved this problem with the following method:
Go to the Navigate to the node_modules/react-native/local-cli/runAndroid/runAndroid.js file and edit the lines that include installDebug change it to installArDebug
Go to the terminal and npm start
Open another terminal and react-native run-android
*Make sure that your device is plugged in and that you have android studio sdk paths in your environment variables. This should do the trick!

How to run Expo test suite

I generated sample expo app, pull the latest https://github.com/expo/test-suite. I run test-suite in the simulator, it shows a spinner which never disappears.
Can you provide me an instruction how to run the tests?
I see some warnings as well while running test-suite.
Warning
Warning: Using unversioned Expo SDK. Do not publish until you set sdkVersion in exp.json
Warning
Warning: 'react' peer depencency missing. Run `npm ls` in /project/test-suite to see full warning.
If there is an issue running your project, please run `npm install` in /project/test-suite and restart.
Thanks
the repository that you linked is not a "test" suit as you understand it. It is not for testing your app. It exist for the developers of Expo as a tool, to test Expo before new releases of it.
Check out more about unit testing and test driven development;
https://en.wikipedia.org/wiki/Unit_testing
https://en.wikipedia.org/wiki/Development_testing
If your goal is to test your own app in you will need a simulator or a development device;
https://docs.expo.io/versions/v18.0.0/guides/up-and-running.html