Phonegap Build无法识别插件

时间:2016-01-07 21:47:07

标签: javascript cordova cordova-plugins

我正在尝试在Phonegap中使用插件,但它无法正常工作。我想我的config.xml可能有些不好,但我不确定是什么。

config.xml中

<widget xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0" id="com.sethmcdonald.helloworld01" version="1.0.0">
  <name>helloworld01</name>
  <description>Hello World sample application that responds to the deviceready event.</description>
  <author href="http://phonegap.com" email="support@phonegap.com">PhoneGap Team</author>
  <content src="index.html"/>
  <preference name="permissions" value="none"/>
  <preference name="orientation" value="default"/>
  <preference name="target-device" value="universal"/>
  <preference name="fullscreen" value="true"/>
  <preference name="webviewbounce" value="true"/>
  <preference name="prerendered-icon" value="true"/>
  <preference name="stay-in-webview" value="false"/>
  <preference name="ios-statusbarstyle" value="black-opaque"/>
  <preference name="detect-data-types" value="true"/>
  <preference name="exit-on-suspend" value="false"/>
  <preference name="show-splash-screen-spinner" value="true"/>
  <preference name="auto-hide-splash-screen" value="true"/>
  <preference name="disable-cursor" value="false"/>
  <preference name="android-minSdkVersion" value="14"/>
  <preference name="android-installLocation" value="auto"/>
  <preference name="android-build-tool" value="gradle" />
  <gap:plugin name="org.apache.cordova.battery-status"/>
  <gap:plugin name="org.apache.cordova.camera"/>
  <gap:plugin name="org.apache.cordova.media-capture"/>
  <gap:plugin name="org.apache.cordova.console"/>
  <gap:plugin name="org.apache.cordova.contacts"/>
  <gap:plugin name="org.apache.cordova.device"/>
  <gap:plugin name="org.apache.cordova.device-motion"/>
  <gap:plugin name="org.apache.cordova.device-orientation"/>
  <gap:plugin name="org.apache.cordova.dialogs"/>
  <gap:plugin name="org.apache.cordova.file"/>
  <gap:plugin name="org.apache.cordova.file-transfer"/>
  <gap:plugin name="org.apache.cordova.geolocation"/>
  <gap:plugin name="org.apache.cordova.globalization"/>
  <gap:plugin name="org.apache.cordova.inappbrowser"/>
  <gap:plugin name="org.apache.cordova.media"/>
  <gap:plugin name="org.apache.cordova.network-information"/>
  <gap:plugin name="org.apache.cordova.splashscreen"/>
  <gap:plugin name="org.apache.cordova.vibration"/>
  <icon src="icon.png"/>
  <icon src="www/res/icon/android/icon-36-ldpi.png" gap:platform="android" gap:qualifier="ldpi"/>
  <icon src="www/res/icon/android/icon-48-mdpi.png" gap:platform="android" gap:qualifier="mdpi"/>
  <icon src="www/res/icon/android/icon-72-hdpi.png" gap:platform="android" gap:qualifier="hdpi"/>
  <icon src="www/res/icon/android/icon-96-xhdpi.png" gap:platform="android" gap:qualifier="xhdpi"/>
  <icon src="www/res/icon/blackberry/icon-80.png" gap:platform="blackberry"/>
  <icon src="www/res/icon/blackberry/icon-80.png" gap:platform="blackberry" gap:state="hover"/>
  <icon src="www/res/icon/ios/icon-57.png" gap:platform="ios" width="57" height="57"/>
  <icon src="www/res/icon/ios/icon-72.png" gap:platform="ios" width="72" height="72"/>
  <icon src="www/res/icon/ios/icon-57-2x.png" gap:platform="ios" width="114" height="114"/>
  <icon src="www/res/icon/ios/icon-72-2x.png" gap:platform="ios" width="144" height="144"/>
  <icon src="www/res/icon/webos/icon-64.png" gap:platform="webos"/>
  <icon src="www/res/icon/windows-phone/icon-48.png" gap:platform="winphone"/>
  <icon src="www/res/icon/windows-phone/icon-173-tile.png" gap:platform="winphone" gap:role="background"/>
  <gap:splash src="www/res/screen/android/screen-ldpi-portrait.png" gap:platform="android" gap:qualifier="port-ldpi"/>
  <gap:splash src="www/res/screen/android/screen-mdpi-portrait.png" gap:platform="android" gap:qualifier="port-mdpi"/>
  <gap:splash src="www/res/screen/android/screen-hdpi-portrait.png" gap:platform="android" gap:qualifier="port-hdpi"/>
  <gap:splash src="www/res/screen/android/screen-xhdpi-portrait.png" gap:platform="android" gap:qualifier="port-xhdpi"/>
  <gap:splash src="www/res/screen/blackberry/screen-225.png" gap:platform="blackberry"/>
  <gap:splash src="www/res/screen/ios/screen-iphone-portrait.png" gap:platform="ios" width="320" height="480"/>
  <gap:splash src="www/res/screen/ios/screen-iphone-portrait-2x.png" gap:platform="ios" width="640" height="960"/>
  <gap:splash src="www/res/screen/ios/screen-iphone-portrait-568h-2x.png" gap:platform="ios" width="640" height="1136"/>
  <gap:splash src="www/res/screen/ios/screen-ipad-portrait.png" gap:platform="ios" width="768" height="1024"/>
  <gap:splash src="www/res/screen/ios/screen-ipad-landscape.png" gap:platform="ios" width="1024" height="768"/>
  <gap:splash src="www/res/screen/windows-phone/screen-portrait.jpg" gap:platform="winphone"/>
  <access origin="*"/>
  <plugin name="cordova-plugin-whitelist" version="1"/>
  <plugin name="cordova-plugin-calendar" />
  <allow-intent href="http://*/*"/>
  <allow-intent href="https://*/*"/>
  <allow-intent href="tel:*"/>
  <allow-intent href="sms:*"/>
  <allow-intent href="mailto:*"/>
  <allow-intent href="geo:*"/>
  <platform name="android">
    <allow-intent href="market:*"/>
  </platform>
  <platform name="ios">
    <allow-intent href="itms:*"/>
    <allow-intent href="itms-apps:*"/>
  </platform>
