0

我尝试将 LiveTile 插件(在此处找到)添加到我干净的 Cordova 3.3 项目中。但我似乎无法让它工作。它适用于链接中的指令,但使用 Cordova 2.0.0。当我尝试添加新 Tile 时,我得到以下打印输出:

        An exception of type 'System.InvalidCastException' occurred in System.ServiceModel.Web.ni.dll and wasn't handled before a managed/native boundary
        A first chance exception of type 'System.InvalidCastException' occurred in System.ServiceModel.Web.ni.dll
        An exception of type 'System.InvalidCastException' occurred in System.ServiceModel.Web.ni.dll and wasn't handled before a managed/native boundary
        Unable to cast object of type 'System.Collections.Generic.List`1[System.Object]' to type 'System.Collections.Generic.Dictionary`2[System.String,System.Object]'.
        Failed to deserialize Cordova.Extension.Commands.LiveTiles+LiveTilesOptions with JSON value :: ["System.Collections.Generic.Dictionary`2[System.String,System.Object]","LiveTiles963855178"]
        A first chance exception of type 'System.NullReferenceException' occurred in CordovaWP8_2.9.14.DLL
        An exception of type 'System.NullReferenceException' occurred in CordovaWP8_2.9.14.DLL but was not handled in user code
        A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.ni.dll
        An exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.ni.dll and wasn't handled before a managed/native boundary
        ERROR: Exception in ProcessCommand :: Exception has been thrown by the target of an invocation.
        ERROR: failed to InvokeMethodNamed :: createSecondaryTile on Object :: LiveTiles
        The thread 0xbac has exited with code 259 (0x103).
        Error occurred: Invalid action

这个新版本的 Cordova 是否添加了不同的插件,或者 LiveTile 插件不再兼容?

4

2 回答 2

0

这可能是一个愚蠢的问题,但由于文档太差,很难称任何问题为愚蠢。然而,我现在已经设法解决了这个问题,如果其他人遇到同样的问题,我会尝试解释我做了什么。

首先,我发现了这个LiveTiles 插件的实现,它似乎比问题中的那个更新。我没有通过 Visual Studio 创建新项目,而是使用了 CLI。

phonegap create hello com.example.hello HelloWorld

然后我根据上面的链接使用plugman安装插件。

plugman install --project . --platform wp8 --plugin com.risingj.cordova.livetiles

现在我浏览了我的文件,看看发生了什么。

config.xml - 一些补充

    <?xml version='1.0' encoding='utf-8'?>
    <widget>
        <access origin="*" />
        <feature name="LiveTiles">
            <param name="wp-package" value="LiveTiles" />
        </feature>
    </widget>

生成了一个新文件: www-文件夹中的cordova_plugins.js,其内容如下:

cordova.define('cordova/plugin_list', function(require, exports, module) {
module.exports = [
    {
        "file": "plugins/livetiles.js",
        "id": "com.risingj.cordova.livetiles.livetiles",
        "clobbers": [
            "LiveTiles"
        ]
    }
];
module.exports.metadata = 
// TOP OF METADATA
{
    "com.risingj.cordova.livetiles": "0.1.0"
}
// BOTTOM OF METADATA
});

我将这些文件添加到了 Cordova Visual Studio 项目中,它工作了!所以我想如果添加一个新插件,这就是所需要的。

于 2014-02-13T21:57:49.583 回答
0

你需要这样做:

cordova plugin add path/to/your/plugin

它会做所有的事情。

于 2014-05-15T14:17:03.267 回答