Home > Mobile >  Error inflating class com.paypal.checkout.paymentbutton.PaymentButtonContainer
Error inflating class com.paypal.checkout.paymentbutton.PaymentButtonContainer

Time:09-08

Here is my xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".ui.payment.PaymentPayPal">

    <com.paypal.checkout.paymentbutton.PaymentButtonContainer
        android:id="@ id/paymentButtonContainer"
        android:layout_width="match_parent"
        android:layout_height="@dimen/_50dp"
        android:layout_margin="@dimen/_30dp"
        app:layout_constraintTop_toTopOf="parent"/>

</LinearLayout>

My activity class:

class PaymentPayPal : BaseActivity() {

    private val YOUR_CLIENT_ID: String = ""

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_payment_pay_pal)
    }
}

also tried binding nothing happens

build.gradle(app)

  1. minSdk=21
  2. dependencies { implementation 'com.paypal.checkout:android-sdk:0.8.1' }

Error message: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.voterswik/com.voterswik.ui.payment.PaymentPayPal}: android.view.InflateException: Binary XML file line #9 in com.voterswik:layout/activity_payment_pay_pal: Binary XML file line #9 in com.voterswik:layout/activity_payment_pay_pal: Error inflating class com.paypal.checkout.paymentbutton.PaymentButtonContainer

CodePudding user response:

You cannot use constraints in a LinearLayout.

app:layout_constraintTop_toTopOf="parent"

If you remove that line you will be able to run your app.

CodePudding user response:

First, this error is due to non-reachable class PaymentButtonContainer

This is because it should build a config before its use, so go to paypal docs https://developer.paypal.com/limited-release/paypal-mobile-checkout/android/

and check whether implemented correctly, is you "implement configuration on a subclass of Application()" which will call at very start of project. To set the configuration

  • Related