realm-js: [Android] Cannot read property 'debugHosts' of undefined
Hi There, i just did a vanilla installation for the realm specified here. However, i got this exception. Below is a screenshot of the app. I was not able to launch it at all. If i remove the constructor for Realm the app works.
Steps Followed:
- react-native init <project-name>
- npm install --save realm
- rnpm link realm
- react-native run-android
package.json
{
"name": "Realm14",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start"
},
"dependencies": {
"react": "15.2.1",
"react-native": "^0.29.0",
"realm": "^0.14.1"
}
}
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 4
- Comments: 20 (1 by maintainers)
Fixed by closing react-native packager again, closing simulator and running npm cache clean, npm start and react-native run-ios
I get into the same issue, here how I solved it:
As @gasperz says, the issue is related to
react-native: 0.29+
breaks compatibility, they added support for a new file calledMainApplication.java
, so,Event running
rnpm link realm
usingrnpm v1.9.0
do not fix, why? when you run the linkrnpm
it only updates the fileMainActivity.java
not the new one, I don’t know why, but I have installed the lastest verion ofrnpm
, run the link and it only changed the old one adding the import line:So, just move that line to
MainApplication.java
and add the package to the list returned as @octohedron has said.Another issue you could have is this:
Just go to
./android.settings.grandle
and add this:Hope that help…