android - 在文件 :///android_asset/www/cordova-2. 0.0.js:938 中找不到 phonegap 类

标签 android cordova

我尝试使用 this plugin 并按照 readme.md 文件中给出的说明进行操作。

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) 这是我的 plugins.xml,它位于 xml 文件夹中

<?xml version="1.0" encoding="utf-8"?>
<plugins>
    <plugin name="VideoPlayer" value="com.phonegap.plugins.video.VideoPlayer"/>
</plugins>

3) 我也将 VideoPlayer.java 复制到这个文件夹 src\com\phonegap\plugins\video

4) 此外,有人说我还需要将插件添加到 AndroidManifest.xml 文件中,所以这是其中的一个 fragment

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

但是,当我点击“播放”时,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:​​这里是 VideoPlayer.java 所在的位置

here

我在 Gen 文件夹下没有看到 VideoPlayer.java,这是否意味着它没有编译?这可能是问题所在吗?如果是,如何解决?

update2:我检查了 bin 文件夹,在 bin\classes\com\phonegap\plugins\video 下有 VideoPlayer.class 所以 VideoPlayer.java 实际上是编译过的

最佳答案

问题出在你的 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.

所以尝试添加标签 <plugin name="VideoPlayer" value="com.phonegap.plugins.video.VideoPlayer"/>

到 res/xml/config.xml 而不是到 plugins.xml

关于android - 在文件 :///android_asset/www/cordova-2. 0.0.js:938 中找不到 phonegap 类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11857958/

相关文章:

java - Android 处理程序泄漏

java - 如何手动安装 java 库并将/tmp 保持为 noexec?

android - 覆盖 editTextStyle 不适用于最新的 Material Components 基本样式

java - 我的应用程序在单击按钮时关闭

android - 无法更新任何插件,不是有效的 cordova 平台?

javascript - 如果数据 = 0,则不更新(执行)表。 (JavaScript/SQL)

java - Espresso Android 匹配父级中的 TextView

iphone - 如何在 iOS 版 Phone Gap 中使用 WSDL Web 服务?

android - Phonegap - 你好 Cordova 错误

android - 如何在 phonegap 和 JQM 中进行登录和注销