Camera Phonegap PictureSourceType undefined

时间:2014-02-25 14:20:08

标签: android cordova camera undefined

所以我得到了以下问题

我通过cli安装了phonegap,安装了相机插件以及看起来远程相关的所有内容。

我仍然收到错误消息,指出我的插件未正确安装。但是在运行cmd行时要求安装所有已安装的插件摄像头。我正在使用android 4.3

我的config.xml

<?xml version='1.0' encoding='utf-8'?>
<widget xmlns:gap="http://phonegap.com/ns/1.0"
    id="com.aycete.proofofconcept"
    version="1.0.0"
    xmlns="http://www.w3.org/ns/widgets" >

    <name>
Hello Cordova
    </name>

    <description>
        A sample Apache Cordova application that responds to the deviceready event.
    </description>

    <access origin="*" />

    <content src="index.html" />

    <preference
        name="loglevel"
        value="DEBUG" />

    <feature name="App" >
        <param
            name="android-package"
            value="org.apache.cordova.App" />
    </feature>

    <name>
PoCPhoneGap
    </name>

    <description>
        Hello World sample application that responds to the deviceready event.
    </description>

    <author
        email="support@phonegap.com"
        href="http://phonegap.com" >
        PhoneGap Team
    </author>

    <feature name="http://api.phonegap.com/1.0/device" />

    <preference
        name="permissions"
        value="none" />
    <preference
        name="orientation"
        value="default" />
    <preference
        name="target-device"
        value="universal" />
    <preference
        name="fullscreen"
        value="true" />
    <preference
        name="webviewbounce"
        value="true" />
    <preference
        name="prerendered-icon"
        value="true" />
    <preference
        name="stay-in-webview"
        value="false" />
    <preference
        name="ios-statusbarstyle"
        value="black-opaque" />
    <preference
        name="detect-data-types"
        value="true" />
    <preference
        name="exit-on-suspend"
        value="false" />
    <preference
        name="show-splash-screen-spinner"
        value="true" />
    <preference
        name="auto-hide-splash-screen"
        value="true" />
    <preference
        name="disable-cursor"
        value="false" />
    <preference
        name="android-minSdkVersion"
        value="7" />
    <preference
        name="android-installLocation"
        value="auto" />

    <icon src="icon.png" />
    <icon
        src="res/icon/android/icon-36-ldpi.png"
        gap:density="ldpi"
        gap:platform="android" />
    <icon
        src="res/icon/android/icon-48-mdpi.png"
        gap:density="mdpi"
        gap:platform="android" />
    <icon
        src="res/icon/android/icon-72-hdpi.png"
        gap:density="hdpi"
        gap:platform="android" />
    <icon
        src="res/icon/android/icon-96-xhdpi.png"
        gap:density="xhdpi"
        gap:platform="android" />
    <icon
        src="res/icon/blackberry/icon-80.png"
        gap:platform="blackberry" />
    <icon
        src="res/icon/blackberry/icon-80.png"
        gap:platform="blackberry"
        gap:state="hover" />
    <icon
        height="57"
        src="res/icon/ios/icon-57.png"
        width="57"
        gap:platform="ios" />
    <icon
        height="72"
        src="res/icon/ios/icon-72.png"
        width="72"
        gap:platform="ios" />
    <icon
        height="114"
        src="res/icon/ios/icon-57-2x.png"
        width="114"
        gap:platform="ios" />
    <icon
        height="144"
        src="res/icon/ios/icon-72-2x.png"
        width="144"
        gap:platform="ios" />
    <icon
        src="res/icon/webos/icon-64.png"
        gap:platform="webos" />
    <icon
        src="res/icon/windows-phone/icon-48.png"
        gap:platform="winphone" />
    <icon
        src="res/icon/windows-phone/icon-173.png"
        gap:platform="winphone"
        gap:role="background" />

    <gap:splash
        src="res/screen/android/screen-ldpi-portrait.png"
        gap:density="ldpi"
        gap:platform="android" />
    <gap:splash
        src="res/screen/android/screen-mdpi-portrait.png"
        gap:density="mdpi"
        gap:platform="android" />
    <gap:splash
        src="res/screen/android/screen-hdpi-portrait.png"
        gap:density="hdpi"
        gap:platform="android" />
    <gap:splash
        src="res/screen/android/screen-xhdpi-portrait.png"
        gap:density="xhdpi"
        gap:platform="android" />
    <gap:splash
        src="res/screen/blackberry/screen-225.png"
        gap:platform="blackberry" />
    <gap:splash
        height="480"
        src="res/screen/ios/screen-iphone-portrait.png"
        width="320"
        gap:platform="ios" />
    <gap:splash
        height="960"
        src="res/screen/ios/screen-iphone-portrait-2x.png"
        width="640"
        gap:platform="ios" />
    <gap:splash
        height="1024"
        src="res/screen/ios/screen-ipad-portrait.png"
        width="768"
        gap:platform="ios" />
    <gap:splash
        height="768"
        src="res/screen/ios/screen-ipad-landscape.png"
        width="1024"
        gap:platform="ios" />
    <gap:splash
        src="res/screen/windows-phone/screen-portrait.jpg"
        gap:platform="winphone" />

    <access origin="http://127.0.0.1*" />

    <feature name="File" >
        <param
            name="android-package"
            value="org.apache.cordova.file.FileUtils" />
    </feature>
    <feature name="Capture" >
        <param
            name="android-package"
            value="org.apache.cordova.mediacapture.Capture" />
    </feature>
    <feature name="Media" >
        <param
            name="android-package"
            value="org.apache.cordova.media.AudioHandler" />
    </feature>
    <feature name="Camera" >
        <param
            name="android-package"
            value="org.apache.cordova.camera.CameraLauncher" />
    </feature>

