android java.security.NoSuchAlgorithmException:未找到KeyManagerFactory SunX509实现

时间:2014-03-22 13:33:49

标签: android paypal

我正在尝试处理PayPal预付款付款。

我使用以下代码,可在PayPal集成指南中找到:

RequestEnvelope requestEnvelope = new RequestEnvelope("en_US");
PreapprovalRequest preapprovalRequest = new PreapprovalRequest();
preapprovalRequest.setRequestEnvelope(requestEnvelope);

preapprovalRequest.setCurrencyCode("USD");
preapprovalRequest.setStartingDate("2014-03-22");
preapprovalRequest.setEndingDate("2015-03-22");

preapprovalRequest.setMaxAmountPerPayment(1.0);
preapprovalRequest.setMaxNumberOfPayments(5);
preapprovalRequest.setMaxTotalAmountOfAllPayments(5.0);

preapprovalRequest.setSenderEmail("platfo_1255077030_biz@gmail.com");
preapprovalRequest.setCancelUrl("https://devtools-    paypal.com/guide/ap_preapprove_payment?cancel=true");
preapprovalRequest.setReturnUrl("https://devtools-  paypal.com/guide/ap_preapprove_payment?success=true");
preapprovalRequest.setIpnNotificationUrl("http://replaceIpnUrl.com");

Map<String, String> sdkConfig = new HashMap<String, String>();
sdkConfig.put("mode", "sandbox");
sdkConfig.put("acct1.UserName", "jb-us-seller_api1.paypal.com");
sdkConfig.put("acct1.Password", "WX4WTU3S8MY44S7F");
sdkConfig.put("acct1.Signature","AFcWxV21C7fd0v3bYYYRCpSSRl31A7yDhhsPUU2XhtMoZXsWHFxu-RWy");
sdkConfig.put("acct1.AppId","APP-80W284485P519543T");

AdaptivePaymentsService adaptivePaymentsService = new  AdaptivePaymentsService(sdkConfig);
PreapprovalResponse preapprovalResponse = adaptivePaymentsService.preapproval(preapprovalRequest); 

但是我收到了这个错误:

03-22 14:04:15.926: E/AndroidRuntime(14824): FATAL EXCEPTION: main
03-22 14:04:15.926: E/AndroidRuntime(14824): Process: com.example.provapaypal, PID: 14824
03-22 14:04:15.926: E/AndroidRuntime(14824): java.lang.ExceptionInInitializerError
03-22 14:04:15.926: E/AndroidRuntime(14824):    at com.paypal.core.SSLUtil.<clinit>(SSLUtil.java:40)
03-22 14:04:15.926: E/AndroidRuntime(14824):    at com.paypal.core.DefaultHttpConnection.<init>(DefaultHttpConnection.java:30)
03-22 14:04:15.926: E/AndroidRuntime(14824):    at com.paypal.core.ConnectionManager.getConnection(ConnectionManager.java:52)
03-22 14:04:15.926: E/AndroidRuntime(14824):    at com.paypal.core.APIService.makeRequestUsing(APIService.java:151)
03-22 14:04:15.926: E/AndroidRuntime(14824):    at com.paypal.core.BaseService.call(BaseService.java:258)
03-22 14:04:15.926: E/AndroidRuntime(14824):    at com.paypal.svcs.services.AdaptivePaymentsService.preapproval(AdaptivePaymentsService.java:699)
03-22 14:04:15.926: E/AndroidRuntime(14824):    at com.paypal.svcs.services.AdaptivePaymentsService.preapproval(AdaptivePaymentsService.java:662)
03-22 14:04:15.926: E/AndroidRuntime(14824):    at com.example.provapaypal.MainActivity.onCreate(MainActivity.java:62)
03-22 14:04:15.926: E/AndroidRuntime(14824):    at android.app.Activity.performCreate(Activity.java:5231)
03-22 14:04:15.926: E/AndroidRuntime(14824):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
03-22 14:04:15.926: E/AndroidRuntime(14824):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
03-22 14:04:15.926: E/AndroidRuntime(14824):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
03-22 14:04:15.926: E/AndroidRuntime(14824):    at android.app.ActivityThread.access$800(ActivityThread.java:135)
03-22 14:04:15.926: E/AndroidRuntime(14824):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
03-22 14:04:15.926: E/AndroidRuntime(14824):    at android.os.Handler.dispatchMessage(Handler.java:102)
03-22 14:04:15.926: E/AndroidRuntime(14824):    at android.os.Looper.loop(Looper.java:136)
03-22 14:04:15.926: E/AndroidRuntime(14824):    at android.app.ActivityThread.main(ActivityThread.java:5017)
03-22 14:04:15.926: E/AndroidRuntime(14824):    at java.lang.reflect.Method.invokeNative(Native Method)
03-22 14:04:15.926: E/AndroidRuntime(14824):    at java.lang.reflect.Method.invoke(Method.java:515)
03-22 14:04:15.926: E/AndroidRuntime(14824):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
03-22 14:04:15.926: E/AndroidRuntime(14824):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
03-22 14:04:15.926: E/AndroidRuntime(14824):    at dalvik.system.NativeStart.main(Native Method)
03-22 14:04:15.926: E/AndroidRuntime(14824): Caused by: java.security.NoSuchAlgorithmException: KeyManagerFactory SunX509 implementation not found
03-22 14:04:15.926: E/AndroidRuntime(14824):    at org.apache.harmony.security.fortress.Engine.notFound(Engine.java:177)
03-22 14:04:15.926: E/AndroidRuntime(14824):    at org.apache.harmony.security.fortress.Engine.getInstance(Engine.java:151)
03-22 14:04:15.926: E/AndroidRuntime(14824):    at javax.net.ssl.KeyManagerFactory.getInstance(KeyManagerFactory.java:77)
03-22 14:04:15.926: E/AndroidRuntime(14824):    at com.paypal.core.SSLUtil.<clinit>(SSLUtil.java:37)
03-22 14:04:15.926: E/AndroidRuntime(14824):    ... 21 more

1 个答案:

答案 0 :(得分:1)

看起来您正在尝试在Android上使用PayPal Java SDK。不幸的是,SDK从未设计用于Android,并且因为依赖于Sun SDK而失败。请参阅a similar issue here