Android アプリケーションからストライプ支払いをサポートしようとしていますが、実行されません。Javaは互換性がありませんか?私のコードとエラーは以下の通りです:
package io.noq.kiosk.android;
import java.util.HashMap;
import java.util.Map;
import com.stripe.Stripe;
import com.stripe.exception.APIConnectionException;
import com.stripe.exception.AuthenticationException;
import com.stripe.exception.CardException;
import com.stripe.exception.InvalidRequestException;
import com.stripe.exception.StripeException;
import com.stripe.model.Charge;
import io.noq.android.R;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
public class OnSwipeActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Stripe.apiKey = "the secret (intentionally omitting)";
Map<String, Object> chargeMap = new HashMap<String, Object>();
chargeMap.put("amount", 100);
chargeMap.put("currency", "usd");
Map<String, Object> cardMap = new HashMap<String, Object>();
cardMap.put("number", "4242424242424242");
cardMap.put("exp_month", 12);
cardMap.put("exp_year", 2013);
chargeMap.put("card", cardMap);
try {
Charge charge = Charge.create(chargeMap);
System.out.println(charge);
Log.i("Status is: " + "exiting try onCreate-PayActivity", "let's see what goes out....");
System.out.println("Status is: "+ "exiting try onCreate-PayActivity");
} catch (CardException e) {
// Since it's a decline, CardException will be caught
System.out.println("CardException is: " + e.getCode());
System.out.println("CardException is: " + e.getParam());
Log.i(OnSwipeActivity.class.getName(), "e.getCode() ...." + e.getCode());
} catch (InvalidRequestException e) {
// Invalid parameters were supplied to Stripe's API
System.out.println("InvalidRequestException: " + e.getMessage());
Log.i(OnSwipeActivity.class.getName(),"e.getCode() ...." + e.getCause());
} catch (AuthenticationException e) {
// Authentication with Stripe's API failed (maybe you changed API keys recently)
System.out.println("AuthenticationException: " + e.getMessage());
Log.i(OnSwipeActivity.class.getName(), "e.getCode() ...." + e.getCause());
} catch (APIConnectionException e) {
// Network communication with Stripe failed
System.out.println("APIConnectionException: " + e.getMessage());
Log.i(OnSwipeActivity.class.getName(), "e.getCode() ...." + e.getCause());
} catch (StripeException e) {
// Display a very generic error to the user, and maybe send yourself an email
System.out.println("StripeException: " + e.getMessage());
Log.i(OnSwipeActivity.class.getName(), "e.getCode() ...." + e.getCause());
} catch (Exception e) {
// Something else happened, completely unrelated to Stripe
System.out.println("Exception: " + e.getMessage());
Log.i(OnSwipeActivity.class.getName(), "e.getCode() ...." + e.getCause());
}
}
}
エラーは次のとおりです。
12-25 05:34:22.625: W/dalvikvm(801): threadid=1: キャッチされない例外で終了するスレッド (グループ = 0x40a70930)
12-25 05:34:22.647: E/AndroidRuntime(801): 致命的な例外: メイン
12-25 05:34:22.647: E/AndroidRuntime(801): java.lang.NoClassDefFoundError com.stripe.Stripe
12-25 05:34:22.647: E/AndroidRuntime(801): io.noq.kiosk.android.OnSwipeActivity.onCreate(OnSwipeActivity.java:26)
12-25 05:34:22.647: E/AndroidRuntime(801): android.app.Activity.performCreate(Activity.java:5104)
12-25 05:34:22.647: E/AndroidRuntime(801): android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
12-25 05:34:22.647: E/AndroidRuntime(801): android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
12-25 05:34:22.647: E/AndroidRuntime(801): android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
12-25 05:34:22.647: E/AndroidRuntime(801): android.app.ActivityThread.access$600(ActivityThread.java:141)
12-25 05:34:22.647: E/AndroidRuntime(801): android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234) で
12-25 05:34:22.647: E/AndroidRuntime(801): android.os.Handler.dispatchMessage(Handler.java:99)
12-25 05:34:22.647: E/AndroidRuntime(801): android.os.Looper.loop(Looper.java:137)
12-25 05:34:22.647: E/AndroidRuntime(801): android.app.ActivityThread.main(ActivityThread.java:5039)
12-25 05:34:22.647: E/AndroidRuntime(801): java.lang.reflect.Method.invokeNative(ネイティブメソッド)
12-25 05:34:22.647: E/AndroidRuntime(801): java.lang.reflect.Method.invoke(Method.java:511)
12-25 05:34:22.647: E/AndroidRuntime(801): com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) で
12-25 05:34:22.647: E/AndroidRuntime(801): com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
12-25 05:34:22.647: E/AndroidRuntime(801): dalvik.system.NativeStart.main(ネイティブメソッド)