</widget>

和我的android清单:

<?xml version='1.0' encoding='utf-8'?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.aycete.proofofconcept"
android:hardwareAccelerated="true"
android:versionCode="1"
android:versionName="1.0.0"
android:windowSoftInputMode="adjustPan" >

<supports-screens
    android:anyDensity="true"
    android:largeScreens="true"
    android:normalScreens="true"
    android:resizeable="true"
    android:smallScreens="true"
    android:xlargeScreens="true" />

<uses-permission android:name="android.permission.INTERNET" />

<uses-sdk
    android:minSdkVersion="10"
    android:targetSdkVersion="19" />

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<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_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />

<uses-feature android:name="android.hardware.camera" />
<application
    android:debuggable="true"
    android:hardwareAccelerated="true"
    android:icon="@drawable/icon"
    android:label="@string/app_name" >
    <activity
        android:name="PoCPhoneGap"
        android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.Black.NoTitleBar" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>


</manifest>

我100%确定javascript代码是正确的,并且正在调用设备。

我得到的错误(在我的设备内部功能):

02-25 15:16:57.316: E/Web Console(7356): Uncaught TypeError: Cannot read property 'PictureSourceType' of undefined at file:///android_asset/www/js/index.js:37

相关的index.js

  /*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
//Stuff for the camera:
var pictureSource;
// picture source
var destinationType;
// sets the format of returned value
var app = {
    // Application Constructor
    initialize : function() {
        this.bindEvents();
    },
    // Bind Event Listeners
    //
    // Bind any events that are required on startup. Common events are:
    // 'load', 'deviceready', 'offline', and 'online'.
    bindEvents : function() {
        document.addEventListener('deviceready', this.onDeviceReady, false);
    },
    // deviceready Event Handler
    //
    // The scope of 'this' is the event. In order to call the 'receivedEvent'
    // function, we must explicity call 'app.receivedEvent(...);'
    onDeviceReady : function() {
        pictureSource = navigator.camera.PictureSourceType;
        destinationType = navigator.camera.DestinationType;
        console.log('deviceisready');
    }
};

0 个答案:

没有答案