becvert / cordova-plugin-zeroconf

Cordova ZeroConf Plugin
MIT License
81 stars 57 forks source link

cordova.plugins.zeroconf is undefined #22

Closed alambrinidis closed 7 years ago

alambrinidis commented 7 years ago

Hello,

I'm testing your plugin to simply display the hostname (for now) of the device on Android 6.0.1 from a computer running on Ubuntu 16.04.

I'm using the getHostname function in the same exact way as shown on the readme for this plugin and the console logs tell me cordova.plugins.zeroconf is Undefined.

Would you have an idea as to why I can't get it to work?

becvert commented 7 years ago

You're remote debugging (Chrome Dev Tools for instance), right?

If you're getting cordova.plugins.zeroconf is Undefined that probably means the plugin is not well installed. Check your install. Remove and re-add the plugin if necessary.

alambrinidis commented 7 years ago

I already tried removing and re-adding the plugin. Several times. Way too many times.

I only try to output console logs on terminal using phonegap serve --console so I don't use chrome dev tools.

I've been stuck on this for way longer than I would admit, I also tried deploying on iPhone to ensure the device wasn't the problem.

becvert commented 7 years ago

I not familiar with phonegap. Can you check install logs? Also is cordova fully loaded when you call the plugin? i.e. after the devicereadyevent?

alambrinidis commented 7 years ago

Here is the installation log : `Fetching plugin "cordova-plugin-zeroconf" via npm Installing "cordova-plugin-zeroconf" for android Fetching plugin "cordova-plugin-add-swift-support" via npm Installing "cordova-plugin-add-swift-support" for android ANDROID_HOME=/home/me/Android/Sdk JAVA_HOME=/home/me/Documents/jdk1.8.0_112 Subproject Path: CordovaLib Incremental java compilation is an incubating feature. :clean :CordovaLib:clean

BUILD SUCCESSFUL

Total time: 1.244 secs ANDROID_HOME=/home/me/Android/Sdk JAVA_HOME=/home/me/Documents/jdk1.8.0_112 Subproject Path: CordovaLib Incremental java compilation is an incubating feature. :clean :CordovaLib:clean

BUILD SUCCESSFUL

Total time: 1.576 secs Subproject Path: CordovaLib Installing "cordova-plugin-zeroconf" for browser Installing "cordova-plugin-add-swift-support" for browser Error loading cordova-browser Installing "cordova-plugin-zeroconf" for ios Installing "cordova-plugin-add-swift-support" for ios`

Yes, cordova is fully loaded when I call the plugin.

Thanks for your swift answers.

alambrinidis commented 7 years ago

By the way,

If you want to see the code (there isn't much to see) but here's the repository : https://github.com/alambrinidis/cordova-for-spacebro. In case I made a typo or something, I triple-checked it but you know, human error.

Thank you very much.

becvert commented 7 years ago

I quickly looked at your repo. Seems ok. But in the install logs, Error loading cordova-browser. This plugin does not support the browser platform. It's probably not it but just to be sure, could you remove the browser platform, remove/add the plugin and have a try.

alambrinidis commented 7 years ago

I also thought it was nothing but I didn't try it until now. zeroconf is still undefined. I should have tried that earlier though.

I think I'll just try removing cordova from my computer completely.

Thanks again

becvert commented 7 years ago

is cordova.plugins defined?

alambrinidis commented 7 years ago

Yes, cordova.plugins is correctly defined.

Reinstalling cordova did not change anything

julianCast commented 7 years ago

As far as I know you have to test it via device, it won't work via browser.

becvert commented 7 years ago

@alambrinidis I cloned your repo, built your project with Android Studio and installed the app. It's working! I don't know what's happening on your side. A Phonegap problem? I would check runtime logs too.

becvert commented 7 years ago

PhoneGap serve @JulianGarciaCastillo you're right. @alambrinidis, from what I understand, you did not install the app, but a server was started to serve your app files. You're basically displaying a website, the browser platform which this plugin does not support. So you need to actually phonegap install android instead.

alambrinidis commented 7 years ago

This might actually be it.. Testing right now and reporting back. Thank you very much

alambrinidis commented 7 years ago

This was it.

Thank you both for your time.

(Sorry)

becvert commented 7 years ago

By the way, are you building some kind of (free) app based on this plugin? If that's the case, please let us know when you release it. Thanks.