PhoneGap插件不起作用(未定义)

时间:2014-01-16 13:09:15

标签: plugins cordova

我正在通过PhoneGap开发我的第一个应用程序,而且我真的陷入非常令人沮丧的插件问题。

我将使用Phonegap Docs中的示例解释问题,以避免代码问题。这是我从头开始创建应用程序并添加插件的工作流程:

$ phonegap create helloworld com.phonegap.helloworld HelloWorld
[phonegap] created project at /.../Phonegap_Dev/helloworld
$ cd helloworld/
$ cordova platform add ios
Creating ios project...
Preparing ios project
$ cordova platform add android
Creating android project...
Preparing android project
$ cordova plugin add org.apache.cordova.dialogs
Fetching plugin from "org.apache.cordova.dialogs"...
Starting installation of "org.apache.cordova.dialogs" for android
Preparing android project
org.apache.cordova.dialogs installed on android.
Starting installation of "org.apache.cordova.dialogs" for ios
Preparing ios project
org.apache.cordova.dialogs installed on ios.
$ cordova plugin add org.apache.cordova.splashscreen
Fetching plugin from "org.apache.cordova.splashscreen"...
Starting installation of "org.apache.cordova.splashscreen" for android
Preparing android project
org.apache.cordova.splashscreen installed on android.
Starting installation of "org.apache.cordova.splashscreen" for ios
Preparing ios project
org.apache.cordova.splashscreen installed on ios.

一旦我有了这个基本的phonegap生成的应用程序,我更改了文件www / index.html中的内容,以获取有关SplashScreen插件的Phonegap文档中的示例代码:

<!DOCTYPE html>
<html>
  <head>
    <title>Splashscreen Example</title>

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

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

    // device APIs are available
    //
    function onDeviceReady() {
        navigator.notification.alert(“Alert works…!!”);
        navigator.splashscreen.show();
    }

    </script>
  </head>
  <body>
    <h1>Example</h1>
  </body>
</html>

并使用以下代码编译应用程序:

$ cordova build
Generating config.xml from defaults for platform "android"
Preparing android project
Generating config.xml from defaults for platform "ios"
Preparing ios project
Compiling app on platform "android" via command "/Users/ifernandez/Duonet_Dev/Phonegap_Dev/helloworld/platforms/android/cordova/build" 
Compiling app on platform "ios" via command "/Users/ifernandez/Duonet_Dev/Phonegap_Dev/helloworld/platforms/ios/cordova/build" 
Platform "android" compiled successfully.
Platform "ios" compiled successfully.

现在,当我使用Ripple Emulator测试应用程序时,警报会正确显示,但对splashscreen.show()的调用始终会返回:

未捕获的TypeError:无法调用未定义的方法'show'

所以看起来应用程序没有找到启动画面插件,尽管插件文件夹内部看起来都很正确。

为什么这个简单的例子不起作用?我的工作流程是否缺少一步?缺少aditional配置?是否可以在Ripple中检查和调试某些插件,而不是其他插件......?

过去几天我试图找出没有运气的问题在哪里......

提前致谢...

0 个答案:

没有答案