react-native run-android not working and how to run it on genymotion - genymotion

I just start learning react-native. when I trying to run the react-native run-android command it is showing error about android emulator.
Please help me to run my first react native app on Genymotion.

simple way:
first connect and android device or run an android emulator then do this steps
1- open android studio
2- click on File->open->navigate to to your react-native project and choose android folder
3- comeback to cmd and run react-antive order again
4- react-native run-android

in gradle-wrapper.properties change distributionUrl=https://services.gradle.org/distributions/gradle-6.3-all.zip
from 5.x

First of all you have to installed genymotion plugin on android studio. After that please run genymotion emulator.
And please open android studio and android project of created RN app.
The relevant gradle version will be downloaded and synchronized.
And then run command "react-native run-android".

Steps to setup for React Native with GenyMotion on MAC Machine
Installed Android Studio
Installed Genymotion
Pointed Genymotion settings custom SDK to: /Users/myusername/Library/Android/sdk
Added path to adb tool directory in .bash_profile to: PATH="/Users/myusername/Library/Android/sdk/platform-tools:${PATH}"
Restarted terminal for path to take effect
Ran exp path in terminal to copy path to exp
Ran adb in terminal to make sure it could find adb in platform-tools directory
Restarted Genymotion
Created and started virtual device in Genymotion
Started Expo XDE and started project
Ran Open on Android from XDE
App started on virtual device created in Genymotion (step 9)
after these steps,
on Terminal fire : npm run android
This has worked for me !

Related

React Native Command "npx react-native start" does not work

I have bought a new MacBook Air with M1 chip a few days ago and am just trying to set up my react native and Xcode etc. running for writing iOS app.
I have had some issues with "npx react-native init AwesomeProject" previously but hopefully it has been solved. React-Native Error + Bug in Ruby Interpreter: Failed to install CocoaPods dependencies for iOS project, which is required by this template
I assume the init was successful because I got the following run instructions in color:
Run instructions for Android:
• Have an Android emulator running (quickest way to get started), or a device connected.
• cd "/Users/boscotsin/Documents/react/test4" && npx react-native run-android
Run instructions for iOS:
• cd "/Users/boscotsin/Documents/react/test4" && npx react-native run-ios
- or -
• Open test4/ios/test4.xcworkspace in Xcode or run "xed -b ios"
• Hit the Run button
Run instructions for macOS:
• See https://aka.ms/ReactNativeGuideMacOS for the latest up-to-date instructions.
I then proceed to the second step according to React Native document which is to cd into the directory and then run "npx react-native start" but then it won't work. I am given two options:
To reload the app press "r"
To open developer menu press "d"
And whichever option I choose it will say no apps connected and I will be greeted with either of these:
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.
info Reloading app...
warn No apps connected. Sending "devMenu" to all React Native apps failed. Make sure your app is running in the simulator or on a phone connected via USB.
info Opening developer menu...
I also try to run "npx react-native run-ios" directly and it will also say the build is unsuccessful...
May I know what is wrong here?
Or should I just reinstall Xcode or some other things once and for all???

installing reactnative for android on macOS Catlina

i try to install reactnative today
been following tutorial from here : https://reactnative.dev/docs/environment-setup
when i try to run the test project
it failed to load emulator
chandra#MacBook-Pro-Chandra AwesomeProject % npx react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 967 file(s) to forward-jetify. Using 8 workers...
info Starting JS server...
/bin/sh: adb: command not found
info Launching emulator...
error Failed to launch emulator. Reason: No emulators found as an output of emulator -list-avds.
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
info Installing the app...
can anyone help me please? thanks
You must create at least one AVD (Android Virtual Device) in order to run it in the emulator. It seems that you don't have any. An easy way to check is to run the following command:
emulator -list-avds
# Example output
Nougat_7
Pixel_2_API_29_Google_Play_
If the output of the command is empty, it means you don't have any AVDs yet. In this case you can create an AVD by opening Android Studio and then clicking the Configure menu and after that opening AVD Manager. In AVD Manager you can create a new virtual device which you can later run in the emulator.