</widget>

这是我的index.html。如果我在那里取消注释该警报,它会发出警报,因此我知道它正在跳转到该代码块。

的index.html

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <meta name="format-detection" content="telephone=no" />
        <meta name="msapplication-tap-highlight" content="no" />
        <!-- WARNING: for iOS 7, remove the width=device-width and height=device-height attributes. See https://issues.apache.org/jira/browse/CB-4323 -->
        <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
        <link rel="stylesheet" type="text/css" href="css/index.css" />
        <script type="text/javascript" charset="utf-8" src="cordova.js"></script>

        <title>Hello World</title>
    </head>
    <body onload="onLoad()">

        <script type="text/javascript">

            function onLoad(){
                document.addEventListener("deviceready", onDeviceReady, false);
            }

            //READY
            function onDeviceReady(){

                //INITIALIZE VARS
                var startDate = new Date(2015,0,1,0,0,30,0,0);
                var endDate = new Date(2015,11,31,23,59,30,0,0);
                var title = "My nice event";
                var eventLocation = "Home";
                var notes = "Some notes about this event.";
                var success = function(message) { alert("Success: " + JSON.stringify(message)); };
                var error = function(message) { alert("Error: " + message); };

                var ref = cordova.InAppBrowser.open("http://dev.leadcliq.com", "_blank", "location=no,toolbar=no");
            }

            function hasReadWritePermission() {

//                alert("inside");

                window.plugins.calendar.hasReadWritePermission(
                    function(result) {
                        // if this is 'false' you probably want to call 'requestReadWritePermission' now
                            alert(result);
                        }
                )
            }


    </script>

    </body>
</html>

1 个答案:

答案 0 :(得分:0)

我不确定你是否还有这个问题,但是当我解压缩来自PhoneGap Build的.apk时,我发现媒体插件没有包含在服务器中。我将支持从NPM版本切换到PGB版本,它包括没有问题。

<plugin name="org.apache.cordova.media" source="pgb" />

花了我一天半的时间来解决这个问题。希望这可以帮助。 :)

相关问题