- 使用PhoenGap 2.2.0
- 执行\bin\create C:\Temp\Test com.test 测试
- 有以下输出
Microsoft (R) Windows 脚本宿主版本 5.8
版权所有 (C) 微软公司。版权所有。
Creating new android project...
Building jar and js files...
Copying template files...
Copying js, jar & config.xml files...
Copying cordova command tools...
Updating AndroidManifest.xml and Main Activity...
- 引进项目
- 文件 > 新建 > 项目 > Android > 来自现有代码的 Android 项目
- 做出改变
- 检查了 res\xml\config.xml 和行
<plugin name="Notification" value="org.apache.cordova.Notification"/>
存在
- 检查index.html是否包含cordova-2.2.0.js
<script type="text/javascript">
app.initialize();
</script>
to
<script type="text/javascript">
function showAlert(msg){
navigator.notification.alert(msg);
}
document.addEventListener("deviceready", showAlert('You are the winner!'), false);
app.initialize();
</script>
我收到以下错误11-25 10:29:58.399: E/Web Console(14604): Uncaught TypeError: Cannot call method 'alert' of undefined at file:///android_asset/www/index.html:40
<script type="text/javascript">
app.initialize();
</script>
to
<script type="text/javascript">
function successAlert(){}
function errorAlert(){}
function showAlert(msg){
cordova.exec(successAlert, errorAlert, "Notification","alert", [msg]);
}
document.addEventListener("deviceready", showAlert('You are the winner!'), false);
app.initialize();
</script>
我收到以下错误11-25 10:25:06.575: E/Web Console(14149): Uncaught TypeError: Object #<Object> has no method 'exec' at file:///android_asset/www/index.html:42
}
我确信我错过了一些东西......只是我无法断定它是什么。请帮帮我。