Open rafiul587 opened 2 years ago
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:
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):
Additional context Add any other context about the problem here.
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
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.(PaymentButtonContainer.kt:174) at com.paypal.checkout.paymentbutton.PaymentButtonContainer.(PaymentButtonContainer.kt:63) at com.paypal.checkout.paymentbutton.PaymentButtonContainer.(PaymentButtonContainer.kt:-1) at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(NativeConstructorAccessorImpl.java:-2) at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)