every time i start a new RN project and start to run the android emulator it shows this 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 app:installDebug -PreactNativeDevServerPort=8081
Could not write standard input to Gradle build daemon.
I did everything and nothing seems to work!
Fixed
I just had to add a local. proprieties file in my android root project folder and add the Sdk Path. " sdk dir = /home/USERNAME/android/Sdk "
Update the ./bash_profile [./profile] file with the ANDROID_HOME path tools
and do a sudo ./gradlew clean command
I hope this helps
Android studio is installed and you have an emulator or device started ?
Screenshoot of the error ?
What gives the command : adb devices ?
I restarted my emulator and when i do adb devices it shows that it recognized and connected
https://i.stack.imgur.com/lw3PM.png
Related
I have initiated successfully a new react-native project. Then, every time I try to run my newly built project using the command react-native run-android, it gets stucks on info Starting JS server....
Here is the output:
$ react-native run-android
info Running jetifier to migrate libraries to AndroidX".
You can disable it using "--no-jetifier" flag.
Jetifier found 855 file(s) to forward-jetify. Using 4 workers...
info Starting JS server..."
I tried restarting the laptop and switching emulators. I don't know what else to do anymore.
How do I solve the problem?
Kill the automatically popped up metro bundler command prompt
Kill the command terminal which is running react-native run-android
Now Run react-native start This will start your js server
In new command prompt window run react-native run-android
The app came up in 5 mins in an emulator.
Linux:
Go to the terminal and type:
react-native start
and then in OTHER terminal, inside your project folder:
yarn android
or
npm run android
Temporary fix:
REACT_TERMINAL= react-native run-android
in my case with manjaro + xfce4:
REACT_TERMINAL=xfce4-terminal react-native run-android
or puts in your .bashrc:
export REACT_TERMINAL=xfce4-terminal
font: https://github.com/facebook/react-native/issues/26097
I had the same problem. I started a project yesterday and it worked, started a new one today and it didn't work. The problem seems to be "#react-native-community/cli-platform-android". The version that showed up today is 2.8.2 as opposed to 2.7.0 for yesterday's project.
I used:
npm install #react-native-community/cli-platform-android#2.7.0
This is not a optimal solution, but it will get you going.
I had the exact same frustrating issue for a very different reason than mentioned in other answers.
As explained in this SO answer Android adb binds to port 5037 and I installed some program which took this port so adb was hanging silently (why adb! .. say something!)
Commands to test if this your issue cause:
test any adb command and see if it hangs, eg:
adb devices
If it does, then check who is using the port:
sudo lsof -i :5037
In my case(Manjaro OS)
First:
npm start
Then in a separate terminal:
npm run android
The best solution that I constantly find myself using, is going to the application manager on android, then clearing the data of the app. Running the app afterwards goes smoothly without lagging.
Reinstalling android studio with a new emulator or changing the app name in app.json , build.gradle and android manifest.xml solved the issue.
I would like to build a NativeScript application for Android, but I'm stuck when trying to build the application using tns build android command.
I get this error: "Command gradlew.bat failed with exit code 1"
My NativeScript version is: 3.2.1
I've also set up the Environment Variables for both ANDROID_HOME and JAVA_HOME:
and these are my Android SDK Platforms installed:
As #pkanev suggested, I've opened /.gradle/ and removed the wrapper directory. After that, I run tns build android again, but then it thrown me a new error:
'FAILURE: Build failed with an exception.'
'Unexpected lock protocol found in lock file. Expected 3, found 0.'
Any thought on this?
Looks like the gradle wrapper you got was corrupted. Delete your Gradle and let the android build redownload it.
Open <User_dir>/.gradle/ and remove the wrapper dir.
Rerun tns build/run android
Finally, I've managed to fix it by removing the whole .gradle folder from my <User_directory>, then I've built it again with tns build android.
Thank you #pkanev for your help!
When I run (Ionic run android )ionic project, it build success but there was an issue in deploying to device.
this is the error in my cmd
Follow below steps
Create virtual device from android adb manager.
Open virtual device(emulator).
Open termainal and check your emulator is connected or
not. $ adb devices.
If your emulator is connected then open
terminal and go to your root folder of project.
run followingcommand
$ ionic run android
I hope its work for you
I am attempting to run a Meteor project on an Android device and/or emulator. When I run either meteor run --verbose android or meteor run --verbose android-device, I get errors related to Cordova not being able to find certain gradle files. Here's some output from my console:
sarah#sarah-ThinkPad-X220:~/simple-todos$ meteor run --verbose android
Getting installed version for platform android in Cordova project
Checking Cordova requirements for platform Android
[[[[[ ~/simple-todos ]]]]]
=> Started proxy.
=> Started MongoDB.
Local package version is up-to-date: autopublish#1.0.4
<... removed some other "Local package" messages here ...>
Preparing Cordova project from app bundle
Copying resources for mobile apps
Writing new config.xml
Preparing Cordova project for platform Android
Running Cordova app for platform Android with options --emulator
ANDROID_HOME=/home/sarah/Android/Sdk/ |
JAVA_HOME=/usr/lib/jvm/default-java
=> Started your app.
=> App running at: http://localhost:3000/
WARNING : no emulator specified, defaulting to nexus4
Waiting for emulator...oid Emulator |
emulator: UpdateChecker: skipped version check
BOOT COMPLETEpp on Android Emulator -
cp: no such file or directory: /home/sarah/Android/Sdk/tools/templates/gradle/wrapper/gradlew
chmod: File not found: /home/sarah/simple-todos/.meteor/local/cordova-build/platforms/android/gradle/wrapper/gradle-wrapper.properties
sed: no such file or directory: /home/sarah/simple-todos/.meteor/local/cordova-build/platforms/android/gradle/wrapper/gradle-wrapper.properties
Running: /home/sarah/simple-todos/.meteor/local/cordova-build/platforms/android/gradlew cdvBuildDebug -b /home/sarah/simple-todos/.meteor/local/cordova-build/platforms/android/build.gradle -PcdvBuildArch=x86 -Dorg.gradle.daemon=true
events.js:72app on Android Emulator \
throw er; // Unhandled 'error' event
^
Error: spawn ENOENT
at errnoException (child_process.js:1011:11)
at Process.ChildProcess._handle.onexit (child_process.js:802:34)
=> Errors executing Cordova commands:
While running Cordova app for platform Android with options --emulator:
Error: Command failed:
/home/sarah/simple-todos/.meteor/local/cordova-build/platforms/android/cordova/run --emulator
at ChildProcess.exitCallback (/tools/utils/processes.js:137:23)
at ChildProcess.emit (events.js:98:17)
at Process.ChildProcess._handle.onexit (child_process.js:820:12)
ExitWithCode:1
Indeed, the files and directories it is trying to access are not there. $ANDROID_HOME/tools/template/gradle/wrapper does not have a directory gradlew
sarah#sarah-ThinkPad-X220:~/Android/Sdk/tools/templates/gradle/wrapper$ ls
gradle
Likewise, there are no files at all in my ~/simple-todos/.meteor/local/cordova-build/platforms/android/gradle/wrapper directory, so there is no gradle-wrapper.properties.
I'm also quite uncertain about the meaning of the spawn ENOENT error.
How can I fix this?
EDIT: I wanted to test that gradle worked at all on my machine, so I made an app in Android Studio and ran it on my phone-- worked fine. My Meteor project still doesn't run on Android, but I think this tells me that gradle is working (somewhere) on my computer.
EDIT: I searched for a gradlew directory on my computer and the only ones I found were in an android-studio, not in my $ANDROID_HOME(~\Android/Sdk). Not sure what to do with this info, but it seems relevant.
EDIT It occurred to me that the output of gradle -v might be useful:
$ gradle -v
------------------------------------------------------------
Gradle 2.5
------------------------------------------------------------
Build time: 2015-08-31 14:26:53 UTC
Build number: none
Revision: UNKNOWN
Groovy: 2.4.3
Ant: Apache Ant(TM) version 1.9.6 compiled on July 8 2015
JVM: 1.7.0_95 (Oracle Corporation 24.95-b01)
OS: Linux 4.2.0-23-generic amd64
Initial disclaimer: I'm not super familiar with the particular tools you are using on top of the android+gradle, but I'll try to help as best I can.
This is worth reading: https://docs.gradle.org/current/userguide/gradle_wrapper.html
Also, you probably want to get gradle setup on your system first, and double check that gradle home is set (*not always necessary, but depends on what other things like android studio, etc. pull in automagically): https://docs.gradle.org/current/userguide/installation.html
My guess is that the tooling you are using is trying to find the system gradle and/or gradlew it expects to have available within your project...and that it is getting mixed up.
I'm following the Get Started tutorial on https://cordova.apache.org/#getstarted but I'm getting an error despite following the instructions clearly, this is what I did:
npm install -g cordova
cordova create myApp
cd myApp
cordova platform add browser
cordova run browser
but at the end of the last command, I get an error:
C:\code\cordova\test
λ cordova run browser
Running command: cmd "/s /c "C:\code\cordova\test\platforms\browser\cordova\run.bat""
C:\code\cordova\test\platforms\browser\cordova\node_modules\cordova-serve\node_modules\q\q.js:155
throw e;
^
Error: listen EACCES
at exports._errnoException (util.js:746:11)
at Server._listen2 (net.js:1139:19)
at listen (net.js:1182:10)
at Server.listen (net.js:1267:5)
at module.exports (C:\code\cordova\test\platforms\browser\cordova\node_modules\cordova-serve\src\server.js:134:8)
at C:\code\cordova\test\platforms\browser\cordova\node_modules\cordova-serve\src\platform.js:45:16
at _fulfilled (C:\code\cordova\test\platforms\browser\cordova\node_modules\cordova-serve\node_modules\q\q.js:834:54)
at self.promiseDispatch.done (C:\code\cordova\test\platforms\browser\cordova\node_modules\cordova-serve\node_modules\q\q.js:863:30)
at Promise.promise.promiseDispatch (C:\code\cordova\test\platforms\browser\cordova\node_modules\cordova-serve\node_modules\q\q.js:796:13)
at C:\code\cordova\test\platforms\browser\cordova\node_modules\cordova-serve\node_modules\q\q.js:857:14
ERROR running one or more of the platforms: Error: cmd: Command failed with exit code 1
You may not have the required environment or OS to run this project
Does anyone have any idea why this is happening?
I'm using NodeJS v0.12.7 and Cordova 5.4.0
I have had a similar issue on my Debian 8.3 (jessie) with an installed Chromium from the offical debian package-sources.
The detailled error message was:
Error: Error executing "google-chrome --user-data-dir=/tmp/temp_chrome_user_data_dir_for_cordova http://localhost:8000/index.html": /bin/sh: 1: google-chrome: not found
To fix the issue, I have downloaded the (Google-) Chrome-Browser directly from their website, and installed the .deb-package.
After that I did a
cordova platform rm browser
cordova platform add browser
cordova build browser
cordova run browser
and it finally worked.
Summary:
Chromium doesn't work - use chrome
Although the tutorial you linked says browser for some reason. I don't see it on their "supported platform list", try using a platform which you think you're going to develop for and see if you have the same issues.
Link to the platform list (odd that browser isn't listed): https://cordova.apache.org/docs/en/latest/guide/support/index.html
This is a late reply, maybe will help someone else.
instead of
cordova run browser
You should try "cordova serve" command after the add platform browser..
cordova platform add browser
cordova serve
after this hopefully if everything is set up right , you will get a message
"server runing on localhost:/port" . Just goto that address on your browser..
see the magic.
I'm confused why you want to deploy it from the command line to a browser instead of a device or an emulator.
Wouldn't you just open index.html in the browswer?
Take a look at the Cordova Windows Platform Guide
It goes more into detail about running Cordova on a windows platform.
Requirements:
To develop apps for Windows platform:
Windows 8.0, 8.1, or 10, 32 or 64 bit Home, Pro, or Enterprise
Visual Studio 2013
To develop apps for Windows 10:
Visual Studio 2015 RC or higher
Note: For Windows 10, the Visual Studio installer has an option to install tools to build Universal Windows Apps. You must ensure that this option is selected when installing to install the required SDK.
Create a New Project
At this point, to create a new project you can choose between the cross-platform CLI tool described in The Command-Line Interface, or the set of Windows-specific shell tools. The CLI approach below generates an app named HelloWorld within a new hello project directory:
> cordova create hello com.example.hello HelloWorld
> cd hello
> cordova platform add windows
Here's the corresponding lower-level shell-tool approach:
C:\path\to\cordova-windows\package\bin\create.bat C:\path\to\new\hello com.example.hello HelloWorld
Build the Project
If you are using the CLI in development, the project directory's top-level www directory contains the source files. Run either of these within the project directory to rebuild the app:
> cordova build
> cordova build windows # do not rebuild other platforms
> cordova build windows --debug # generates debugging information
> cordova build windows --release # signs the apps for release
Here's the corresponding lower-level shell-tool approach:
C:\path\to\project\cordova\build.bat --debug
C:\path\to\project\cordova\build.bat --release
The clean command helps flush out directories in preparation for the next build:
C:\path\to\project\cordova\clean.bat
Deploy the app
To deploy Windows package:
> cordova run windows -- --win # explicitly specify Windows as deployment target
> cordova run windows # `run` uses Windows package by default
Also before executing the command:
cordova create myApp
make sure to cd into a user directory or a directory where you will keep your cordova apps
Ok, I also had this problem, and couldn't figure out what was going on for the life of me. I finally figured it out:
The guy didn't have Chrome installed. Installed Chrome, poof, problem solved.
Let this be a lesson for us all.