I have the problem "Cannot read property 'debugHosts' of undefined", I know this issue was closed but I believe it comes back again.
"react-native": "^0.46.2",
"realm": "^1.10.0",
Android 7.0 device
Files "MainApplication.java", "build.gradle" and "settings.gradle" are correct.
But not every running will encounter this issue. Most time it is good for the first load when android is connected to the PC.
There is always an error before this issue:
BUILD SUCCESSFUL
Total time: 10.622 secs
Running D:Androidsdk/platform-tools/adb -s KWG5T16722008100 reverse tcp:8081 tcp:8081
Starting the app on KWG5T16722008100 (D:Androidsdk/platform-tools/adb -s KWG5T16722008100 shell am start -n com.BLEHygrometer/com.BLEHygrometer.MainActivity)...
Starting: Intent { cmp=com.BLEHygrometer/.MainActivity }
Running D:Androidsdk/platform-tools/adb -s 587f667d1665 reverse tcp:8081 tcp:8081
error: closed
Could not run adb reverse: Command failed: D:Androidsdk/platform-tools/adb -s 587f667d1665 reverse tcp:8081 tcp:8081
Starting the app on 587f667d1665 (D:Androidsdk/platform-tools/adb -s 587f667d1665 shell am start -n com.BLEHygrometer/com.BLEHygrometer.MainActivity)...
java.lang.NullPointerException
at android.os.ServiceManager.getService(ServiceManager.java:62)
at android.app.ActivityManagerNative$1.create(ActivityManagerNative.java:2074)
at android.app.ActivityManagerNative$1.create(ActivityManagerNative.java:2072)
at android.util.Singleton.get(Singleton.java:34)
at android.app.ActivityManagerNative.getDefault(ActivityManagerNative.java:83)
at com.android.commands.am.Am.onRun(Am.java:261)
at com.android.internal.os.BaseCommand.run(BaseCommand.java:47)
at com.android.commands.am.Am.main(Am.java:76)
at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:243)
at dalvik.system.NativeStart.main(Native Method)
[vscode-react-native] Finished executing: react-native.cmd run-android
[vscode-react-native] Executing command: adb -s "KWG5T16722008100" reverse tcp:8081 tcp:8081
[vscode-react-native]
[vscode-react-native] Finished executing: adb -s "KWG5T16722008100" reverse tcp:8081 tcp:8081
[vscode-react-native] Executing command: adb -s KWG5T16722008100 shell am start -n com.BLEHygrometer/.MainActivity
[vscode-react-native] Starting: Intent { cmp=com.BLEHygrometer/.MainActivity }
[vscode-react-native] Finished executing: adb -s KWG5T16722008100 shell am start -n com.BLEHygrometer/.MainActivity
[vscode-react-native] Executing command: adb -s KWG5T16722008100 shell am broadcast -a "com.BLEHygrometer.RELOAD_APP_ACTION" --ez jsproxy true
[vscode-react-native] Broadcasting: Intent { act=com.BLEHygrometer.RELOAD_APP_ACTION (has extras) }
Broadcast completed: result=0
[vscode-react-native] Finished executing: adb -s KWG5T16722008100 shell am broadcast -a "com.BLEHygrometer.RELOAD_APP_ACTION" --ez jsproxy true
[vscode-react-native] Starting debugger app worker.
[vscode-react-native] Established a connection with the Proxy (Packager) to the React Native application
[vscode-react-native] Debugger worker loaded runtime on port 21238
[vscode-react-native] Debugger worker loaded runtime on port 13649
Warning: View.propTypes has been deprecated and will be removed in a future version of ReactNative. Use ViewPropTypes instead.
Warning: PropTypes has been moved to a separate package. Accessing React.PropTypes is no longer supported and will be removed completely in React 16. Use the prop-types package on npm instead. (https://fb.me/migrating-from-react-proptypes)
Cannot read property 'debugHosts' of undefined
@adyanced It looks like adb reverse fails. Can you verify that adb reverse works in other situations?
Hey I have the same issue but on iOS, i didn't yet tested it on android, I already posted a reply on #868.
I'm using the below versions
"react-native": "0.46.0",
"realm": "^1.10.1".
the problem is that in the destructuring of NativeModules in index.js (node_module/realm/lib/browser), so I'm guessing an Xcode linking issue? I'm not using cocoapods. and my Xcode project doesn't include/link the .a files for realm.

I guess the problem is solved after doing the following steps.
npm install --save realmrnpm link realmso the problem was indeed the library linking
@adyanced Do the steps outlined by @geniuscd solve the issue for you?
Sorry for late. The issue is raised when I use VSCode to debug, but everything is good while using command line 'react-native run-android'. I think may be it is not a library linking problem
@adyanced Thanks for the update. Which version of https://github.com/Microsoft/vscode-react-native do you use?
Sorry I forgot it cause it is automatically upgraded to V0.4.1 several days ago, maybe V0.3.2 or V0.4.0. Actually now I comment all codes relating to realm while debugging. Otherwise the speed is not acceptable as you know. It's really sad.
Hi, I tried to reproduct this issue just now and it comes.
"react-native": "^0.47.1",
"realm": "^1.10.1"
VSCode: V1.15.0
React Native Tools (VSCode extension): V0.4.1
And I got this:
Installing APK 'app-x86-debug.apk' on 'Nexus_5X_API_25(AVD) - 7.1.1' for app:debug
Installed on 1 device.
...
[vscode-react-native] Starting debugger app worker.
[vscode-react-native] Established a connection with the Proxy (Packager) to the React Native application
[vscode-react-native] Debugger worker loaded runtime on port 28669
[vscode-react-native] Debugger worker loaded runtime on port 10443
Cannot read property 'debugHosts' of undefined
Pay attention to 'Nexus_5X_API_25(AVD) - 7.1.1' which is a virtual device. Maybe it is the point because it runs well on an android phone.
@adyanced Does it work in an emulator running an older Android version.
Same with Android 6.0
Installing APK 'app-x86-debug.apk' on 'Nexus_4_API_23(AVD) - 6.0' for app:debug
Installed on 1 device.
BUILD SUCCESSFUL
Total time: 20.929 secs
Running D:Androidsdk/platform-tools/adb -s emulator-5554 reverse tcp:8081 tcp:8081
Starting the app on emulator-5554 (D:Androidsdk/platform-tools/adb -s emulator-5554 shell am start -n com.BLEHygrometer/com.BLEHygrometer.MainActivity)...
Starting: Intent { cmp=com.BLEHygrometer/.MainActivity }
[vscode-react-native] Finished executing: react-native.cmd run-android
[vscode-react-native] Executing command: adb -s emulator-5554 shell am broadcast -a "com.BLEHygrometer.RELOAD_APP_ACTION" --ez jsproxy true
[vscode-react-native] Broadcasting: Intent { act=com.BLEHygrometer.RELOAD_APP_ACTION (has extras) }
Broadcast completed: result=0
[vscode-react-native] Finished executing: adb -s emulator-5554 shell am broadcast -a "com.BLEHygrometer.RELOAD_APP_ACTION" --ez jsproxy true
[vscode-react-native] Starting debugger app worker.
[vscode-react-native] Established a connection with the Proxy (Packager) to the React Native application
[vscode-react-native] Debugger worker loaded runtime on port 6067
[vscode-react-native] Debugger worker loaded runtime on port 11302
Warning: PropTypes has been moved to a separate package. Accessing React.PropTypes is no longer supported and will be removed completely in React 16. Use the prop-types package on npm instead. (https://fb.me/migrating-from-react-proptypes)
Cannot read property 'debugHosts' of undefined
@adyanced Do you also see it with version 1.10.3?
Yes, I did see it with 1.10.3 yesterday while running on the Android phone but not emulator.
@adyanced Are you consistently getting the error even after restarting VSCode?
I'm sorry to say it's no effect restarting VSCode. It seems all depend on the luck but bad luck
We have tried to reproduce it, and it happened only once in about 15 debugging session. It seems that Visual Studio Code's react native plugin is a bit unstable when it comes to debugging. I don't think we can help you much :cry:
Ok thank you very much. I will close it
I got this issue on ios. First it was giving error "Can't read property debugHosts of undefined"
I deleted the app and re-installed then app is crashing without any error. When running from xcode it throws exception at
ode_modules/realm/vendor/json.hpp, line 4012.
@bhatti-waqas I believe it has been solved by #1516.
@kneth then why I am facing it. Its been two-three hours wasted but no work around.
Please help.
@bhatti-waqas Please create a new issue as this is closed. Use the template to provide as much relevant info as possible, including instructions on how to reproduce this. A simplified sample project (in github/gist) gives anyone the best chances to help you the fastest.
@bhatti-waqas Please upgrade to 2.0.10.