braintree / braintree-android-drop-in

Braintree Drop-In SDK for Android
https://developers.braintreepayments.com/guides/drop-in/android/v2
MIT License
124 stars 79 forks source link

NoSuchMethodError: No static method isTokenizationKey #396

Closed kevinstotz closed 1 year ago

kevinstotz commented 1 year ago

Integration Details (please complete the following information):

Describe the bug I have an andoid app in AndroidStudio. The emulator is a Galaxy S9 Plus Api 31. The dropin appears as expected. I choose the "Credit card" option from the 3 options available (Google pay, credit card, paypal) The card number 4111111111111111 is entered and once I click next, this error is thrown.

java.lang.NoSuchMethodError: No static method isTokenizationKey(Ljava/lang/String;)Z in class Lcom/braintreepayments/api/Authorization; or its super classes (declaration of 'com.braintreepayments.api.Authorization' appears in /data/app/com.example.xxxx-cCI1Genjm0f-UgyWcin6tw==/base.apk!classes17.dex) E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.snoozeforacause, PID: 9330 java.lang.NoSuchMethodError: No static method isTokenizationKey(Ljava/lang/String;)Z in class Lcom/braintreepayments/api/Authorization; or its super classes (declaration of 'com.braintreepayments.api.Authorization' appears in /data/app/com.example.snoozeforacause-cCI1Genjm0f-UgyWcin6tw==/base.apk!classes17.dex) at com.braintreepayments.api.DropInActivity.lambda$showCardDetailsFragment$6$com-braintreepayments-api-DropInActivity(DropInActivity.java:353) at com.braintreepayments.api.DropInActivity$$ExternalSyntheticLambda8.onResult(Unknown Source:6) at com.braintreepayments.api.BraintreeClient$1$1.onResult(BraintreeClient.java:184) at com.braintreepayments.api.ConfigurationLoader.loadConfiguration(ConfigurationLoader.java:50) at com.braintreepayments.api.BraintreeClient$1.onAuthorizationResult(BraintreeClient.java:179) at com.braintreepayments.api.AuthorizationLoader.loadAuthorization(AuthorizationLoader.java:20) at com.braintreepayments.api.BraintreeClient.getAuthorization(BraintreeClient.java:206) at com.braintreepayments.api.BraintreeClient.getConfiguration(BraintreeClient.java:175) at com.braintreepayments.api.DropInInternalClient.getConfiguration(DropInInternalClient.java:83) at com.braintreepayments.api.DropInActivity.lambda$showCardDetailsFragment$7$com-braintreepayments-api-DropInActivity(DropInActivity.java:350) at com.braintreepayments.api.DropInActivity$$ExternalSyntheticLambda1.onAuthorizationResult(Unknown Source:4) at com.braintreepayments.api.AuthorizationLoader.loadAuthorization(AuthorizationLoader.java:20) at com.braintreepayments.api.BraintreeClient.getAuthorization(BraintreeClient.java:206) at com.braintreepayments.api.DropInInternalClient.getAuthorization(DropInInternalClient.java:79) at com.braintreepayments.api.DropInActivity.showCardDetailsFragment(DropInActivity.java:348) at com.braintreepayments.api.DropInActivity.onAddCardSubmit(DropInActivity.java:314) at com.braintreepayments.api.DropInActivity.onDropInEvent(DropInActivity.java:131) at com.braintreepayments.api.DropInActivity.lambda$onCreate$0$com-braintreepayments-api-DropInActivity(DropInActivity.java:88) at com.braintreepayments.api.DropInActivity$$ExternalSyntheticLambda9.onFragmentResult(Unknown Source:2) at androidx.fragment.app.FragmentManager$LifecycleAwareResultListener.onFragmentResult(FragmentManager.java:249) at androidx.fragment.app.FragmentManager.setFragmentResult(FragmentManager.java:916) at com.braintreepayments.api.DropInFragment.sendDropInEvent(DropInFragment.java:9) at com.braintreepayments.api.AddCardFragment.onCardFormSubmit(AddCardFragment.java:151) at com.braintreepayments.api.AddCardFragment.lambda$onCreateView$0$com-braintreepayments-api-AddCardFragment(AddCardFragment.java:56) at com.braintreepayments.api.AddCardFragment$$ExternalSyntheticLambda0.onClick(Unknown Source:2) at com.braintreepayments.api.AnimatedButtonView.onClick(AnimatedButtonView.java:55) at android.view.View.performClick(View.java:7125) at android.view.View.performClickInternal(View.java:7102) at android.view.View.access$3500(View.java:801) at android.view.View$PerformClick.run(View.java:27336) at android.os.Handler.handleCallback(Handler.java:883) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loop(Looper.java:214) at android.app.ActivityThread.main(ActivityThread.java:7356) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930) To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. See error

