使用cordova插件时出错

时间:2014-10-27 08:30:13

标签: cordova plugins admob cordova-plugins

我尝试使用admob cordova插件(来自https://github.com/appfeel/admob-google-cordova)在cordova应用中展示广告。我一直在尝试:

cordova plugin add com.admob.google
cordova plugin add https://github.com/appfeel/admob-google-cordova

但是我收到了这个错误:

Fetching plugin "com.admob.google" via plugin registry
npm http GET http://registry.cordova.io/com.admob.google
npm http 304 http://registry.cordova.io/com.admob.google
Installing "com.admob.google" for android
Failed to install 'com.admob.google':TypeError: Cannot read property '1' of undefined
    at findall (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/elementtree/lib/elementpath.js:283:20)
    at Object.find (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/elementtree/lib/elementpath.js:321:24)
    at Element.find (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/elementtree/lib/elementtree.js:123:22)
    at ElementTree.find (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/elementtree/lib/elementtree.js:273:21)
    at resolveParent (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/util/xml-helpers.js:180:22)
    at Object.module.exports.graftXML (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/util/xml-helpers.js:74:22)
    at ConfigFile_graft_child [as graft_child] (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/util/config-changes.js:589:30)
    at PlatformMunger_apply_file_munge [as apply_file_munge] (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/util/config-changes.js:170:38)
    at PlatformMunger.add_plugin_changes (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/util/config-changes.js:270:14)
    at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/util/config-changes.js:393:14
TypeError: Cannot read property '1' of undefined
    at findall (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/elementtree/lib/elementpath.js:283:20)
    at Object.find (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/elementtree/lib/elementpath.js:321:24)
    at Element.find (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/elementtree/lib/elementtree.js:123:22)
    at ElementTree.find (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/elementtree/lib/elementtree.js:273:21)
    at resolveParent (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/util/xml-helpers.js:180:22)
    at Object.module.exports.graftXML (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/util/xml-helpers.js:74:22)
    at ConfigFile_graft_child [as graft_child] (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/util/config-changes.js:589:30)
    at PlatformMunger_apply_file_munge [as apply_file_munge] (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/util/config-changes.js:170:38)
    at PlatformMunger.add_plugin_changes (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/util/config-changes.js:270:14)
    at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/util/config-changes.js:393:14

2 个答案:

答案 0 :(得分:1)

我是这个插件的维护者。当res/values/strings.xml没有存在于android平台时(该插件试图附加此文件),这是一个错误。它已经解决了。现在应该使用已经在cordova插件注册表中发布的1.0.7版本。

答案 1 :(得分:-1)

尝试

cordova插件添加cordova-plugin-admob-simple

并查看https://github.com/sunnycupertino/cordova-plugin-admob-simple了解文档。