无法在phonegap中添加插件,其中包含" Class Not Found"错误

时间:2015-09-10 20:00:05

标签: javascript android cordova phonegap-plugins cordova-3

尝试安装此插件:(Github) Phone-call-trap-pluging,我在phonegap上执行此操作:

1-安装插件:phonegap plugin add https://github.com/renanoliveira/cordova-phone-call-trap

在插件中添加日志消息后,将插件中的javascript文件复制并添加到我的www / js文件夹中,如下所示:

var PhoneCallTrap = {
    onCall: function(successCallback, errorCallback) {
        errorCallback = errorCallback || this.errorCallback;
        cordova.exec(successCallback, errorCallback, 'com.sample.phonecalltrap', 'onCall', []);
    },

    errorCallback: function(err) {
        console.log("WARNING: PhoneCallTrap errorCallback not implemented");
        console.log(err);
    }
};

module.exports = PhoneCallTrap;

3-

PhoneCallTrap.onCall(

        function(state) {
            console.log("CHANGE STATE: " + state);

            switch (state) {
                case "RINGING":
                    alert("Phone is ringing: ");
                    break;
                case "OFFHOOK":
                    alert("Phone is off-hook");
                    break;

                case "IDLE":
                    alert("Phone is idle");
                    break;
                }
    });

4-我在问题标题中出现上述错误

我做错了什么?

---------------------------------------------- < / p>

修改

当我phonegap build

时,会出现这些错误
[phonegap] executing 'cordova build'...
cp: no such file or directory: /.../PHONEGAP/secondApp/icon.png


Running command: /.../PHONEGAP/secondApp/platforms/android/cordova/build

[Error: Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually.
Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory.]

ERROR building one of the platforms: Error: ..../platforms/android/cordova/build: Command failed with exit code 2
You may not have the required environment or OS to build this project

Error: /..../platforms/android/cordova/build: Command failed with exit code 2
    at ChildProcess.whenDone (. ( (.../node_modules/phonegap/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:139:23)
    at ChildProcess.emit (events.js:110:17)
    at maybeClose (child_process.js:1015:16)
    at Process.ChildProcess._handle.onexit (child_process.js:1087:5)

--------------------------------------------

编辑2

我得到了#34;未找到课程&#34;错误,当我的代码在下面的代码

中命中这一行(console.log(错误);)时
    var PhoneCallTrap = {
    onCall: function(successCallback, errorCallback) {
        errorCallback = errorCallback || this.errorCallback;
        cordova.exec(successCallback, errorCallback, 'PhoneCallTrap', 'onCall', []);
    },

    errorCallback: function(err) {
        console.log("WARNING: PhoneCallTrap errorCallback not implemented");
        console.log(err);
        console.log(err.stack);
    }
};

module.exports = PhoneCallTrap;

关于ANDROID_HOME环境变量,我使用phonegap开发客户端,它通过连接到服务器来查看我的应用程序(运行:phonegap serve

0 个答案:

没有答案