question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Android] Cannot read property 'debugHosts' of undefined

See original GitHub issue

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:

  1. react-native init <project-name>
  2. npm install --save realm
  3. rnpm link realm
  4. 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"
  }
}

image

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:4
  • Comments:20 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
laclancecommented, Dec 8, 2016

Fixed by closing react-native packager again, closing simulator and running npm cache clean, npm start and react-native run-ios

1reaction
frangeriscommented, Jul 21, 2016

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 called MainApplication.java, so,

Event running rnpm link realm using rnpm v1.9.0 do not fix, why? when you run the link rnpm it only updates the file MainActivity.java not the new one, I don’t know why, but I have installed the lastest verion of rnpm, run the link and it only changed the old one adding the import line:

import io.realm.react.RealmReactPackage;

So, just move that line to MainApplication.java and add the package to the list returned as @octohedron has said.

Add the module in your app’s /android/…/MainApplication.Java file, should look like this

@Override
protected List<ReactPackage> getPackages() {
    return Arrays.<ReactPackage>asList(
        new MainReactPackage(),
        new RealmReactPackage() // this line
    );
}

Another issue you could have is this:

screen shot 2016-07-21 at 5 18 21 pm copy

Just go to ./android.settings.grandle and add this:

include ':realm'
project(':realm').projectDir = file('../node_modules/realm/android')

Hope that help…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot read property 'debugHosts' of undefined #1150 - GitHub
I have the problem "Cannot read property 'debugHosts' of undefined", I know this issue was closed but I believe it comes back again....
Read more >
react native - Cannot read property 'debugHosts' of undefined
Steps to fix: rnpm link realm. Add the module in the MainApplication.Java file, should look like this @Override protected List<ReactPackage> ...
Read more >
Cannot read property 'debugHosts' of undefined -
I have the problem "Cannot read property 'debugHosts' of undefined", I know this issue was closed but I believe it comes back again....
Read more >
Cannot read property 'debugHosts' of undefined-React Native
Coding example for the question Cannot read property 'debugHosts' of undefined-React Native.
Read more >
error cannot read property 'configurations' of undefined. react ...
I think the important part that I was missing even previously is to run pod install for iOS. For Android, the reason it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found