I have an activity named sample activity.From that activity i opened an intent, that was navigationlayout1 activity, which had a paypal service. Oncreate this service should be added like they(paypal) done in their example. I have not had this problem before when i was using no multidex option.
I got an error like "exit value 2", my gradle couldn't completed due to this error. I have done some research on it to clear this error off.
Finally my previous error(exit value 2) got cleared. I was happy because now there is no error. But unexpectedly i got this error. I have been stucked with error for the past 3 days. I have been researching all the time. This is the right time to ask over here without wasting my time any more ..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_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;
}
}
But i am getting the above error.Please help me