2013-10-09 2 views
2

캡처 플러그인을 사용하면 사진을 찍은 후에 앱이 항상 중단됩니다. 캡처 버튼을 클릭하면 카메라 앱이 열리고 사진을 찍은 다음 체크 표시를 클릭하면 앱이 닫히고 "안타깝게도 HelloWorld가 중지되었습니다."라고 표시됩니다. 그런 다음 갤러리 앱을 보면 사진이 있습니다. 내가 잘못하고있는 것이 있습니까? 아니면 플러그인에 문제가 있습니까? 여기 PhoneGap Capture Plugin이 Android에 충돌 함

내가 무슨 짓을했는지 :

내가 프로젝트

phonegap create exampleProject 
cd exampleProject 

(정확하게는 3.1.0-0.15.0) 새로운 폰갭 3.x를 생성 및 캡처 플러그인을 설치

phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture.git 

org.apache.cordova.media-capture를 plugins 폴더에 넣습니다.

phonegap build android 

이 (미디어 캡처가 종속되어 있기 때문에), 플러그인 폴더에 android.json 만든 플러그인 폴더에 org.apache.cordova.file 넣어 : 그럼 프로젝트를 만들었습니다.

<input type="button" value="Capture" onClick="capture();" /> 
: 그것은 또한

내가 index.html을에 다음을 넣어 플랫폼/안드로이드를 만들고 플랫폼/안드로이드/SRC에서 플랫폼/안드로이드/자산/www /에서 플러그인과 올바른 자바 파일에 올바른 JS 파일을 저장합니다

<!DOCTYPE html> 
<html> 
    <head> 
     <meta 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" /> 
     <link rel="stylesheet" type="text/css" href="css/index.css" /> 
     <title>Hello World</title> 
    </head> 
    <body> 
     <div class="app"> 
      <h1>PhoneGap</h1> 
      <div id="deviceready" class="blink"> 
       <p class="event listening">Connecting to Device</p> 
       <p class="event received">Device is Ready</p> 
      </div> 
      <input type="button" value="Capture" onClick="capture();" /> 
     </div> 
     <script type="text/javascript" src="phonegap.js"></script> 
     <script type="text/javascript" src="js/index.js"></script> 
     <script type="text/javascript"> 
      app.initialize(); 
     </script> 
    </body> 
</html> 

그리고 캡처()를 추가하고, 따라 GetErrorMessage()하는 index.js의 끝 기능 :

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() { 
     app.receivedEvent('deviceready'); 
    }, 
    // Update DOM on a Received Event 
    receivedEvent: function(id) { 
     var parentElement = document.getElementById(id); 
     var listeningElement = parentElement.querySelector('.listening'); 
     var receivedElement = parentElement.querySelector('.received'); 

     listeningElement.setAttribute('style', 'display:none;'); 
     receivedElement.setAttribute('style', 'display:block;'); 

     console.log('Received Event: ' + id); 
    } 
}; 

function capture() { 
    var options = { limit: 1 }; 
    try { 
     navigator.device.capture.captureImage(
      function(response) { 
       alert("success: response=" + stringify(response)); 
      }, 
      function(CaptureError) { 
       alert('Error: ' + getErrorMessage(CaptureError)); 
      }, 
      options 
     ); 
    } catch(e) { 
     alert("catch e="+e); 
    } 
} 

function getErrorMessage(CaptureError) { 
    var errorMessage = 'An unknown error occured while trying to get your media, please try again.'; 
    switch(CaptureError.code) { 
    case CaptureError.CAPTURE_NOT_SUPPORTED: 
     errorMessage = 'This app does not support the media type.'; 
     break; 
    case CaptureError.CAPTURE_NO_MEDIA_FILES: 
     errorMessage = 'No media files returned.'; 
     break; 
    case CaptureError.CAPTURE_INTERNAL_ERR: 
     errorMessage = 'The capture process experienced an internal error.'; 
     break; 
    case CaptureError.CAPTURE_APPLICATION_BUSY: 
     errorMessage = 'The application was too busy with something else to handle the media capture.'; 
     break; 
    case CaptureError.CAPTURE_INVALID_ARGUMENT: 
     errorMessage = 'Values submitted for capture were out of range, notify support.'; 
     break; 
    case 3: 
     errorMessage = 'Did you cancel? Please try again.'; 
     break; 
    default: 
     break; 
    } 
    return errorMessage; 
} 
,369

여기에 전체 파일입니다

은 그 때 나는 응용 프로그램 구축 :

phonegap build android 

을 오는 오류 메시지가 있는지 확인하기 위해 언급 한 문제를 (안드로이드 SDK와 함께 제공)

+0

안녕하세요, 새로 설치 한 Nexus 7에서 동일한 문제가 발생합니다. 설치가 제대로 된 것 같습니다. 이것은 cordova 3.0의 버그 일 수 있습니다. 좀 더 조사한 후에 다시 게시 할 것입니다. – MBillau

+1

나는이를 추적하기 위해 https://issues.apache.org/jira/browse/CB-5052를 제출했다. StackOverflow에는 다른 사람들도이 문제가 있습니다. – MBillau

+1

감사합니다. 이 질문에 대한 대답은 나를 위해 일했다 : http://stackoverflow.com/questions/19183174/phonegap-video-capture-crashes – aharris88

답변

1

사용 로그 캣을 내 안드로이드 장치에서 실행 및 체험 전화 갭에서.

관련 문제