NativeScript - cmd tns run android issue

Am new to NativeScript.
I have done Full setup ( cmd tns doctor with no issues) and created a new project by using cmd tns create.
I have installed Android studio as well, also created virtual device by AVD Manager (Pixel 3 API Q).
Now opened the project in Android Studio and run the cmd tns run android / tns run android --bundle but it throws the error "Cannot find connected devices. Reconnect any connected devices, verify that your system recognizes them, and run this command again."
cmd tns device not showing any devices but tns device android --available-devices shows devices.
Please help me how to connect device and emulators.
Also, i don't have experience in Android studio.
I'm new in Nativescript also and take me two days to configure the entire environment to run a Nativescript app with the android emulator without install the Android Studio. So the problema that you have also I had and to fix it just has to add the "ANDROID_AVD_HOME" to your system variables.
Environment variables
After that you can run your emulator only in a command line window and in another command line window without close your emulator you can type "tns device" and see the active emulators and then run your application using "tns run" or "tns run android --device emulatorname". That works for my after many attempts
Set Environment path for android emulator. First open environment variables and double click on path in system variables then open new window Edit environment variable and add emulator path in this window. Like show in this images.

How to open an Android Studio made Flutter project on Mac?

How can I open an existing Flutter project made by Android Studio on Mac-Os to export ipa version of app? Can it be done with Mac-Os version of Android Studio or I have to do it with X-Code? How?
Thanks in Advance
I could finally do that by accomplishing the following steps:
Copy the project into macOs (with X-Code Installed)
Open it by Android Studio (preferably latest version)
Enable Flutter and Dart plugin on Android Studio framework settings
Run command flutter packages get (Connection to Flutter repositories must be available)
Run flutter build ios --release as #Günter Zöchbauer truly commented
Connect iPhone device or simulator and run directly on your device
If some errors printed you may need to verify your developer account settings on X-Code or check Github page of your libraries for possible iOS issues
You can do it in XCode.
Ensure you run flutter build ios --release before you do.
Connection to physical iPhone device is not necessary. Run any sample project in xcode. Start a Simulator. (Only One simulator preferrably).
clone the repository from github into Mac (with X-Code Installed)
open terminal.
cd to your pubspec.yaml
flutter run (it will automatically run flutter pub get)
(It will launch on the already running iOS simulator)
follow steps on flutter.dev to install flutter. Above steps will only work from terminal if flutter doctor(any flutter command) is recognized

Nativescript - error on tns run android

I'm trying to run android emulator with the command tns run android. This starts the emulator but it keeps stuck on Android logo and I get the following error:
(...)
BUILD SUCCESSFUL
Total time: 17.013 secs
Project successfully built.
Using C:\(...)\sample-Groceries\platforms\android\build\outputs\apk\sampleGroceries-debug.apk
Starting Android emulator with image Nexus6
Waiting for emulator device initialization..............
Cannot run your app in the native emulator. Increase the timeout of the operation with the --timeout option or try to restart your adb
server with 'adb kill-server' command. Alternatively, run the Android
Virtual Device manager and increase the allocated RAM for the virtual
device.
(...)
Here is my Android Virtual Device configured:
AVD Manager
Note: I can run the application on my phone anyway, but not on my PC.
Finally I found the problem.
In Android Virtual Device Manager, there was an error I didn't see:
AVD Manager error
Here is a solution which I found to be useful.
enter image description here
You just have to manually activate the emulator, which you can do using android studio or command line. Using the command line, you have to run this command
emulator -avd avd_name [ {-option [value]} … ]
for ex:
/Android/sdk/emulator/emulator -avd test
Once the emulator starts you can run this command
tns run android
I started having similar issue after updating to the latest Android Studio and latest emulators. I switched the VM Heap to 64, and it worked for me. May be worth giving that a try.
Open your Android Virtual Device Manager and download the latest
emulator. That will fix the error.
I had the same problem. I fixed that by:
Open emulator manually from Android Studio (double-click on position in AVD Manager list)
Run tns run android
Works for macOS Sierra.

Resources