Paypal服务没有启动(沙箱帐户),我得到低于错误

时间:2016-04-22 16:54:03

标签: android paypal paypal-sandbox android-multidex

我有一个名为样本活动的活动。从那个活动我开了一个意图, 这是navigationlayout1活动,它有一个paypal服务。应该添加Oncreate这个服务,就像他们(paypal)在他们的例子中完成的那样。 我之前没有使用multidex选项时,我没有遇到过这个问题。

我收到类似“退出值2”的错误,由于此错误,我的gradle无法完成。我已经做了一些研究来清除这个错误。

最后我的上一个错误(退出值2)被清除了。我很高兴因为现在没有错误。但出乎意料的是我得到了这个错误。过去3天我一直被误导。我一直在研究。这是在这里问问题而不再浪费我的时间的正确时间..请帮助我

 E/AndroidRuntime: FATAL EXCEPTION: main
                                                   java.lang.NoClassDefFoundError: okhttp3.internal.tls.OkHostnameVerifier
                                                       at okhttp3.OkHttpClient$Builder.<init>(OkHttpClient.java:364)
                                                       at com.paypal.android.sdk.cc.a(Unknown Source)
                                                       at com.paypal.android.sdk.cm.<init>(Unknown Source)
                                                       at com.paypal.android.sdk.payments.PayPalService.a(Unknown Source)
                                                       at com.paypal.android.sdk.payments.PayPalService.onStartCommand(Unknown Source)
                                                       at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2656)
                                                       at android.app.ActivityThread.access$1900(ActivityThread.java:141)
                                                       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1331)
                                                       at android.os.Handler.dispatchMessage(Handler.java:99)
                                                       at android.os.Looper.loop(Looper.java:137)
                                                       at android.app.ActivityThread.main(ActivityThread.java:5041)
                                                       at java.lang.reflect.Method.invokeNative(Native Method)
                                                       at java.lang.reflect.Method.invoke(Method.java:511)
                                                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
                                                       at dalvik.system.NativeStart.main(Native Method)

我的代码是

Intent intent = new Intent(getActivity(), NavigationLayout1.class);

   startActivity(intent);

此页面将被打开

NavigationLayout1.java

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageView;

import com.example.administrator.login.R;
import com.example.administrator.login.helper.ImageLoader;
import com.paypal.android.sdk.payments.PayPalConfiguration;
import com.paypal.android.sdk.payments.PayPalPayment;
import com.paypal.android.sdk.payments.PayPalService;
//import com.squareup.picasso.Picasso;


public class NavigationLayout1 extends AppCompatActivity {

    // private static final String TAG = "paymentdemoblog";
    /**
     * - Set to PaymentActivity.ENVIRONMENT_PRODUCTION to move real money.
     *
     * - Set to PaymentActivity.ENVIRONMENT_SANDBOX to use your test credentials
     * from https://developer.paypal.com
     *
     * - Set to PayPalConfiguration.ENVIRONMENT_NO_NETWORK to kick the tires
     * without communicating to PayPal's servers.
     */
    // private static final String CONFIG_ENVIRONMENT =
    // PayPalConfiguration.ENVIRONMENT_NO_NETWORK;
    private static final String CONFIG_ENVIRONMENT = PayPalConfiguration.ENVIRONMENT_SANDBOX;

    // note that these credentials will differ between live & sandbox
    // environments.
    private static final String CONFIG_CLIENT_ID = "Af3H9MCGkS0bGBEdj_KFIeZU6uip0RK0hLEONpOxo73KYpboXEsAiib6kwUXfM2n-W3wr9b2bQ_JRKhB";

    private static final int REQUEST_CODE_PAYMENT = 1;
    private static final int REQUEST_CODE_FUTURE_PAYMENT = 2;

    private static PayPalConfiguration config = new PayPalConfiguration()
            .environment(CONFIG_ENVIRONMENT)
            .clientId(CONFIG_CLIENT_ID)
                    // The following are only used in PayPalFuturePaymentActivity.
            .merchantName("Hipster Store")
            .merchantPrivacyPolicyUri(
                    Uri.parse("https://www.example.com/privacy"))
            .merchantUserAgreementUri(
                    Uri.parse("https://www.example.com/legal"));

    PayPalPayment thingToBuy;

    /****************************************************************Paypal*********************************/



    private String data;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.navigation_layout1);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        data=this.getIntent().getStringExtra("total");

        Intent intent = new Intent(this, PayPalService.class);
        intent.putExtra(PayPalService.EXTRA_PAYPAL_CONFIGURATION, config);
        startService(intent);

        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);

        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                        .setAction("Action", null).show();
            }
        });
    }



    @Override
    public boolean onOptionsItemSelected(MenuItem item)
    {

        super.onBackPressed();
        finish();
        return true;
    }

}

但我得到了上述错误。请帮助我

1 个答案:

答案 0 :(得分:0)

你可以添加这两个gradle文件 "com.paypal.sdk:paypal-android-sdk:2.14.2"

compile 'com.squareup.okhttp3:okhttp:3.3.1'
compile 'com.squareup.okio:okio:1.8.0'

或者,您可以下载OkHttp.jarOkio.jar,并将它们放在您的libs文件夹下。