How Can I run react-native app in my mobile because avd is too slow - javascript

Please help me. My React Native app is not running in my mobile. It works fine on the android simulator, but the performance is quiet bad.
The error is:
$ 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 2 workers...
info Starting JS server...
info Installing the app...
FAILURE: Build failed with an exception.
* What went wrong:
Could not initialize class org.codehaus.groovy.runtime.InvokerHelper
* 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
BUILD FAILED in 8s
error Failed to install the app. Make sure you have the Android development environment set up:
https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Com
mand failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

This might be because lower version of Jdk. Please update JDK version supported by Android Studio
For Reff : Could not initialize class org.codehaus.groovy.runtime.InvokerHelper

Try React Native environment to upgrade your environment because there is a thread in here Grovy Error

It's simple , just connect your mobile with Android studio and on the developing mode , then select the device from Android studio and run the project the app will simply open on your phone , unless you don't have any errors in enviornment.

Related

React Native, Failed to launch emulator. Reason: No emulators found as an output

I'm trying to run my react native app in emulator by using command react-native run-android but it's throwing that error
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.3/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 44s
info Connecting to the development server...
warn Failed to connect to development server using "adb reverse": spawnSync /Opt/Android/platform-tools/adb ENOENT
info Starting the app...
The system cannot find the path specified.
error Failed to start the app. Run CLI with --verbose flag for more details.
Error: Command failed: /Opt/Android/platform-tools/adb shell am start -n com.reactproject/com.reactproject.MainActivity
at makeError (C:\Users\Danger World\ReactProject\node_modules\execa\index.js:174:9)
I already setup my android studio and sdk manager, avd manager like it's shown in doc also I already set path but it's still showing that error, anyone know why? Can anyone help please?
You can fix it by using the command :
react-native doctor
This command shows all issues that need to be fixed.
Press f to fix the issues and don't forget to restart your windows
And after then open the emulator before running your project.
Once emulator opened,
run command:
react-native run-android
After fixed:
Don't forget to give me an upvote if that's work.
In My Case, I have to re-run the command in the same terminal where you are trying to run npx react-native run-android
Step 1. paste the source command first
source ~/.bash_profile OR source ~/.bashrc
Step 2. RUN Next command
npx react-native run-android
set your AVD manager path and JDK path like this , also you have to add Android Home path

React Native, why react-native run-android not working?

