Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Layout and Inflate Errors #418

Open
sawyermade opened this issue Apr 30, 2023 · 12 comments
Open

Layout and Inflate Errors #418

sawyermade opened this issue Apr 30, 2023 · 12 comments

Comments

@sawyermade
Copy link

Braintree SDK Version

6.9.0

Environment

Sandbox

Android Version & Device

Samsung S21 Ultra - Android 12

Braintree dependencies

implementation 'com.braintreepayments.api:drop-in:6.9.0'

Describe the bug

Once the drop in loads, the PayPal works fine and I can get the nonce but when clicking Credit or Debit Card it immediately crashes. This is the error I get:

FATAL EXCEPTION: main
Process: com.sjursolutions.videoinspectionprodev, PID: 8250
android.view.InflateException: Binary XML file line #32 in com.sjursolutions.videoinspectionprodev:layout/bt_fragment_add_card: Binary XML file line #32 in com.sjursolutions.videoinspectionprodev:layout/bt_fragment_add_card: Error inflating class com.braintreepayments.cardform.view.CardForm
Caused by: android.view.InflateException: Binary XML file line #32 in com.sjursolutions.videoinspectionprodev:layout/bt_fragment_add_card: Error inflating class com.braintreepayments.cardform.view.CardForm
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
at android.view.LayoutInflater.createView(LayoutInflater.java:858)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1010)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:965)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:1127)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1088)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:1130)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1088)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:1130)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1088)
at android.view.LayoutInflater.inflate(LayoutInflater.java:686)
at android.view.LayoutInflater.inflate(LayoutInflater.java:538)
at com.braintreepayments.api.AddCardFragment.onCreateView(AddCardFragment.java:50)
at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2995)
at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:523)
at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:261)
at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1840)
at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1758)
at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1701)
at androidx.fragment.app.FragmentManager$4.run(FragmentManager.java:488)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at android.app.ActivityThread.main(ActivityThread.java:8582)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:563)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1133)
Caused by: android.view.InflateException: Binary XML file line #9 in com.sjursolutions.videoinspectionprodev:layout/bt_card_form_fields: Binary XML file line #9: You must supply a layout_width attribute.
Caused by: java.lang.UnsupportedOperationException: Binary XML file line #9: You must supply a layout_width attribute.
at android.content.res.TypedArray.getLayoutDimension(TypedArray.java:831)
at android.view.ViewGroup$LayoutParams.setBaseAttributes(ViewGroup.java:9230)
at android.view.ViewGroup$MarginLayoutParams.(ViewGroup.java:9428)
at android.widget.LinearLayout$LayoutParams.(LinearLayout.java:2023)
at android.widget.LinearLayout.generateLayoutParams(LinearLayout.java:1917)
at android.widget.LinearLayout.generateLayoutParams(LinearLayout.java:89)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:1129)
at android.view.LayoutInflater.inflate(LayoutInflater.java:660)
at android.view.LayoutInflater.inflate(LayoutInflater.java:538)
at android.view.LayoutInflater.inflate(LayoutInflater.java:485)
at android.view.View.inflate(View.java:28455)
at com.braintreepayments.cardform.view.CardForm.init(CardForm.java:125)
at com.braintreepayments.cardform.view.CardForm.(CardForm.java:107)
at java.lang.reflect.Constructor.newInstance0(Native Method)

To reproduce

Tap Credit or Debit Card and it crashes

Expected behavior

Should load the credit or debit card form

Screenshots

No response

@sshropshire
Copy link
Contributor

Hi @sawyermade thanks for using the Braintree SDK for Android. I'm trying to reproduce this error but I'm having trouble on a Pixel 6 Pro and a Galaxy S21 5G. Using the same steps to reproduce, does this same crash occur on another device / emulator?

@sawyermade
Copy link
Author

