android中未找到PhoneGap类错误
我的PhoneGap(Android)应用程序面临一些问题。据我所知,我做的每件事都很好。这就是我所做的android中未找到PhoneGap类错误,android,cordova,Android,Cordova,我的PhoneGap(Android)应用程序面临一些问题。据我所知,我做的每件事都很好。这就是我所做的 在Eclipse中创建项目之后,我在libs文件夹中添加了cordova-2.2.0.jar 然后我编辑了AndroidManifest.xml和MainActivity.java 我在资产文件夹中创建了www文件夹,并保留了cordova-2.2.0.js和index.html 到目前为止,一切都还好。但是当我运行这个程序时,它显示了一个错误。我附上了一个截图和示例代码 AndroidM
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.hellopgap"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:xlargeScreens="true"
android:resizeable="true"
android:anyDensity="true"
/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.RECORD_VIDEO"/>
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.BROADCAST_STICKY" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
index.html
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="format-detection" content="telephone=no" />
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
<script type="text/javascript" charset="utf-8" src="cordova-2.2.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
}
// alert dialog dismissed
function alertDismissed() {
// do something
}
// Show a custom alertDismissed
//
function showAlert() {
navigator.notification.alert(
'You are the winner!', // message
alertDismissed, // callback
'Game Over', // title
'Done' // buttonName
);
}
</script>
<title>Notification Example</title>
</head>
<body>
<div class="app">
<h1>Apache Cordova</h1>
<h3>This is sample PhoneGap apps</h3>
<p><a href="#" onclick="showAlert(); return false;">Show Alert</a></p>
</div>
</body>
</html>
//等待Cordova加载
//
文件。添加的监听器(“deviceready”,OnDeviceraddy,false);
//科尔多瓦准备好了
//
函数ondevicerady(){
//空的
}
//警报对话框已关闭
函数{
//做点什么
}
//显示自定义警报
//
函数showAlert(){
navigator.notification.alert(
“你是赢家!”,//留言
AlertDisabled,//回调
“游戏结束了”,//标题
'完成'//buttonName
);
}
通知示例
阿帕奇科尔多瓦酒店
这是PhoneGap应用程序示例
提前谢谢。您的apps res/xml目录中似乎缺少config.xml。它作为phonegap发行版的一部分包含在lib/android/res/xml/config.xml中。将该文件复制到您的res/xml目录中,您应该会没事。我以前也遇到过同样的问题。我刚刚完成了以下步骤,它就开始工作了:
- 转到选定项目的属性
- 转到java构建路径
- 选择“订单和导出”
- 启用所有检查(依赖项目)
- 现在只需清理并再次运行应用程序
它对我很有用…我曾经面临类似的问题,今天我在Javascript中发现,除非调用deviceready事件;导航器,设备等仍保持未定义
文档中没有提到这一点。这对我不起作用,但我的应用程序正在寻找的类是ContactManager。但它在清单中的位置正确。您能详细介绍一下您启用的所有检查吗。很难理解为那些不使用eclipse的人做些什么。实际上,它:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="format-detection" content="telephone=no" />
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
<script type="text/javascript" charset="utf-8" src="cordova-2.2.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
}
// alert dialog dismissed
function alertDismissed() {
// do something
}
// Show a custom alertDismissed
//
function showAlert() {
navigator.notification.alert(
'You are the winner!', // message
alertDismissed, // callback
'Game Over', // title
'Done' // buttonName
);
}
</script>
<title>Notification Example</title>
</head>
<body>
<div class="app">
<h1>Apache Cordova</h1>
<h3>This is sample PhoneGap apps</h3>
<p><a href="#" onclick="showAlert(); return false;">Show Alert</a></p>
</div>
</body>
</html>