Application screen becomes black and freezes when

2019-08-14 01:51发布

问题:

I'm developing an application that uses the new Paypal-Android integration SDK. The application has a donation button that donates the money for an organization that supports/protects the Human Rights (No app features are added upon donating).

I followed the guidelines/example given by Paypal on Github but I'm facing a problem. My application's screen turns black and just freezes until I get a "Application Not Responding" and the app crashes. After some debugging it appeared that the problem happens right when I start the PayPal service. Below are the major snapshots of my code, any help would be appreciated.

Note: I tried using it in all environments, (No Network, Sandbox and Production) with the Test and Production Paypal accounts, but it constantly gives the same error.

Thaks in advance.

Donation Activity:

private static final String CONFIG_ENVIRONMENT = PayPalConfiguration.ENVIRONMENT_SANDBOX;
private static final String MERCHANT_NAME = "*****";
private static final String RECEIVER_CLIENT_ID = "*****";
private static PayPalConfiguration config = new PayPalConfiguration().environment(CONFIG_ENVIRONMENT)
                                                                     .clientId(RECEIVER_CLIENT_ID)
                                                                     .merchantName(MERCHANT_NAME);

// Paypal service intent
private Intent paypalServiceIntent;

// onCreate
@Override
protected void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_donation_layout);

    // Init Params
    initParams();
}

// initParams
private void initParams()
{
    // Initialize the service
    paypalServiceIntent = new Intent(this, PayPalService.class);

    // Star the Paypal service
    paypalServiceIntent.putExtra(PayPalService.EXTRA_PAYPAL_CONFIGURATION, config);
    startService(paypalServiceIntent);
}

Manifest:

<!-- Paypal Activities/Services -->
<activity android:name="com.paypal.android.sdk.payments.PaymentActivity" />
<activity android:name="com.paypal.android.sdk.payments.LoginActivity" />
<activity android:name="com.paypal.android.sdk.payments.PaymentMethodActivity" />
<activity android:name="com.paypal.android.sdk.payments.PaymentConfirmActivity" />
<service
        android:name="com.paypal.android.sdk.payments.PayPalService"
        android:exported="false" />

回答1:

Just came across the same problem, seems like the new PayPal SDK has some bug. I've posted there the info I've got from the ANR stack trace.

You can follow the bug here: https://github.com/paypal/PayPal-Android-SDK/issues/83

Meanwhile I suggest revert back to an older version of the PayPal SDK. [2.2.0]