ReactNative build for android just freezes in the last step

I have always been developing a React Native project; when I encountered the following error after running react-native run android or equivalently cd android && ./gradlew installDebug . It's just 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 code in reaction version 0.43.2 and react-native-cli 2.0.1, also npm 4.1.2 and yarn 0.21.3; Ubuntu 16.04. Thus, everything is ready for the teeth according to the latest version, but I still can not understand the problem. This happens even for a project that I just create using react-native init , anywhere. :( Postscript make sure my emulator is running and the problem is not because of this.

+13
android compilation react-native
source share
5 answers

Try restarting adb so that it examines local port 5554

 killall adb; adb devices 
+15
source share

In fact, I did not find the cause or solution to the problem. But what I know, I continued my daily work, and after a day or two (with a couple of restarts during this period), it started working again. And so far I have not encountered the problem again.

0
source share

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 
0
source share

I found a fix that works for me:

  1. Close the emulated device so that when you run adb devices nothing is displayed
  2. Run the software react-native run-android so that the build fails with No connected devices! mistake
  3. Restart the emulator and run react-native run-android again

Unfortunately, I still have to run this after every restart, I would like to find the reason and fix it once and for all!

0
source share

If you encounter the following error while installing the guard, you will most likely encounter the problem mentioned in this discussion.

 Warning: The post-install step did not complete successfully 

If so, check what the watchman window displays. 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 device emulator and run the command

 > react-native run-android 

You should see a failed action with a message like

 > com.android.builder.testing.api.DeviceException: No connected devices! 

Now repeat the command to see that the compilation was successful and the application opens in the emulator.

 > react-native run-android 
0
source share

All Articles