2012-11-16 4 views
0

card.io 및 phonegap (crodova)에 대한 플러그인을 작성하려고합니다. 내 문제는 내가 다음과 같은 오류로 인해 응용 프로그램이 충돌하는 신용 ​​카드를 스캔하기 위해 card.io를 열 때입니다.card.io Android Phonegap 통합

11-16 14 : 19 : 52.990 : E/SurfaceTextureClient (17199) : queueBuffer : 오류 큐 버퍼 SurfaceTexture에, -9

11-16 14 : 19 : 55.580 : A/libc의 (17,199) 치명적인 신호 (11) (SIGSEGV)으로 0x00000010 (코드 = 1)

에서 I는 자바 프로 모르지만 나는 phonegap에 대한 플러그인 설명서를 따라 이미 완료된 다른 것들을 살펴 보았다. 다음은

내 코드입니다 :

package com.eliashajj.MyApp; 

import org.apache.cordova.DroidGap; 

import android.app.AlertDialog; 
import android.content.Intent; 
import android.os.Bundle; 
import android.util.Log; 
import android.view.Gravity; 
import android.view.Menu; 
import android.view.MenuInflater; 
import android.view.View; 
import android.widget.TextView; 
import com.elixir.vmart.R; 

public class MyApp extends DroidGap { 

    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     super.setIntegerProperty("splashscreen", R.drawable.splash); 
     try { 
      super.loadUrl("file:///android_asset/www/index.html", 10000); 
     } catch (Exception e) { 
      AlertDialog.Builder builder = new AlertDialog.Builder(this); 
      builder.setTitle("Error"); 
      builder.setMessage("Please make sure you have have and internet connection and try again."); 
      builder.setPositiveButton("OK", null); 
      AlertDialog dialog = builder.show(); 

      TextView messageView = (TextView) dialog 
        .findViewById(android.R.id.message); 
      messageView.setGravity(Gravity.CENTER); 
     } 
    } 
} 

가 여기 내 Card.IO 핸들러

package com.eliashajj.MyApp; 

import io.card.payment.CardIOActivity; 
import io.card.payment.CreditCard; 

import org.apache.cordova.api.Plugin; 
import org.apache.cordova.api.PluginResult; 

import org.json.JSONArray; 
import org.json.JSONException; 
import org.json.JSONObject; 

import android.content.Context; 
import android.content.Intent; 
import android.util.Log; 


public class Cardio extends Plugin{ 

    private static final String MY_CARDIO_APP_TOKEN = "MY APP TOKEN"; 
    private static final String SCAN = "scan"; 
    private static final String CC_VARIABLE = "cc_number"; 
    private static final String CC_MONTH_VARIABLE = "cc_month"; 
    private static final String CC_YEAR_VARIABLE = "cc_year"; 
    private static final String CC_CVV_VARIABLE = "cc_cvv"; 
    private static String CC_NUMBER; 
    private static int EXPIRY_MONTH; 
    private static int EXPIRY_YEAR; 
    private static int CVV_NUMBER; 


    public String callback; 
    public static final int REQUEST_CODE = 0x0ba7c0de; 

    /* 
    * Constructor 
    */ 
    public Cardio(){ 

    } 

    /* 
    * Executes the request and returns PluginResult. 
    * 
    * @param action  The action to execute. 
    * @param args   JSONArry of arguments for the plugin. 
    * @param callbackId The callback id used when calling back into JavaScript. 
    * @return    A PluginResult object with a status and message. 
    */ 
    public PluginResult execute(String action, JSONArray args, String callbackId) { 
     this.callback=callbackId; 

     //Context cc = this.cordova.getActivity().getApplicationContext(); 
     if(action.equals(SCAN)){ 
      scan(); 
     } 
     PluginResult r = new PluginResult(PluginResult.Status.NO_RESULT); 
     r.setKeepCallback(true); 
     return r; 
    } 

