Search code examples
cordovaphonegap-pluginsphonegap-build

Phonegap error adding module


Trying to add module from build.phonegap.com/plugins/414. But after adding <gap:plugin name="com.badrit.macaddress" version="0.1.0" /> to config.xml and try { window.MacAddress.getMacAddress( function(macAddress) {alert(macAddress);},function(fail) {alert(fail);} ); } catch {... to index.html , i have recieved error "Class not found" help me

index.html

<!DOCTYPE html>
<html>
  <head>
    <title>navigator.network.connection.type Example</title>

<script src="cordova.js"></script>
<script type="text/javascript" charset="utf-8">

    // Wait for PhoneGap to load
    // 
    document.addEventListener("deviceready", onDeviceReady, false);

    // PhoneGap is loaded and it is now safe to make calls PhoneGap methods
    //
    function onDeviceReady() {
        checkConnection();
    }

    function checkConnection() {
        alert('all ok');
        try{
            window.MacAddress.getMacAddress(
            function(macAddress) {alert(macAddress);},function(fail) {alert(fail);}
            );

        } catch(e) {
            alert(e.name)
        } finally {
            alert("finished")
        }


    }



    </script>
  </head>
  <body>
    <p></p>
  </body>
</html>

config.xml

<?xml version="1.0" encoding="UTF-8" ?>
    <widget xmlns   = "http://www.w3.org/ns/widgets"
        xmlns:gap   = "http://phonegap.com/ns/1.0"
        id          = ""
        versionCode = "10" 
        version     = "1.0.0" >
    <preference name="phonegap-version" value="3.3.0" />
    <!-- versionCode is optional and Android only -->

    <name>PhoneGap Example</name>

    <description>
        An example for phonegap build docs. 
    </description>

    <author href="https://build.phonegap.com" email="support@phonegap.com">
        Hardeep Shoker 
    </author>
<gap:plugin name="org.apache.cordova.device" /> 
<gap:plugin name="org.apache.cordova.network-information" version="0.2.7" />
<gap:plugin name="com.badrit.macaddress" version="0.1.0" />
<gap:platform name="ios" />
<gap:platform name="android" />
</widget>

Solution

  • In index.html, include script for plugin like below:

    <script type="text/javascript" src="MacAddress.js"></script>