Android – PayPal service is not started (sandbox account), I get an error
I have an activity called sample activity. I have an intention from that activity. This is the navigationlayout1 activity, which has a PayPal service. Oncreate service should be added, just as they did in their example. I didn't encounter this problem when I didn't use the multidex option before
I received an error such as "exit value 2". Due to this error, my gradle cannot be completed. I have done some research to clear this error
Finally, my last error (exit value 2) was cleared. I'm glad because there is no error now. But unexpectedly, I got this error. I've been misled for the past three days. I've been studying. This is the right time to ask questions here without wasting time.. please help me
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)
My code is
Intent intent = new Intent(getActivity(), NavigationLayout1.class);
startActivity(intent);
This page will be opened
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_SAND@R_71_2419@ 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_SAND@R_71_2419@;
// note that these credentials will differ between live & sand@R_71_2419@
// environments.
private static final String CONfig_CLIENT_ID = "Af3H9MCGkS0bGBEdj_KFIeZU6uip0RK0hLEONpOxo73KYp@R_71_2419@EsAiib6kwUXfM2n-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;
}
}
But I got the above error. Please help me
resolvent:
You can add these two gradle files "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'
Alternatively, you can download okhttp.jar and okio.jar and put them in your LIBS folder