嘿,我正在尝试将 Paypal MPL API 集成到 android 中,但我遇到了很多麻烦......我已经完成了所有https://www.x.com/developers/paypal/how-to-guides/how-accept-payments -android-app-using-mpl步骤,但是当我运行我的项目时,出现此错误:
java.lang.NoClassDefFoundError: com.paypal.android.MEP.PayPalPayment
我已经在我的项目中集成了 mpl.jar 文件。
这是代码:
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void initLibrary() {
PayPal pp = PayPal.getInstance();
if (pp == null) {
pp = PayPal.initWithAppID(this, "APP-80W284485P519543T", PayPal.ENV_NONE);
pp.setLanguage("en_US");
pp.setFeesPayer(PayPal.FEEPAYER_EACHRECEIVER);
pp.setShippingEnabled(true);
}
}
private void showPayPalButton() {
PayPal pp = PayPal.getInstance();
final CheckoutButton launchPayPalButton;
launchPayPalButton = pp.getCheckoutButton(this, PayPal.BUTTON_278x43, CheckoutButton.TEXT_PAY);
launchPayPalButton.setOnClickListener((OnClickListener) this);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams (LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
params.bottomMargin = 10;
launchPayPalButton.setLayoutParams(params);
launchPayPalButton.setId(10);
((RelativeLayout) findViewById(R.id.rlayout)).addView(launchPayPalButton);
((RelativeLayout) findViewById(R.id.rlayout)).setGravity(Gravity.CENTER_HORIZONTAL);
}
public void PayPalButtonClick(View arg0) {
PayPalPayment payment = new PayPalPayment();
payment.setCurrencyType("USD");
payment.setRecipient("nons3nsedevelopment@gmail.com");
payment.setSubtotal(new BigDecimal(10));
payment.setPaymentType(PayPal.PAYMENT_TYPE_GOODS);
PayPalInvoiceData invoice = new PayPalInvoiceData();
invoice.setTax(new BigDecimal(5));
}
public void PayPalActivityResult(int requestCode, int resultCode, Intent intent) {
switch (resultCode) {
case Activity.RESULT_OK:
String payKey = intent.getStringExtra(PayPalActivity.EXTRA_PAY_KEY);
//this.paymentSucceeded(payKey);
break;
case Activity.RESULT_CANCELED:
//this.paymentCanceled();
break;
case PayPalActivity.RESULT_FAILURE:
String errorID = intent.getStringExtra(PayPalActivity.EXTRA_ERROR_ID);
String errorMessage = intent.getStringExtra(PayPalActivity.EXTRA_ERROR_MESSAGE);
//this.paymentFailed(errorID, errorMessage);
}
}
我在这里没有发现错误...