I can run my rn project without error.I just create another for test something with
react-native init testapp
and then opened with vs code , run this command as usual
react-native run-android --no-jetifier
it runs the code in emulator.But now it gives error in new project like that.
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 971 file(s) to forward-jetify. Using 8 workers...
info JS server already running.
info Installing the app...
:ReactNative:Unexpected empty result of running '[node, C:\Users\sampleuser\Desktop\samplee\testapp\node_modules\react-native\node_modules\#react-native-community\cli\build\bin.js, config]' command.
:ReactNative:Running '[node, C:\Users\sampleuser\Desktop\samplee\testapp\node_modules\react-native\node_modules\#react-native-community\cli\build\bin.js, config]' command failed.
FAILURE: Build failed with an exception.
* Where:
Script 'C:\Users\sampleuser\Desktop\samplee\testapp\node_modules\#react-native-community\cli-platform-android\native_modules.gradle' line: 195
* What went wrong:
A problem occurred evaluating script.
> internal/modules/cjs/loader.js:1033 throw err; ^Error: Cannot find module 'C:\Users\sampleuser\Desktop\samplee\testapp\node_modules\react-native\node_modules\#react-native-community\cli\build\bin.js' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1030:15) at Function.Module._load (internal/modules/cjs/loader.js:899:27) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) at internal/main/run_main_module.js:17:47 { code: 'MODULE_NOT_FOUND', requireStack: []}
* 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
BU�LD FAILED in 1s
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: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
also i tryed
npx react-native run-android
Also tryed
uninstall and reinstall nodemodules
Cold start Emulator
Update android sdk
Still gives same error
Also tryed to downgrade version
"dependencies": {
"react": "16.8.0",
"react-native": "0.60.0",
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\sampleuser\Desktop\samplee\testapp\android\app\build.gradle' line: 1
* What went wrong:
A problem occurred evaluating project ':app'.
> Failed to apply plugin [id 'com.android.application']
> Your project path contains non-ASCII characters. This will most likely cause the build to fail on Windows. Please move your project to a different directory. See http://b.android.com/95744 for details. This warning can be disabled by adding the line 'android.overridePathCheck=true' to gradle.properties file in the project directory.
info JS server already running.
info Installing the app...
:ReactNative:Unexpected empty result of running '[node, \node_modules\react-native\node_modules\#react-native-community\cli\build\bin.js, config]' command.
:ReactNative:Running '[node, \node_modules\react-native\node_modules\#react-native-community\cli\build\bin.js, config]' command failed.
react-native --version
react-native-cli: 2.0.1
react-native: 0.63.2
You didn't enter your project file with "cd" command.You must run your command in your project file.That's why it gives this error.The solution is gonna be in these following steps.
When you initiliaze your project with command "npx react-native init testapp", you need to start metro bundler.(You can find the details about Metro) Before you start metro bundler,You should write down "cd testapp/" command in VS terminal.This will get in your project file.Than,write command which is gonna start metro "npx react-native start".
Secondly,let metro run in its own terminal.Open a new terminal inside your react native project folder.Get into your file again in this terminal too with "cd testapp/".
3.Finally,run your emulator from Android studio.And write "npx react-native run-android" command.(You can go look for how AVD starts with Android Stuido in this link)
Additionally,(VS code screenshot)
Related
I am now using react native cli in my crud project,but after I initialized the project and ran npx react-native run-android inside project folder
it gave me these errors :
npx react-native run-android
info Starting JS server...
* daemon not running; starting now at tcp:5037
* daemon started successfully
info Launching emulator...
info Successfully launched emulator.
info Installing the app...
:ReactNative:Unexpected empty result of running '[node, C:\Users\invis\OneDrive\�?rea de Trabalho\reac\app\node_modules\#react-native-community\cli\build\bin.js, config]' command.
:ReactNative:Running '[node, C:\Users\invis\OneDrive\�?rea de Trabalho\reac\app\node_modules\#react-native-community\cli\build\bin.js, config]' command failed.
FAILURE: Build failed with an exception.
* Where:
Script 'C:\Users\invis\OneDrive\�rea de Trabalho\reac\app\node_modules\#react-native-community\cli-platform-android\native_modules.gradle' line: 413
* What went wrong:
A problem occurred evaluating script.
> node:internal/modules/cjs/loader:988 throw err; ^Error: Cannot find module 'C:\Users\invis\OneDrive\�rea de Trabalho\reac\app\node_modules\#react-native-community\cli\build\bin.js' at Function.Module._resolveFilename (node:internal/modules/cjs/loader:985:15) at Function.Module._load (node:internal/modules/cjs/loader:833:27) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) at node:internal/main/run_main_module:22:47 { code: 'MODULE_NOT_FOUND', requireStack: []}
* 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.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
:ReactNative:Unexpected empty result of running '[node, C:\Users\invis\OneDrive\�?rea de Trabalho\reac\app\node_modules\#react-native-community\cli\build\bin.js, config]' command.
:ReactNative:Running '[node, C:\Users\invis\OneDrive\�?rea de Trabalho\reac\app\node_modules\#react-native-community\cli\build\bin.js, config]' command failed.
FAILURE: Build failed with an exception.
* Where:
Script 'C:\Users\invis\OneDrive\�rea de Trabalho\reac\app\node_modules\#react-native-community\cli-platform-android\native_modules.gradle' line: 413
* What went wrong:
A problem occurred evaluating script.
> node:internal/modules/cjs/loader:988 throw err; ^Error: Cannot find module 'C:\Users\invis\OneDrive\�rea de Trabalho\reac\app\node_modules\#react-native-community\cli\build\bin.js' at Function.Module._resolveFilename (node:internal/modules/cjs/loader:985:15) at Function.Module._load (node:internal/modules/cjs/loader:833:27) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) at node:internal/main/run_main_module:22:47 { code: 'MODULE_NOT_FOUND', requireStack: []}
* 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
at makeError (C:\Users\invis\OneDrive\Área de Trabalho\reac\app\node_modules\#react-native-community\cli-platform-android\node_modules\execa\index.js:174:9)
at C:\Users\invis\OneDrive\Área de Trabalho\reac\app\node_modules\#react-native-community\cli-platform-android\node_modules\execa\index.js:278:16
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async runOnAllDevices (C:\Users\invis\OneDrive\Área de Trabalho\reac\app\node_modules\#react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:109:5)
at async Command.handleAction (C:\Users\invis\OneDrive\Área de Trabalho\reac\app\node_modules\#react-native-community\cli\build\index.js:142:9)
info Run CLI with --verbose flag for more details.
At first I installed react native and react-native-community-cli globally and I saw it was a bad practice so I uninstalled it globally and installed again but now locally
I saw in a website the command
react-native doctor
And I saw at first some problems with SDK so I installed all packages necessary and it still AFTER ALL THIS gives me the same error again and again
I also tried deleting node modules ang installing again with
npm install
but unfortunately it did not work,if anyone has any ideas please send it ,I will be very grateful !!!
After A LOT of research,I found out that because my path system is written in portuguese ,my desktop is named "Área de Trabalho" ,it did not worked,I changed it to OneDrive directory which is 1 level upper in the directory tree and it DID worked fine!!! Hope I helped someone with the same problem!!! Have a good day !!!
I'm setting up my environment to code in react-native, and when I run
npx react-native run-android
the response is:
:ReactNative:Unexpected empty result of running '[node, C:\Users\fre_z\OneDrive\�?rea de Trabalho\Prog\OmegaApp\node_modules\#react-native-community\cli\build\bin.js, config]' command.
:ReactNative:Running '[node, C:\Users\fre_z\OneDrive\�?rea de Trabalho\Prog\OmegaApp\node_modules\#react-native-community\cli\build\bin.js, config]' command failed.
FAILURE: Build failed with an exception.
* Where:
Script 'C:\Users\fre_z\OneDrive\�rea de Trabalho\Prog\OmegaApp\node_modules\#react-native-community\cli-platform-android\native_modules.gradle' line: 213
* What went wrong:
A problem occurred evaluating script.
node:internal/modules/cjs/loader:936 throw err; ^Error: Cannot find module 'C:\Users\fre_z\OneDrive\�rea de Trabalho\Prog\OmegaApp\node_modules\#react-native-community\cli\build\bin.js' at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15) at Function.Module._load (node:internal/modules/cjs/loader:778:27) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) at node:internal/main/run_main_module:17:47 { code: 'MODULE_NOT_FOUND',
requireStack: []}
* 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 971ms
I know it's probably an error while I was setting up the environment. But, I don't know where, and I already redone it twice.
In your project, try to remove node modules and reinstall core-util-is:
rm -rf node_modules
npm install -g npm#latest
npm i core-util-is
I'm also guessing you cloned RN project created on other environment. So if above steps fail, you can try to create new RN project on your current setup - if it is 'compileable' you should be able to run cloned project also.
Another step worth to try - reinstal Node for your platform (https://nodejs.org/en/download/)
I don't know why, but i changed the folder where i cloned the project and it worked. I'm guessing it was because of the spaces and special characters in the path. When i cloned it in C: it worked.
Im trying to build an app but run into some problems so tried with a fresh projects that still fails to build. This is my steps:
1) Installing the app with
react-native init Myapp
after that Im running the emulator in android studio and launching the app with:
react-native run-android
and are getting the errormessage below. I have tried to reinstall the react-native cli
npm install -g react-native-cli
reset the cache in gradle with
cd android
gradlew cleanBuildCache
It used to work but since I have had some problems to build the apk I messed around a bit with the gradle. I might have updated something that causes the error. Any help is very welcomed!
here is the errormessage
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:preDebugBuild'.
> Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'.
> Could not resolve org.webkit:android-jsc:+.
Required by:
project :app
> Failed to list versions for org.webkit:android-jsc.
> Could not list versions using M2 pattern 'https://jitpack.io/[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier])(.[ext])'.
> Could not get resource 'https://jitpack.io/org/webkit/android-jsc/'.
> Could not GET 'https://jitpack.io/org/webkit/android-jsc/'. Received status code 522 from server: Origin Connection Time-out
* 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 39s
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
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:preDebugBuild'.
> Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'.
> Could not resolve org.webkit:android-jsc:+.
Required by:
project :app
> Failed to list versions for org.webkit:android-jsc.
> Could not list versions using M2 pattern 'https://jitpack.io/[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier])(.[ext])'.
> Could not get resource 'https://jitpack.io/org/webkit/android-jsc/'.
> Could not GET 'https://jitpack.io/org/webkit/android-jsc/'. Received status code 522 from server: Origin Connection Time-out
* 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 39s
at checkExecSyncError (child_process.js:616:11)
at execFileSync (child_process.js:634:13)
at runOnAllDevices (D:\Myapp\node_modules\#react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:74:39)
at buildAndRun (D:\Myapp\node_modules\#react-native-community\cli-platform-android\build\commands\runAndroid\index.js:158:41)
at then.result (D:\Myapp\node_modules\#react-native-community\cli-platform-android\build\commands\runAndroid\index.js:125:12)
at process._tickCallback (internal/process/next_tick.js:68:7)
Is Android SDK installed and are all the required variables set?
Try running in the command line:
adb
If the command is not recognized, then something is wrong with your Android SDK installation.
Follow the link provided in the error for detailed instructions on installing Android SDK.
I think, Developer options closed in your devices first open developer options,
then try this command
react-native init Test
npm i
react-native run-android or ios.
Turn off wifi
Build the app in offline mode
Turn on wifi
Your app should be builded
The reason behind this has been described here: https://github.com/react-native-camera/react-native-camera/issues/2490
Go to android folder and edit build.gradle
set buildToolsVersion to buildToolsVersion = "23.0.1" mine was 30.0.2 when i changed it to "23.0.1" it started working
In the android folder run
gradlew.bat installDebug
and make sure the Build is successful
That should do it go back to your project folder and run
npm run android
I am new to react-native and trying to build an android app using react native in Android Studio for Windows. After I install react-navigation, follow all the steps in the react-navigation documentation, I run react-native run-android and I get this error in the command line:
PS C:\Users\comp\Desktop\work\reactnative\dansapp> react-native run-android
Starting JS server...
Building and installing the app on the device (cd android && gradlew.bat installDebug)...
FAILURE: Build failed with an exception.
* Where:
Settings file 'C:\Users\comp\Desktop\work\reactnative\dansapp\android\settings.gradle' line: 3
* What went wrong:
Could not compile settings file 'C:\Users\comp\Desktop\work\reactnative\dansapp\android\settings.gradle'.
> startup failed:
settings file 'C:\Users\comp\Desktop\work\reactnative\dansapp\android\settings.gradle': 3: unexpected char:
'\' # line 3, column 133.
s\react-native-gesture-handler\android')
^
1 error
* 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 1s
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
Command failed: gradlew.bat installDebug
Error: Command failed: gradlew.bat installDebug
at checkExecSyncError (child_process.js:602:13)
at Object.execFileSync (child_process.js:622:13)
at runOnAllDevices (C:\Users\comp\Desktop\work\reactnative\dansapp\node_modules\react-native\local-cli\runAndroid\runAndroid.js:299:19)
at buildAndRun (C:\Users\comp\Desktop\work\reactnative\dansapp\node_modules\react-native\local-cli\runAndroid\runAndroid.js:135:12)
at isPackagerRunning.then.result (C:\Users\comp\Desktop\work\reactnative\dansapp\node_modules\react-native\local-cli\runAndroid\runAndroid.js:65:12)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:189:7)
PS C:\Users\comp\Desktop\work\reactnative\dansapp>
Does anyone know what this error is and how to resolve it? It seems to occur after I install react-navigation following these steps: https://reactnavigation.org/docs/en/getting-started.html
I have follwed the steps, including changing the mainActivity.java file. I also do not know what gradle is.
Any help would be greatly appreciated!
Known issue (see: bug with react-native link in android and windows), which will hopefully be fixed soon.
Jump into your settings.gradle file in /dansapp/android/ and replace...
project(':react-native-gesture-handler').projectDir = new File(rootProject.projectDir, '..\node_modules\react-native-gesture-handler\android')
...with...
project(':react-native-gesture-handler').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-gesture-handler/android')
I'm using phonegap 100% from the command line. If I build while connected to the internet it works
$ phonegap build android
[phonegap] executing 'cordova build android'...
[phonegap] completed 'cordova build android'
But if I disconnect from the internet I get errors
$ phonegap build android
[phonegap] executing 'cordova build android'...
cp: no such file or directory: /Users/gregg/src/hft-mobile-app/icon.png
Running command: /Users/gregg/src/hft-mobile-app/platforms/android/cordova/build
ANDROID_HOME=/Users/gregg/Downloads/android-sdk-macosx
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home
Running: /Users/gregg/src/hft-mobile-app/platforms/android/gradlew cdvBuildDebug -b /Users/gregg/src/hft-mobile-app/platforms/android/build.gradle -Dorg.gradle.daemon=true
FAILURE:
Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all dependencies for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:1.0.0+.
Required by:
:android:unspecified
>
Failed to list versions for com.android.tools.build:gradle.
>
Unable to load Maven meta-data from https://repo1.maven.org/maven2/com/android/tools/build/gradle/maven-metadata.xml.
>
Could not GET 'https://repo1.maven.org/maven2/com/android/tools/build/gradle/maven-metadata.xml'.
>
repo1.maven.org: nodename nor servname provided, or not known
* 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: 30.753 secs
/Users/gregg/src/hft-mobile-app/platforms/android/cordova/node_modules/q/q.js:126
throw e;
^
Error code 1 for command: /Users/gregg/src/hft-mobile-app/platforms/android/gradlew with args: cdvBuildDebug,-b,/Users/gregg/src/hft-mobile-app/platforms/android/build.gradle,-Dorg.gradle.daemon=true
ERROR building one of the platforms: Error: /Users/gregg/src/hft-mobile-app/platforms/android/cordova/build: Command failed with exit code 1
You may not have the required environment or OS to build this project
Error: /Users/gregg/src/hft-mobile-app/platforms/android/cordova/build: Command failed with exit code 1
at ChildProcess.whenDone (/usr/local/lib/node_modules/phonegap/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:131:23)
at ChildProcess.emit (events.js:110:17)
at maybeClose (child_process.js:1015:16)
at Process.ChildProcess._handle.onexit (child_process.js:1087:5)
Why is the command line version phoning home? How do I get this to build 100% offline?
Note: I see this error as the 2nd line when trying to build offline
cp: no such file or directory: /Users/gregg/src/hft-mobile-app/icon.png
But as you can see that error does not occur online. Plus supposedly whatever that issue was was fixed according to this
I'm on OSX, I've got the Android SDK installed. I had no idea it was calling home. How do I get it to build offline?
This is what I have experienced till now. Ionic uses gradle for android build. It first time downloads all the dependencies from internet. So internet is most for first gradle build but it caches them and no internet is needed for further build.Since you are having problem why don't you globally update your cordova and ionic.
npm install -g cordova ionic