简体   繁体   English

phonegap类找不到文件:///android_asset/www/cordova-2.0.0.js:938

[英]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所在的位置

here 这里

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. 对于仍然收到此错误消息的人,请尝试以下技巧。

  1. Open cordova-2.0.0.js in an editor. 在编辑器中打开cordova-2.0.0.js。
  2. 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);

  3. 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是插件名称。

  4. Check if the section in your config.xml file has any entry for the XYZ plugin. 检查config.xml文件中的部分是否包含XYZ插件的任何条目。
  5. Add the XYZ plugin if not found. 如果找不到,请添加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.

相关问题 “初始化网络连接时出错:找不到类”,来源:file:///android_asset/www/cordova.js - “Error initializing Network Connection: Class not found”, source: file:///android_asset/www/cordova.js Phonegap:对象xx在文件中没有方法&#39;exec&#39;:///android_asset/www/cordova.js - Phonegap: Object xx has no method 'exec' at file:///android_asset/www/cordova.js cordova-2.0.0.js没有使用phonegap在android上工作 - cordova-2.0.0.js is not working on android using phonegap 在cordova-3.0.0中的file:///android_asset/www/cordova.js:56找不到未捕获的模块cordova / urlutil - Uncaught module cordova/urlutil not found at file:///android_asset/www/cordova.js:56 in cordova-3.0.0 Android phonegap文件://android_asset/www/index.htm - Android phonegap file://android_asset/www/index.htm android上的phonegap说:不允许加载本地资源:file:///android_asset/www/app/fb.js - phonegap on android says: Not allowed to load local resource: file:///android_asset/www/app/fb.js 找不到文件://android_asset/www/index.html - file://android_asset/www/index.html was not found Phonegap / Android错误:未捕获ReferenceError:未在file:///android_asset/www/js/login.js:17定义url - Phonegap/Android error: Uncaught ReferenceError: url is not defined at file:///android_asset/www/js/login.js:17 您好如何为我提供帮助并解决“ file:///android_asset/www/plugin.js中未定义Cordova.exec()”错误 - hi how can help me and resolve “Cordova.exec() is not defined at file:///android_asset/www/plugin.js” error 找不到网:: ERR_FILE_NOT_FOUND file:///android_asset/www/index.html - net::ERR_FILE_NOT_FOUND file:///android_asset/www/index.html was not found
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM