我遵循了 Phonegap.com 官方网站上的 Phonegap 教程(Android 入门)。
我已经按照所有步骤创建了项目。
- 创建 Activity 并从“DroidGap”扩展并从 onCreate() 添加 loadURL 方法。
- 在相应文件夹中添加了 cordova-2.0.0.js 和 cordova-2.0.0.jar。
- 将 jar 文件添加到构建路径
- 从html标签加载js文件
- 从 AndroidMainfeast.xml 添加权限
- 复制了包含“configs.xml”的xml文件夹
现在我不明白问题出在哪里。它显示以下错误,如屏幕截图所示
这是我的 HTML 文件
<!DOCTYPE html>
<html>
<head>
<title>Notification Example</title>
<script type="text/javascript" charset="utf-8" src="cordova-2.0.0.js"></script>
<script type="text/javascript" charset="utf-8">
// Wait for Cordova to load
//
document.addEventListener("deviceready", onDeviceReady, false);
// Cordova is ready
//
function onDeviceReady() {
// Empty
}
// Show a custom alert
//
function showAlert() {
navigator.notification.alert(
'You are the winner!', // message
'Game Over', // title
'Done' // buttonName
);
}
// Beep three times
//
function playBeep() {
navigator.notification.beep(3);
}
// Vibrate for 2 seconds
//
function vibrate() {
navigator.notification.vibrate(2000);
}
</script>
</head>
<body>
<p><a href="#" onclick="showAlert()">Show Alert</a></p>
<p><a href="#" onclick="playBeep()">Play Beep</a></p>
<p><a href="#" onclick="vibrate()">Vibrate</a></p>
</body>
</html>
有什么建议吗?谢谢!
最佳答案
它是 config.xml
而不是 configs.xml
。
根据我看到的日志,您的应用程序 res/xml
目录中缺少此文件。它作为分发的一部分包含在 lib/android/res/xml/config.xml
中,因此将该文件复制到您的 res/xml
目录中,您应该已经准备好了.
关于android - 初始化 Cordova 时出错 : Class not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11934974/