8

i try to use this plugin and followed the instruction given in the readme.md file.

1)here's my html file

<!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

<?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

4) additionally, some said I also need to add the plugin into AndroidManifest.xml file, so this is a snippet of it

<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

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

here

I don't see the VideoPlayer.java under Gen folder, does that means it's not compiled? 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

2
  • where your cordova-2.0.0.js file is located ?
    – zizoujab
    Aug 8, 2012 at 5:10
  • @ZiedJaballah it's in the same folder as index.html, which is assets\www
    – imin
    Aug 8, 2012 at 5:15

3 Answers 3

10

the problem is your 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.

so try adding the tag <plugin name="VideoPlayer" value="com.phonegap.plugins.video.VideoPlayer"/>

to res/xml/config.xml not to plugins.xml

2
  • sorry I don't get what u meant by that. as u can see above, i've already add the exact line u posted in my plugins.xml file. and from my download at phonegap site, I only get config.xml with it, and not plugins.xml
    – imin
    Aug 8, 2012 at 5:40
  • thanks Zied... gosh the video.js author should have updated their documentation on this
    – imin
    Aug 8, 2012 at 6:18
6

If the error shown in the log is

Class not found at 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.
  2. Replace code on Line 938 i.e.

    console.log("Error: Status="+v.status+" Message="+v.message);

    with

    console.log("Error: 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.

  4. Check if the section in your config.xml file has any entry for the XYZ plugin.
  5. Add the XYZ plugin if not found.
1
  • I did what you suggested. I am just starting phonegap and I'm stuck at trying to get a HelloWorld Plugin to work. I get the same error with my HelloWorld plugin. The config.xml file has the plugin entry. I cant figure out the problem. Sep 24, 2012 at 17:33
2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.