Cordova插件参考错误(Dropbox Sync)

时间:2014-08-16 11:31:29

标签: javascript android html cordova cordova-plugins

我用这些命令为Android制作了一个新的Cordova应用程序:

  

$ cordova create hello com.example.hello HelloWorld
   $ cordova平台添加android

它有效。然后我添加了Dropboc Sync插件

  

cordova插件添加https://github.com/rossmartin/phonegap-dropbox-sync-android.git

但我无法访问JS变种。 我试过了

try{

DropboxSync.checkLink(function() { // success
alert("ok");
    // User is already authenticated with Dropbox.
}, function() { // fail
alert("fail");
    // User is not authenticated with Dropbox.
});

DropboxSync.link();

}catch(e){alert(e);}

警报或电子警报说:

  

ReferenceError:未定义DropboxSync

我忘记了什么吗?

更改了index.html:

<!DOCTYPE html>
<!--
    Licensed to the Apache Software Foundation (ASF) under one
    or more contributor license agreements.  See the NOTICE file
    distributed with this work for additional information
    regarding copyright ownership.  The ASF licenses this file
    to you under the Apache License, Version 2.0 (the
    "License"); you may not use this file except in compliance
    with the License.  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing,
    software distributed under the License is distributed on an
    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
     KIND, either express or implied.  See the License for the
    specific language governing permissions and limitations
    under the License.
-->
<html>
    <head>
        <meta charset="utf-8" />
        <meta name="format-detection" content="telephone=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" />
        <meta name="msapplication-tap-highlight" content="no" />
        <title>Hello World</title>
    </head>
    <body>
        <div class="app">
            <h1>Apache Cordova</h1>
            <div id="deviceready" class="blink">
                <p class="event listening">Connecting to Device</p>
                <p class="event received">Device is Ready</p>
            </div>
        </div>
        <script type="text/javascript" src="cordova.js"></script>
        <script type="text/javascript" src="js/index.js"></script>
        <script type="text/javascript">
            app.initialize();
        </script>




        <script>

    function dropbox_linked() { }
// Called from the onActivityResult method in the plugin when linking is successful.
function dropbox_onSyncStatusChange(status) { }
// Called by observer in the plugin when there's a change 
// to the status of background synchronization (download/upload).
// status is a string variable that will be 'sync' or 'none'.
function dropbox_fileChange() { }
// Called by observer in the plugin when a file is changed.




try{
DropboxSync.checkLink(function() { // success
alert("Hallo ok");
    // User is already authenticated with Dropbox.
}, function() { // fail
alert("Hallo fail");
    // User is not authenticated with Dropbox.
});

        alert("Hallo");
        DropboxSync.link();
        alert("Hallo2");

        }catch(e){alert(e);}

        </script>


    </body>
</html>

1 个答案:

答案 0 :(得分:0)

尝试使用window.DropboxSync,也不要忘记检查android.json是否正确安装(如果你使用netbeans,你可以在plugins文件夹下的Files窗口看到它。