Phonegap 1.4.1 WebIntent插件错误“未找到类”Android

时间:2012-04-03 11:36:47

标签: android cordova

我是开发phonegap的新手,所以如果这是一个明显的答案,我很抱歉。这是我项目的最后一部分,其中唯一不起作用的部分是插件。

我收到消息“无法通过Android Intent发送电子邮件”并在logcat中收到以下错误“错误:状态= 2消息=未在文件中找到类:///android_asset/www/phonegap-1.4.1。 js:651“

我无法弄清楚这一点,过去一天我一直在这里!

我已将插件添加到plugin.xml

插件名称=“webintent”value =“com.borismus.webintent.WebIntent”

我有WebIntent.java文件的正确名称空间。

包borismus.webintent;

我的index.html中引用了webintent.js文件。

以下是使用该插件的功能。         function emailxmlfile(){

var subject = "Sports Code Xml Edit List" + filedate.toDateString();
var body = "";
if(!window.plugins || !window.plugins.webintent){

    alert('Unable to find webintent plugin');

}else{



var extras={};

extras[WebIntent.EXTRA_SUBJECT] = subject;
extras[WebIntent.EXTRA_TEXT] = body;

 window.plugins.webintent.startActivity({
        action: WebIntent.ACTION_SEND,
        type: 'text/plain',
        extras: extras
      }, function() {}, function(e) {alert('Failed to send email via Android Intent');});

}};

任何帮助将不胜感激。感谢

4 个答案:

答案 0 :(得分:6)

我知道我可能会迟到,但是在没有轻微和微妙变化的情况下使用相同的代码:在将插件详细信息添加到.xml文件时尊重大写。我的意思是,你说过:

plugin name="webintent" value="com.borismus.webintent.WebIntent"

应该读取此内容(注意名称!):

plugin name="WebIntent" value="com.borismus.webintent.WebIntent"
一旦你纠正了拼写错误,Eclipse中的红色波形就会消失,而且代码运行正常,所以我可以调用我的电子邮件应用程序。

HTH!

答案 1 :(得分:4)

通常,当您收到该消息时,您错过了将插件添加到plugins.xml

<plugin name="WebIntent" value="com.borismus.webintent.WebIntent"/>

答案 2 :(得分:3)

在处理Android应用程序时,事情的变化速度要快得多,太糟糕了,大多数文档都没有尽快更新。

我正在使用phonegap 2.0.0,我不得不将插件配置添加到config.xml文件中,而不是在plugins.xml中。

确保你正在加载phonegap.js(在我的情况下为cordova-2.0.0.js),webintent.js并且你的src文件夹上有正确的包结构(src / com / borismus / webintent / WenIntent的.java)

那么你应该全部准备好了。

答案 3 :(得分:0)

你说包裹是:

package borismus.webintent;

但定义为:

plugin name="webintent" value="com.borismus.webintent.WebIntent"

你不会错过“com”。关于包裹声明?

相关问题