Phonegap错误-无法读取property 'capture'undefined"在And
Phonegap Error - "Cannot read property 'capture' of undefined" on Android
尝试用PhoneGap创建一个入门应用程序。我被卡在这行了:
navigator.device.capture.captureAudio(onSuccess, onError, {limits:1, duration:5});
它在iOS上工作正常,但在Android模拟器上抛出此错误:
无法读取未定义属性'capture'
这是navigator
对象,在错误发生时(注意没有导致这个错误的device
属性)
{
"language": "en-US",
"product": "Gecko",
"mimeTypes": {
"length": 0
},
"appVersion": "5.0 (Linux; U; Android 4.0.3; en-us; sdk Build/MR1) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30",
"plugins": {
"length": 0
},
"onLine": true,
"connection": {
"type": 0
},
"platform": "Linux armv7l",
"vendor": "Google Inc.",
"appCodeName": "Mozilla",
"geolocation": {},
"cookieEnabled": true,
"appName": "Netscape",
"productSub": "20030107",
"userAgent": "Mozilla/5.0 (Linux; U; Android 4.0.3; en-us; sdk Build/MR1) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30",
"vendorSub": ""
}
这是Phonegap.js
加载后的PhoneGap
对象(注意它是device: true
)
{
"commandQueue": [],
"commandQueueFlushing": false,
"_constructors": [
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null
],
"documentEventHandler": {},
"windowEventHandler": {},
"resources": {
"base": true,
"debugconsole": true,
"position": true,
"acceleration": true,
"accelerometer": true,
"battery": true,
"camera": true,
"device": true,
"capture": true,
"contact": true,
"file": true,
"filetransfer": true,
"geolocation": true,
"compass": true,
"media": true,
"notification": true,
"orientation": true,
"sms": true,
"telephony": true,
"network": true,
"splashscreen": true
},
"available": false,
"sessionKey": 0,
"callbackId": 0,
"callbacks": {},
"callbackStatus": {
"NO_RESULT": 0,
"OK": 1,
"CLASS_NOT_FOUND_EXCEPTION": 2,
"ILLEGAL_ACCESS_EXCEPTION": 3,
"INSTANTIATION_EXCEPTION": 4,
"MALFORMED_URL_EXCEPTION": 5,
"IO_EXCEPTION": 6,
"INVALID_ACTION": 7,
"JSON_EXCEPTION": 8,
"ERROR": 9
},
"mediaObjects": {}
}
有什么办法可以解决这个问题吗?
好吧,这是我偶然发现的最傻逼的解决方案!
Android的JS 与iOS的不同。这些文件的名称是一样的——phonegap-x.x.x.js
。没有必要猜测其他移动平台的情况会有所不同。
我明白,你需要有不同的JS为不同的平台,但如何提及的地方?
一旦我从Android文件夹中拖出JS,一切都就位了。
感谢这个问题的答案:deviceready won't fire in Phonegap 1.0.0 on Android
您的www目录中的phonegap.js文件名是否与index.html引用匹配?一旦我将phonegap.js更改为phonegap-1.3.0.js, API文档中的完整示例将在我的HTC evo
相关文章:
- 为什么会出现错误;未捕获的类型错误:undefined不是函数;
- /undefined在我的404错误日志中多次出现
- RequireJS向模块传递配置总是返回undefined
- JSON数组数据返回Undefined
- 为什么会出现错误,“UncaughtTypeError:undefined不是函数”
- Array.lenght = undefined
- mongoose.connect undefined不是一个函数
- JavaScript”;.方法“;返回undefined
- Uncaught TypeError:undefined不是函数-ember js
- Jquery - table.row(tr) is undefined
- jQuery可以't获取data-*属性值,返回undefined
- noty.js is returning undefined
- 将对象的列表c#传递给javascript:undefined变量时出错
- $routeParams is undefined
- 试图打印/调用/或提醒数组中的对象:Getting Undefined
- jQuery Mobile Undefined不是一个函数
- Javascript/JSON警报返回Undefined
- 未捕获的类型错误:undefined不是函数$
- node js post request.body undefined
- Phonegap错误-无法读取property 'capture'undefined"在And