I'm trying to run react native run-android after I update my project file, but whenever I run react-native it throws an error. When I created that project and that command it worked fine but when I edit and add some files like apps/redux, apps/components, screens etc it stopped working. Can anyone tell me why it's not working?
error Failed to launch emulator. Reason: Could not start emulator within 30 seconds..
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
info Installing the app...
> Task :app:compileDebugJavaWithJavac
> Task :app:stripDebugDebugSymbols UP-TO-DATE
Compatible side by side NDK version was not found.
> Task :app:installDebug FAILED
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.3/userguide/command_line_interface.html#sec:command_line_warnings
27 actionable tasks: 6 executed, 21 up-to-date
Note: C:\Users\Danger World\ReactProject\android\app\src\debug\java\com\reactproject\ReactNativeFlipper.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:installDebug'.
> com.android.builder.testing.api.DeviceException: No connected devices!
* 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
BUILD FAILED in 1m 11s
error Failed to install the app. Make sure you have an Android emulator running or a device connected. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
Note: C:\Users\Danger World\ReactProject\android\app\src\debug\java\com\reactproject\ReactNativeFlipper.java uses or overrides a deprecated API.
you either need to create a virtual device or connect a physical device with USB debuging enabled (https://developer.android.com/studio/debug/dev-options).
To create a virtual device, open android studio and select AVD manager from Configure menu and create a new virtual device downloading required packages.
In case you are using a virtual device with Android studio then try to manually run the emulator BEFORE react-native run-android.
(open android studio > Tools > AVD Manager > Create Virtual Device)
https://developer.android.com/studio/run/managing-avds#createavd
Or repeat the official installation guide:
https://reactnative.dev/docs/environment-setup

Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

I am new to react-native development. I was trying a simple react-native project from Facebook git hub. I have followed all the steps but when I try to run the project by typing
react-native run-android
it simply shows me following error:
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 864 file(s) to forward-jetify. Using 4 workers...
info Starting JS server...
info Launching emulator...
info Successfully launched emulator.
info Installing the app...
Warning: No leading - on line 1 of `C:\Program Files\Java\jdk-13\lib\jvm.cfg'
error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
Warning: No leading - on line 1 of `C:\Program Files\Java\jdk-13\lib\jvm.cfg'
at checkExecSyncError (child_process.js:611:11)
at execFileSync (child_process.js:629:15)
at runOnAllDevices (C:\Users\Toshiba\Documents\AwesomeProject\node_modules\#react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:39)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async Command.handleAction (C:\Users\Toshiba\Documents\AwesomeProject\node_modules\react-native\node_modules\#react-native-community\cli\build\index.js:164:9)
Turns out I had a problem with my Java. I uninstall JDK and JRE and reinstall the latest version and it worked out for me.
Try these once :
1.reopen android studio as admin. build the gradle. if no issue, proceed on
access the android folder of your app. i.e c:\folder\app\android
2.type in gradlew clean
3.run react-native run-android
Hope it helps
If you're using the latest version of Java Development Kit, you'll need to change the Gradle version of your project so it can recognize the JDK. You can do that by going to {project root folder}\android\gradle\wrapper\gradle-wrapper.properties and changing the distributionUrl value to upgrade the Gradle version. You can check out here the lastest releases of Gradle

Problem with new version of react-native: FAILURE: Build failed with an exception

the new version of react-native (v 0.59) give me an error when trying to run that on a device or simulator:
C:\Pro\react-native jan\tictactoe>react-native run-android
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\MAN.gradle\wrapper\dists\gradle-4.10.2-all\9fahxiiecdb76a5g3aw9oi8rv\gradle-4.10.2-all.zip to C:\Users\MAN.gradle\wrapper\dists\gradle-4.10.2-all\9fahxiiecdb76a5g3aw9oi8rv
Welcome to Gradle 4.10.2!
Here are the highlights of this release:
- Incremental Java compilation by default
- Periodic Gradle caches cleanup
- Gradle Kotlin DSL 1.0-RC6
- Nested included builds
- SNAPSHOT plugin versions in the plugins {} block
For more details see https://docs.gradle.org/4.10.2/release-notes.html
Starting a Gradle Daemon (subsequent builds will be faster)
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring root project 'tictactoe'.
Could not resolve all artifacts for configuration ':classpath'.
Could not resolve com.android.tools.build:gradle:3.3.1.
Required by:
project :
Could not resolve com.android.tools.build:gradle:3.3.1.
Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.3.1/gradle-3.3.1.pom'.
Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.3.1/gradle-3.3.1.pom'.
Connect to 127.0.0.1:50002 [/127.0.0.1] failed: Connection refused: connect
Could not resolve com.android.tools.build:gradle:3.3.1.
Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.3.1/gradle-3.3.1.pom'.
Could not GET 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.3.1/gradle-3.3.1.pom'.
Connect to 127.0.0.1:50002 [/127.0.0.1] failed: Connection refused: connect
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
BUILD FAILED in 4m 55s
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
what i have to do?

SDK error in React native

i am new to react native and an trying to run the project on emmulator "react-native run-android" . iam getting the error.
* What went wrong:
A problem occurred configuring project ':app'.
> The SDK directory 'D:\ReactNativeLearning\zupportdeskchat\ZDReactNative\zupportdeskapp\android\"D:\Android\sdk"' does not exist.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 5.253 secs
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/android-setup.html
My Sdk Folder is in
sdk.dir ="D:/Android/sdk"
I set it up in local.properties.
Can someone help me to fix this tnx.
If you are working on windows system then path should be:
sdk.dir=D\:\\Projects\\Android\\sdk
Clear build cache and npm cache then try to make build.
Also check, your device is connected or not.
You are getting this error because you haven't connected a device or opened the emulator. So first connect the device to the machine and try react-native run-android or run the emulator and enter react-native run-android

Categories