No I haven't, I can try that though. Quick question though, why would the PayPal load just fine but the CC doesn't? Isn't that kind of strange? I did start a brand new app with only the drop in and it worked fine. The Gradle was setup the same as well. It's just strange that only CC does it? But yeah, I will check with other devices later, I wasn't sure if this was a known problem with a quick workaround, thanks for the response and I will get back to you once I try it on something else.

@sshropshire
Copy link
Contributor

@sawyermade awesome thanks! For the PayPal flow we use a Chrome custom tab, so there isn't as much View inflation happening in that flow. Our DropIn library depends on another library we maintain called android-card-form and CardForm is a custom view. I checked those xml files and the width attributes are definitely set.

We haven't seen any issues with android-card-form lately, but we'll keep an eye out. If you have additional information, feel free to reach out and we'll take a look.

@sawyermade
Copy link
Author

@sshropshire I'll have some different devices later this afternoon but in the meantime, here's the activity that calls the drop in (I removed all the misc buttons and text that don't matter) but is there anything you can see from the layout that would cause that error? I don't know the card form as well, it may be something stupid from the calling activity layout I overlooked. Thanks again and let me know if anything stands out I should add/remove and will let you know when I try on another device. The btnPaymentSave launches the drop in...

<?xml version="1.0" encoding="utf-8"?>

<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/grayBackground">

    <androidx.constraintlayout.widget.ConstraintLayout 
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        tools:context=".PaymentActivity">

    <Button
        android:id="@+id/btnPaymentSave"
        android:layout_width="300dp"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:layout_marginTop="40dp"
        android:layout_marginEnd="8dp"
        android:background="@drawable/rounded_button_green"
        android:backgroundTint="@color/clrDarkTerraCotta"
        android:text="@string/btnPaymentSave"
        android:textAllCaps="false"
        android:textColor="#FFFFFF"
        android:textSize="16sp"
        android:textStyle="normal"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.494"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/lblPaymentCCN" />

    </androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>

@sshropshire
Copy link
Contributor

@sawyermade nothing stands out as out of place. Technically your layout shouldn't affect the presentation of DropIn since it's contained in its own Activity and has its own view. I'd try it on another device or emulator just to make sure.

@sawyermade
Copy link
Author

sawyermade commented May 9, 2023

@sshropshire So I tried on an LG with android v9 and still get the same identical error. Min api is v24 and target is v33. Could the min be a problem? Oh and I also tried to implement just card form and got the same error as well.

@sawyermade
Copy link
Author

sawyermade commented May 9, 2023

@sshropshire Okay, did a little more digging and from the card form jar there's filename AddCardFragment.java with an error on line 50 it says "Cannot resolve symbol R": View view = inflater.inflate(R.layout.bt_fragment_add_card, container, false);

That's kind of weird right, like what would cause it not to be able to resolve R (as it's used in basically every activity in our program)? Have you guys ever seen this error before?

@sshropshire
Copy link
Contributor

@sawyermade interesting I can't say that I have. We have an import statement in AddCardFragment.java that references the R class generated by the DropIn library.

Out of curiosity if you repeat the steps to reproduce on an emulator, does it work as expected?

@sawyermade
Copy link
Author

sawyermade commented May 10, 2023

@sshropshire I will test it out, but yeah that import was "R" method and it was red. In the import, only the R is red in android studio (Cannot resolve symbol R): import com.braintreepayments.api.dropin.R; Its really weird but yeah, I will try it on the emulator tmr and get back to you. Thanks for the help!

Image_0:

Image_1:

@sawyermade
Copy link
Author

sawyermade commented May 10, 2023

@sshropshire Yeah, same thing. I also had my coworker run it off his windows PC (im on Mac and linux) with his v9 android and same stuff. Super weird the R isn't resolved, right?

@sshropshire
Copy link
Contributor

@sawyermade are y'all using proguard in your project? And to confirm it's the same behavior when using an emulator?

@sawyermade
Copy link
Author

sawyermade commented May 13, 2023

@sshropshire We are using proguard, which version emulator should I try using? I believe I was using an older v9 android emulator I used before. Here is the proguard in the Gradle app section in the android {}:

buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants