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')
Related
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.
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)
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
Error:Execution failed for task 'app:generateDebugBuildConfig'
java.io.FileNotFoundException: C:\Users\bok\Desktop\Zipzap\app\build\generated\source\buildConfig\debug\com\storie\myapp \BuildConfig.java (Le chemin d’accès spécifié est introuvable)
What's the solution ..
I hope to find a solution to this problem
Try to clean project this is working for me
for android
$ cd android
$ ./gradlew clean
BUILD SUCCESSFUL in 5s
1 actionable task: 1 executed
Changing port worked for me
You Could try:
react-native run-android --port=8082
Try to clean and rebuild project or you can try to remove whole build folder and build after removing. If it won't help, show your build.gradle, your current information isn't enough to recognise the reason of problem.
React Native
Faced similar issue while building react native app. Running on the different port as the default port (8081) is used by some other app.
Command to build the app.
react-native run-android --port=8082
Solution
Removed extra attribute android:screenOrientation="portrait". If you check the log, it says
lineNumber: 26; columnNumber: 56; Attribute "screenOrientation" bound
to namespace "http://schemas.android.com/apk/res/android" was already
specified for element "activity".
hence removed the same attribute. This was being added multiple times
Error log
Configure project :react-native-webview
:react-native-webview:reactNativeAndroidRoot /Users/PROJECT_PATH/node_modules/react-native/android
Task :app:generateDebugBuildConfig FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:generateDebugBuildConfig'.
org.xml.sax.SAXParseException; systemId: file:/Users/PROJECT_PATH/android/app/src/main/AndroidManifest.xml; lineNumber: 26; columnNumber: 56; Attribute "screenOrientation" bound to namespace "http://schemas.android.com/apk/res/android" was already specified for element "activity".
* 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
32 actionable tasks: 1 executed, 31 up-to-date
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 installDebug
Go to project root.
Go to android folder.
cd android
Clean gradle.
.\gradlew clean
(./gradlew clean didnot work for me for some reason.)
Go back to root.
cd ..
Run react native.
npx react-native run-android
In android studio,
On the Menu Bar, go to build
Click clean project and wait for project to clean
Then on the menu bar again, go to build -> rebuild project and wait for project to rebuild.
That's all
I created an Android platform with success, but when I run
ionic build android
I get the following error:
FAILURE: Build failed with an exception.
* What went wrong:
Could not create an instance of type org.gradle.invocation.DefaultGradle_Decorated.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
ERROR building one of the platforms: Error code 1 for command: /home/skylek/Ionic/conFusion/platforms/android/gradlew with args: cdvBuildDebug,-b,/home/skylek/Ionic/conFusion/platforms/android/build.gradle,-Dorg.gradle.daemon=true,-Pandroid.useDeprecatedNdk=true
You may not have the required environment or OS to build this project
Error: Error code 1 for command: /home/skylek/Ionic/conFusion/platforms/android/gradlew with args: cdvBuildDebug,-b,/home/skylek/Ionic/conFusion/platforms/android/build.gradle,-Dorg.gradle.daemon=true,-Pandroid.useDeprecatedNdk=true
Can anyone help me out.
I had exactly the same problem with an ionic project build with the m-ionic yeoman generator, that was uploaded to the ionic cloud.
It started after my computer crashed with a 'blue screen of death', in the middle of a compilation task
What We did to fix the project was to copy and replacing the gradle and corodova files :
.gradle
cordova
CordovaLib
gradle
gradlew.bat
from other ionic>platform>android project that I knew was working fine, beacuse we thought the Cordova files might be corrupted, and early in the project we fixed a similar compilation problem that way. It did not fixed the problem. But then removed the ionic cloud configuration files: ionic.project .
And it worked!!
I hope it could help you!