How do I open react-native app in emulator? - javascript

I have a react-native app that I have just ejected from expo to a bare react-native app.
I can run yarn react-native run-android without any errors and even opens my android emulator however, I can't see my app available within the emulator.
Should this open automatically or should I see it available in the app draw?
How can I start my app within the emulator?
note: the Who Am I app is not it. It's my built version via expo before I ejected.

The command should be react-native run-android not yarn react-native run-android unless you defined the script react-native run-android as itself in your package.json.
Then the app should start by itself in the emulator, but you have to run react-native start to use it.
react-native run-android installs the app on the emulator so you should be able to find the launch icon of your app inside the emulator
Using react-native run-android without exactly one device (one emulator or one real device) leads to an error (Failed to install the app. Make sure you have an Android emulator running or a device connected. in case none is connected) thus if you don't have a real device connected your emulator is detected.

Related

React Native White Screen on iOS Simulator

Up until recently, my app was running on iOS. I am now running into a white screen issue when running npx run-ios.
When running npx run-ios, the simulator starts up and builds the application, but Metro bundler says warn No apps connected. Sending "reload" to all React Native apps failed. Make sure your app is running in the simulator or on a phone connected via USB. on the terminal. Which is odd as the command itself opens the simulator and builds the application.
I am also unable to access the developer menu in both the terminal and on the simulator. So I can't access/edit bundler configs.
Things I've tried:
I've tried to delete the node_modules and run npm-install.
Deleting the Pods folder and Podfile.lock and then running pod install.
As I was working in a development branch, so I checked out to the main branch, which was working fine before, but the same issue persists, so I am doubtful that it's my code (I might be wrong however".
Doing Clear device and settingson the simulator.
Trying a different simulator.
I've seen on different similar posts that the simulator and my dev environment should be on the same network. However, this was never an issue before, and there is also no wifi edit function on the simulator.
Running the iOS application from Xcode instead

An error occurred while running subprocess cordova. Why?

I make mobile game on JS, and i use Ionic for build Android app.
For adding to my project Android Platform i writed:
C:\TB>ionic cordova prepare android
But this back me:
? Platform android is not installed! Would you like to install it? Yes
> cordova.cmd platform add android --save
You have been opted out of telemetry. To change this, run: cordova telemetry on.
Using cordova-fetch for cordova-android#9.1.0
Adding android project...
Could not load API for android project C:\TB\node_modules\cordova-android
[ERROR] An error occurred while running subprocess cordova.
cordova.cmd platform add android --save exited with exit code 1.
Re-running this command with the --verbose flag may provide more information.
At my node_modules folder have subfolder cordova-android, why ionic?!
How can i fix this?
P.S. My android SDK at needed folder AppData\Local\Android\Sdk
Try running the following commands
ionic cordova platform rm android
ionic cordova platform add android
ionic cordova build android

Module hmrclient is not registered react native, why is this happening and how to fix it?

So I have rage shaken my tablet and in dev settings, I have my JS dev mode to true yet, live/hot reloading does not work. Funny thing is, when I run the app on a colleague's Mac (the same model and everything) - it works fine.
I don't know what or why this is happening.
I've tried:
cd android && ./gradlew clean
then cd .. && react-native run-android
https://github.com/expo/expo/issues/916
and also:
rm -rf node_modules && npm install
cd android && ./gradlew clean
React-Native Module HMRClinet is not a registered callable module(calling enable)
import com.facebook.react.BuildConfig;
react-native run-android
Unable to load script from assets index.android.bundle on windows
None of the above solutions work.
Do you guys know how I can solve this issue?
This issue come due to development server error.
Follow some steps to resolve this issue.
Step 1:
adb kill-server
adb start-server
then check your device/emulator is visible on command prompt or not.
adb devices
Step 2
Clean your gradle compiler files, some file may be corrupt.
android/gradlew clean
Step 3:
Remove application from your device/emulator.
Step 4:
react-native run-android
Now issue will be resoled :)
React-Native Module HMRClinet is not a registered callable module(calling enable)

Why we are making index.android.bundle file while do changes in react native?

Every time I will need to make index.android.bundle file in android studio.
Command 1: react-native bundle --platform --dev false --entry-file index.android.js --bundle-output android /app/src/main/assets/index.android.bundle/ --assets-dest android/app/src/main/res
Command 2 : react-native run-android.
Please let me know is we need to hit every time to see the little changes on simulator or i 'm doing something wrong in that....
Also please tell me how to enable android monitor for debugging the change or check the log of react native files.
Thanks
Finally i got a solution of this problem, React-naive js is based on Instant refreshing with that user is able to see the result in simulator..
In this you need to follow these steps before starting Developing in react js
Open two command prompt window and run one window : react-native run-android and other on below command npm start.
react-native run-android
Now may be you will got an error : Unable to connect to development server
Now you need to run "npm start"
You simulator is running with the localhost:8081 server instantly
You can check in the browser as well : localhost:8081 that is showing react packager server is running.
After this by pressing Ctrl + D then Ctrl + M for debugging or Reloading your changes in the simulator .
You can check this above methods for get rid of issues .
Thanks!

How to install my NativeScript application in my phone?

I have build an android application using NativeScript but now i want to install it in my android phone but i don't know which .apk file i have to take to install the application in my phone.
According to the {N} docs you should execute tns deploy android on the command line. This will install your app onto the currently connected device. After the app has been installed, it will automatically start on Android.
If you want your app to be compiled before installing it on your device, you should execute tns run android on the command line. This will prepare, build and deploy your app.
You can find all the cli commands on the github page: https://github.com/NativeScript/nativescript-cli

Categories