Error inflating class com.paypal.checkout.paymentbutton.PaymentButtonContainer

Issue

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

Solution

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

Answered By – Rishabh Garg

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published