android-checkout-sdk
android-checkout-sdk copied to clipboard
The new PaymentButtonContainer button is invisible in the android studio preview
I tried to copy and use the PaymentButtonContainer from the official document like the one below. But it doesn't show anything in the android studio preview. I got the error message from the android studio preview. Version: Android Studio Dolphin | 2021.3.1
<com.paypal.checkout.paymentbutton.PaymentButtonContainer
android:id="@+id/payment_button_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:paypal_button_color="silver"
app:paypal_button_label="pay"
app:paypal_button_shape="rectangle"
app:paypal_button_size="large"
app:paypal_button_enabled="true" />
Error from the android studio preview window
The following classes could not be instantiated:
- com.paypal.checkout.paymentbutton.PaymentButtonContainer (Open Class, Show Exception, Clear Cache)
Tip: Use View.isInEditMode() in your custom views to skip code or show sample data when shown in the IDE. If this is an unexpected error you can also try to build the project, then manually refresh the layout. Exception Details java.lang.IllegalStateException: Required value was null. at com.paypal.pyplcheckout.di.SdkComponent$Companion.getInstance(SdkComponent.kt:129) at com.paypal.checkout.paymentbutton.PaymentButtonContainer.
You need to initialize the checkout config 1st in your application class.
It's already there. Can hilt cause the problem somehow?
`@HiltAndroidApp class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
val config = CheckoutConfig(
application = this,
clientId = "Client id here",
environment = Environment.SANDBOX,
currencyCode = CurrencyCode.USD,
userAction = UserAction.PAY_NOW,
settingsConfig = SettingsConfig(
loggingEnabled = true,
)
)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
PayPalCheckout.setConfig(config)
} else {
Toast.makeText(this, "Checkout SDK only available for API 23+", Toast.LENGTH_SHORT).show()
}
}`
It shouldn't be. Could you please fill out the following information so it's easier for me to reproduce the issue and figure out what went wrong on the client side?
Before you create a new issue, please search for similar issues. It's possible somebody has encountered this bug already. PLEASE REMOVE THIS LINE TO ACKNOWLEDGE THAT AN ISSUE DOESN'T ALREADY EXIST FOR THIS BUG
Describe the bug A clear and concise description of what the bug is.
To Reproduce Steps to reproduce the behavior:
- Go to '...'
- Click on '....'
- Scroll down to '....'
- See error
Expected behavior A clear and concise description of what you expected to happen.
Screenshots If applicable, add screenshots to help explain your problem.
Smartphone (please complete the following information):
- Android Version: [e.g. API 30]
- Device: [e.g. Emulator or One Plus 9]
- Browser [e.g. chrome, safari] <- only applicable for app switches or fallback situations
- SDK Version [e.g. 0.1.0]
- Package name of your app [e.g. com.example.my_app]
- Client ID
Additional context Add any other context about the problem here.