[英]phonegap Class not found at file:///android_asset/www/cordova-2.0.0.js:938
i try to use this plugin and followed the instruction given in the readme.md file. 我尝试使用此插件并按照readme.md文件中给出的说明进行操作。
1)here's my html file 1)这是我的html文件
<!DOCTYPE HTML>
<html>
<head>
<title>TryMakan Video</title>
<link rel="stylesheet" href="style.css" />
<script type="text/javascript" charset="utf-8" src="cordova-2.0.0.js"></script>
<script type="text/javascript" charset="utf-8" src="video.js"></script>
<script type="text/javascript">
function playVideo(){
window.plugins.videoPlayer.play("http://www.trymakan.my/wp-content/uploads/2011/09/NASI-AYAM-BEREMPAH-KAJANG.mp4");
}
</script>
</head> <body>
<a href="#" onClick="playVideo();">play</a>
</body></html>
2) here's my plugins.xml which is located in xml folder 2)这是我的plugins.xml,它位于xml文件夹中
<?xml version="1.0" encoding="utf-8"?>
<plugins>
<plugin name="VideoPlayer" value="com.phonegap.plugins.video.VideoPlayer"/>
</plugins>
3) i've also copied the VideoPlayer.java into this folder src\\com\\phonegap\\plugins\\video 3)我还将VideoPlayer.java复制到此文件夹src \\ com \\ phonegap \\ plugins \\ video
4) additionally, some said I also need to add the plugin into AndroidManifest.xml file, so this is a snippet of it 4)另外,有人说我还需要将插件添加到AndroidManifest.xml文件中,所以这是它的一个片段
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale"
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="com.phonegap.plugins.video.VideoPlayer"/>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
but still, when I click on 'play', log cat will return this error 但是,当我点击“播放”时,log cat将返回此错误
08-08 04:54:15.823: I/Web Console(309): Error: Status=2 Message=Class not found at file:///android_asset/www/cordova-2.0.0.js:938
update1: here's where the VideoPlayer.java is located update1:这是VideoPlayer.java所在的位置
I don't see the VideoPlayer.java under Gen folder, does that means it's not compiled? 我没有在Gen文件夹下看到VideoPlayer.java,这是否意味着它没有编译? Could this be the problem? 这可能是问题吗? If yes, how to solve it? 如果是,如何解决?
update2: I checked bin folder, and there VideoPlayer.class under bin\\classes\\com\\phonegap\\plugins\\video so the VideoPlayer.java is actually compiled update2:我检查了bin文件夹,bin \\ classes \\ com \\ phonegap \\ plugins \\ video下有VideoPlayer.class,所以VideoPlayer.java实际编译
the problem is your plugins.xml. 问题是你的plugins.xml。
it appears in one of the recent PhoneGap release, the plugins.xml has been removed and you have to add the line in res/xml/config.xml instead. 它出现在最近的一个PhoneGap版本中,已删除了plugins.xml,您必须在res / xml / config.xml中添加该行。
so try adding the tag <plugin name="VideoPlayer" value="com.phonegap.plugins.video.VideoPlayer"/>
所以尝试添加标签<plugin name="VideoPlayer" value="com.phonegap.plugins.video.VideoPlayer"/>
to res/xml/config.xml not to plugins.xml res / xml / config.xml不是plugins.xml
If the error shown in the log is 如果日志中显示的错误是
Class not found at file:///android_asset/www/cordova-2.0.0.js:938 在file:///android_asset/www/cordova-2.0.0.js:938找不到类
The best way is to check which class is causing the error. 最好的方法是检查哪个类导致错误。 For those who still get this error message, try the following trick. 对于仍然收到此错误消息的人,请尝试以下技巧。
Replace code on Line 938 ie 替换938行的代码即
console.log("Error: Status="+v.status+" Message="+v.message); console.log(“错误:Status =”+ v.status +“Message =”+ v.message);
with 同
console.log("Error: Status="+v.status+" Message="+v.message+" service="+service+" action="+action); console.log(“错误:Status =”+ v.status +“Message =”+ v.message +“service =”+ service +“action =”+ action);
Run the app again and check the console for the above error. 再次运行应用程序并检查控制台是否存在上述错误。 You can see the plugin which causes the error in service=XYZ where XYZ is the plugin name. 您可以在服务中看到导致错误的插件= XYZ ,其中XYZ是插件名称。
I have had this error because of a missing plugin. 由于缺少插件,我遇到了这个错误。 I Added 我补充道
<plugin name="Device" value="org.apache.cordova.Device"/>
to the config.xml file and it fixed it. 到config.xml文件并修复它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.