    public void scan() { 
     // This method is set up as an onClick handler in the layout xml 
     // e.g. android:onClick="onScanPress" 
     Context cc = this.cordova.getActivity().getApplicationContext(); 

     Intent scanIntent = new Intent(cc, CardIOActivity.class); 

     // required for authentication with card.io 
     scanIntent.putExtra(CardIOActivity.EXTRA_APP_TOKEN, MY_CARDIO_APP_TOKEN); 

     // customize these values to suit your needs. 
     scanIntent.putExtra(CardIOActivity.EXTRA_REQUIRE_EXPIRY, true); // default: true 
     scanIntent.putExtra(CardIOActivity.EXTRA_REQUIRE_CVV, true); // default: false 
     scanIntent.putExtra(CardIOActivity.EXTRA_REQUIRE_ZIP, false); // default: false 

     // hides the manual entry button 
     // if set, developers should provide their own manual entry mechanism in the app 
     scanIntent.putExtra(CardIOActivity.EXTRA_SUPPRESS_MANUAL_ENTRY, false); // default: false 

     Log.d("SCANNING TAG: ", "1"); 
     // MY_SCAN_REQUEST_CODE is arbitrary and is only used within this activity. 
     this.cordova.startActivityForResult((Plugin) this, scanIntent, REQUEST_CODE); 
     Log.d("SCANNING TAG: ", "2"); 
    } 

    @Override 
    public void onActivityResult(int requestCode, int resultCode, Intent data) { 
     Log.d("SCANNING TAG: ", "3"); 
     super.onActivityResult(requestCode, resultCode, data); 
     Log.d("SCANNING TAG: ", "4"); 

     Log.d("Request Code: ",""+requestCode); 
     Log.d("Request Code 2: ",""+REQUEST_CODE); 

     if (requestCode == REQUEST_CODE) { 
      Log.d("SCANNING TAG: ", "Data"+data); 
      if (data != null && data.hasExtra(CardIOActivity.EXTRA_SCAN_RESULT)) { 
       JSONObject obj = new JSONObject(); 
       CreditCard scanResult = data.getParcelableExtra(CardIOActivity.EXTRA_SCAN_RESULT); 

       // Never log a raw card number. Avoid displaying it, but if necessary use getFormattedCardNumber() 
       CC_NUMBER = scanResult.getRedactedCardNumber(); 
       // CC Expiry Month 
       EXPIRY_MONTH = scanResult.expiryMonth; 
       // CC Expiry Year 
       EXPIRY_YEAR = scanResult.expiryYear; 
       // CC CVV Number 
       CVV_NUMBER = scanResult.cvv.length(); 

       try{ 
        obj.put(CC_VARIABLE, CC_NUMBER); 
        obj.put(CC_MONTH_VARIABLE, EXPIRY_MONTH); 
        obj.put(CC_YEAR_VARIABLE, EXPIRY_YEAR); 
        obj.put(CC_CVV_VARIABLE, CVV_NUMBER); 
       } 
       catch(JSONException e){ 

       } 
       this.success(new PluginResult(PluginResult.Status.OK, obj), this.callback); 
      } 
     } 
     else { 
      // Scanning was canceled 
     } 
    } 

    protected void onResume() { 
     super.onResume(true); 

    } 
} 

메인 클래스 여기 내 코르도바 플러그인 자바 스크립트

,691입니다
var Cardio = function() { 
}; 


//------------------------------------------------------------------- 
Cardio.prototype.scan = function(successCallback, errorCallback) { 
    if (errorCallback == null) { errorCallback = function() {}} 

    if (typeof errorCallback != "function") { 
     console.log("Cardio.scan failure: failure parameter not a function"); 
     return 
    } 

    if (typeof successCallback != "function") { 
     console.log("Cardio.scan failure: success callback parameter must be a function"); 
     return 
    } 

    cordova.exec(successCallback, errorCallback, 'Cardio', 'scan', []); 
}; 

//------------------------------------------------------------------- 

if(!window.plugins) { 
    window.plugins = {}; 
} 
if (!window.plugins.cardio) { 
    window.plugins.cardio = new Cardio(); 
} 

어떤 도움을 주시면 감사하겠습니다. 미리 감사드립니다.

+0

Java 코드에 많은 로그가 있습니다.이 로그는 adb logcat에 어디에 표시됩니까? –

답변

0

libc SIGSEGV는 기본 계층 (libc)의 segfault입니다. 이 중 두 가지는 3.0.2 릴리스에서 수정되었으므로 최신 버전의 SDK가 있는지 확인하십시오.

그렇지 않으면 네이티브 크래시 덤프를 보지 않고도 문제가 무엇인지 정확하게 알기가 어렵습니다. DDMS logcat 뷰는 호스팅 애플리케이션이 아닌 Android에 의해 생성되기 때문에 숨겨지기 때문에 logcat 필터링을 제거해야 볼 수 있습니다.