Expected behavior Expected behavior is the month/year screen should display

Screenshots @AndroidEntryPoint class MainActivity : AppCompatActivity(), DropInListener, VenmoListener { @Inject lateinit var commonRepository: CommonRepository private lateinit var mCoroutineScope: CoroutineScope lateinit var dropInClient: DropInClient lateinit var braintreeClient: BraintreeClient lateinit var dataCollector: DataCollector lateinit var cardClient: CardClient private var venmoClient: VenmoClient? = null

companion object { lateinit var INSTANCE: MainActivity private set }

init { INSTANCE = this@MainActivity }

override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState)

dropInClient = DropInClient(this@MainActivity, ExampleClientTokenProvider())
dropInClient.setListener(this@MainActivity)

setContent {
  val navController = rememberNavController()

  SnoozeForGoodTheme(false) {

    NavHost(
        navController = navController, startDestination = SplashDirections.root.destination) {
          composable(route = SplashDirections.root.destination) {
            Log.d("TAG2", "going splash page")
            SplashContentFactory().Content(navController)
     }
  }
}

}

fun loadDropIn2() { val dropInRequest = DropInRequest() dropInRequest.maskCardNumber = true Log.d("TAG2", "launch dropin") dropInClient.launchDropIn(dropInRequest) Log.d("TAG2", "launched dropin") }

override fun onDropInSuccess(dropInResult: DropInResult) { Log.d("TAG2", "dropIn success") val paymentMethodNonce = dropInResult.paymentMethodNonce?.string Log.d("TAG2", "payment Method Nonce : $paymentMethodNonce") // use the result to upapdate your UI and send the payment method nonce to your server }

override fun onDropInFailure(error: Exception) { if (error is UserCanceledException) { Log.d("TAG2", "dropin user cancelled : ${error.message}") } else { Log.d("TAG2", "dropin failure : ${error.message}") Log.d("TAG2", "dropin failure : ${error.localizedMessage}") Log.d("TAG2", "dropin failure : ${error.cause}") } }

override fun onVenmoSuccess(venmoAccountNonce: VenmoAccountNonce) { Log.d("TAG2", "venmo success") }

override fun onVenmoFailure(error: java.lang.Exception) { Log.d("TAG2", "venmo failure") }

}

============ then from inside the ViewModel override fun handleTransactionsEvent(event: TransactionsEvent) { _uiState.value = uiState.value.build { when (event) { is TransactionsEvent.PaymentButtonClicked -> { Log.d("TAG2", "Payment button clicked") val dropInRequest = DropInRequest() dropInRequest.maskCardNumber = true MainActivity.INSTANCE.dropInClient.launchDropIn(dropInRequest) } } } Screenshot_20230208_151227 Screenshot_20230208_151245

}
sshropshire commented 1 year ago

Hi @kevinstotz thanks for using the Braintree SDK for Android. We haven't updated the internal dependency version for DropIn yet, we'll create a PR for this soon. In the meantime, version 4.23.1 of the Braintree core SDK should work fine with DropIn.

kevinstotz commented 1 year ago

works great on 4.23.1

Thanks!!!!