I was developing a React Native project as always; when I encountered the following error after doing react-native run android or equivalently cd android && ./gradlew installDebug.
It's just over the last step that this exception is caught:`
:app:assembleDebug
:app:installDebug
Exception in thread "Device List Monitor" java.lang.NullPointerException
at com.android.ddmlib.EmulatorConsole.checkConnection(EmulatorConsole.java:317)
at com.android.ddmlib.EmulatorConsole.getConsole(EmulatorConsole.java:231)
at com.android.ddmlib.DeviceMonitor.queryAvdName(DeviceMonitor.java:248)
at com.android.ddmlib.DeviceMonitor.updateDevices(DeviceMonitor.java:220)
at com.android.ddmlib.DeviceMonitor.access$400(DeviceMonitor.java:65)
at com.android.ddmlib.DeviceMonitor$DeviceListUpdateListener.deviceListUpdate(DeviceMonitor.java:662)
at com.android.ddmlib.DeviceMonitor$DeviceListMonitorTask.processIncomingDeviceData(DeviceMonitor.java:847)
at com.android.ddmlib.DeviceMonitor$DeviceListMonitorTask.run(DeviceMonitor.java:781)
at java.lang.Thread.run(Thread.java:745)
> Building 97% > :app:installDebug`
I'm coding on react-native version 0.43.2 and react-native-cli 2.0.1, also npm 4.1.2 and yarn 0.21.3; Ubuntu 16.04. So everything is armed to teeth by the latest version but I still can't figure out the problem. It happens even for a project I just create by react-native init, it's every where. :(
P.S. be sure my emulator is up and running and the problem isn't due to it.
Try restarting adb in to make it probe the local 5554 port
killall adb; adb devices
Actually, I never found the reason or the solution to the problem. But what I know, I went on with my daily work, and after a day or two (with a couple of restarts in this period) it began working again. And till now, I haven't encountered the problem again.
try to specify the path for sdk/build-tools in the terminal
export PATH="Users/YOURUSERNAME/Library/Android/sdk/build-tools/...":$PATH
after that restart the emulator and try
npm run android
The fix I have found that works for me is to:
Close the emulated device so you have nothing listed when running adb devices
Run react-native run-android so the build fails correctly with a No connected devices! error
Restart the emulator and run react-native run-android again
Unfortunately I still have to run this after every restart, would love to get to the root cause and fix it once and for all!
If you had hit the following error while installing watchman, you will most likely hit the issue mentioned in this discussion
Warning: The post-install step did not complete successfully
If this is the case, check what the watchman window shows. If it is something like this:
Watchman: watchman --no-pretty get-sockname returned with exit code=1, signal=null, stderr= 2018-08-24T17:37:44,142: [0x7fffab20d380] while computing sockname: failed to create /usr/local/var/run/watchman/macbookpro-state: No such file or directory
Do
> brew uninstall watchman
> cd /usr/local/var/
> sudo chown -R $(whoami) var
> brew update
> brew install watchman
Kill/close the emulator device and run the command
> react-native run-android
You should see the action fail with message like
> com.android.builder.testing.api.DeviceException: No connected devices!
Now, rerun the command to see the compilation successful and the app opening up in the emulator
> react-native run-android
Related
OS: Linux Ubuntu
CLI or Expo: CLI
RN Version: 0.70.6
I start my React Native project with the following commands:
yarn start
yarn react-native run-android
It works when a real device connected to my PC and the project starts on my device. But it does not work with an Android Emulator.
When I try with an emulator:
yarn start command shows usual outputs. No error, nothing. Seems to work correctly
yarn react-native run-android also same. Build successful. No error or warning.
adb devices command shows my emulator correctly.
But emulator does not start my project. I can see my project icon on the emulator. When I double click to my project, I just see a blank screen for one second or less and it closed again.
When i try to reload metro using r command on terminal it says no apps connected.
I think the emulator builds the app but not connect to metro properly. I don't know why. I cannot see any error or warning messages.
I tried ./gradlew clean and delete node_modules and install but it didn't work.
I also tried yarn start --port 8081 but it also didn't work.
EDIT: For testing purpose, I created a new project with `npx react-native init AwesomeProject' and it works on the emulator. So I think the problem is only about the other project.
SOLUTION:
In my case it was because of Flipper version. When I changed it from 0.125 to 0.144 my project started on an android emulator properly.
Here is the link where i found the solution:
react-native-issue-in-github
I have that weird error when running "npx react-native run-android" that is only occuring in a specific react native project only on my Macbook with android simulator. Other RN apps are running fine on my mac with android.
On a windows pc this specific RN app is also working fine.
Error: spawn Unknown system error -8
at ChildProcess.spawn (node:internal/child_process:413:11)
at Object.spawn (node:child_process:743:9)
at module.exports (/Users/hannes/Projects/test2/mapp/native-frame/node_modules/#react-native-community/cli-platform-android/node_modules/execa/index.js:205:26)
I tried the following things:
deleting package-lock.json
rm -r node_modules + gradlew clean (in android folder)
creating a new virtual device in android studio with API level according to build.gradle
upgrading node to 18.8.0
upgrading npm to 8.18.0
npm cache clean –force
Somebody any ideas?
After using "run-ios" in the meantime I had to face the problem again and found a solution.
npx react-native run-android
this line is using the port 8081 and my macbook did sometimes use this port for another service
lsof -i tcp:8081
this command showed the process that was running
COMMAND PID FD DEVICE SIZE/OFF NODE NAME
node 44492 24u 0t0 TCP *:sunproxyadmin (LISTEN)
I terminated this process but still got the error message.
So I called the gradle command for building and installing the app myself.
cd android && ./gradlew app:installDebug -PreactNativeDevServerPort=8081
This worked, the app got build and installed on my android device but I got multiple error messages in the android studio run console starting with:
Could not find generated setter for class
this error was also addressed on GitHub and Stackoverflow
So building and installing the app in production mode solved the problem for me.
./gradlew app:installRelease
I installed android studio, I configured the environment variables and everything, I installed genymotion and created a device, but running the react-native run-android in the project folder occurs the following error:
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. Run CLI with --verbose flag for more details.
please help me in this problem. React-native does not find Genymotion disositivo, in this link has more details: https://pt.stackoverflow.com/questions/382115/react-native-n%C3%A3o-reconhece-genymotion
It tries to connect the emulator to the ADB, by the IP of the device. To check the IP of the device, simply click on an emulator window, the IP address is in the title of the window.
No terminal will run the command:
$ adb connect ip_of_your_emulator:5555
Soon after, run:
$ adb devices
If the name of your file appears in the list, your emulator has been connected successfully!
With the emulator open, simply run the native run-android in the folder of your project.
I've had the same problem earlier this month. As far as I can tell the newer versions of Genymotion don't register on adb devices, a user in the Expo forums speculates it's because they have a paywall now.
I recommend switching to Android Studio, that's what I did to solve my problem.
I ran react-native with the --verbose flag, and got the following error:
...
error Failed to install the app. Make sure you have the Android development
environment set up: https://reactnative.dev/docs/environment-setup.
Error: spawn ./gradlew EACCES
...
So, I gave permissions to the android/gradlew folder as follows:
chmod 755 android/gradlew
But then, I got an error regarding Google Play Licenses:
error Failed to install the app. Please accept all necessary Android SDK
licenses using Android SDK Manager: "$ANDROID_HOME/tools/bin/sdkmanager --licenses".
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
So yeah, pretty the solution was:
Downloading Android Studio with its own SDK
Change the env variabe ANDROID_HOME to the one installed with Android Studio
Installing Google Play Licensing Library (In Android Studio, go to Settings>SDK Manager>SDK Tools, select Google Play License Library and then install)
I am getting this error. I have tried running npm install multiple times but this is still there, how to get this worked?
Most times you may not need to delete your node modules and reinstall as some answers may suggest, if you have installed your packages previously without errors. Most times all you need to do is to close or terminate metro bundler and restart. Or just run react-native run-ios (or android) after terminating the metro bundler.
At first, remove all the installed npm packages and install them again by running the following command:
$ rm -rf /node_modules && npm i
And then, start React-Native again by the following command:
$ react-native start
For me, I realized another app was running.
I stopped Metro Bundler then run react-native run-ios, and it worked!
As suggested by soroush in the comment, I run
rm -rf /node_modules && npm install
react-native run-android
It worked, but actually the problem was with firebase#5.0.4 , I installed firebase 5.0.3 and everything was normal.
npm install firebase
This can crop up if Metro Bundler is already running. You don't necessarily need to nuke your node_modules.
Often this can be fixed (on Mac) with:
Find process listening on 8081: sudo lsof -i :8081
8081 is the port Metro bundler runs on by default.
Kill process: kill -9 [pid]
for the example in the image this would be kill - 9 20292
Run app again via xcode, react-native cli, etc.
Ref: Docs
I've been trying to install phonegap on my Windows 7 laptop for the past couple days and I can't seem to get pass a specific error.
14828 error Error: EPERM, open 'C:\Users\MyUserName\AppData\Roaming\npm\node_modules\phonegap\node_modules\phonegap-build\node_modules\phonegap-build-api\node_modules\request\node_modules\form-data\node_modules\combined-stream\node_modules\delayed-stream\test\integration\test-max-data-size.js'
npm ERR! Please try running this command again as root/Administrator.
What I've tried so far
tried running 'npm install -g phonegap' on both node.js x86 and 64bit
running installation as admin (right click cmd -> run as admin)
The error message is telling me I'm missing test-max-data-size.js in the path
When I go to the that folder, I do see other scripts (like test-handle-source-errors.js and test-delayed-stream.js) ... but not tast-max-data-size.js
The error suggests me to run as Administrator but I am already am ...
Is there anything I can try to further throubleshoot this issue?