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

"Error: java.lang.NoSuchMethodError: no static method" when calling a non-static method on an instance #1708

Open
sebj54 opened this issue Apr 4, 2022 · 2 comments

Comments

@sebj54
Copy link
Contributor

sebj54 commented Apr 4, 2022

Environment
Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):

✔ Component nativescript has 8.2.3 version and is up to date.
✔ Component @nativescript/core has 8.2.1 version and is up to date.
✔ Component @nativescript/ios has 8.2.3 version and is up to date.
✔ Component @nativescript/android has 8.2.2 version and is up to date.

Describe the bug

This problem happens with the @triniwiz/nativescript-stripe module (see triniwiz/nativescript-plugins#110).

When calling this method:

this.stripe.confirmSetupIntent(activity, new StripeSetupIntentParams(paymentMethodId, clientSecret).native);

This error is thrown:

Error: java.lang.NoSuchMethodError: no static method "Lcom/stripe/android/Stripe;.confirmSetupIntent(Landroidx/activity/ComponentActivity;Lcom/stripe/android/model/ConfirmSetupIntentParams;)V"

I used java.util.Arrays.toString(this.stripe.getClass().getMethods())) to get this method's signature:

public final void com.stripe.android.Stripe.confirmSetupIntent(androidx.activity.ComponentActivity,com.stripe.android.model.ConfirmSetupIntentParams)

It looks totally the same (to me). There are also methods with the same name:

public final void com.stripe.android.Stripe.confirmSetupIntent(androidx.fragment.app.Fragment,com.stripe.android.model.ConfirmSetupIntentParams)

public final void com.stripe.android.Stripe.confirmSetupIntent(androidx.activity.ComponentActivity,com.stripe.android.model.ConfirmSetupIntentParams,java.lang.String)

public final void com.stripe.android.Stripe.confirmSetupIntent(androidx.fragment.app.Fragment,com.stripe.android.model.ConfirmSetupIntentParams,java.lang.String)

public static void com.stripe.android.Stripe.confirmSetupIntent$default(com.stripe.android.Stripe,androidx.activity.ComponentActivity,com.stripe.android.model.ConfirmSetupIntentParams,java.lang.String,int,java.lang.Object)

public static void com.stripe.android.Stripe.confirmSetupIntent$default(com.stripe.android.Stripe,androidx.fragment.app.Fragment,com.stripe.android.model.ConfirmSetupIntentParams,java.lang.String,int,java.lang.Object)

public final com.stripe.android.model.SetupIntent com.stripe.android.Stripe.confirmSetupIntentSynchronous(com.stripe.android.model.ConfirmSetupIntentParams) throws com.stripe.android.exception.AuthenticationException,com.stripe.android.core.exception.InvalidRequestException,com.stripe.android.core.exception.APIConnectionException,com.stripe.android.core.exception.APIException

public final com.stripe.android.model.SetupIntent com.stripe.android.Stripe.confirmSetupIntentSynchronous(com.stripe.android.model.ConfirmSetupIntentParams,java.lang.String) throws com.stripe.android.exception.AuthenticationException,com.stripe.android.core.exception.InvalidRequestException,com.stripe.android.core.exception.APIConnectionException,com.stripe.android.core.exception.APIException

public static com.stripe.android.model.SetupIntent com.stripe.android.Stripe.confirmSetupIntentSynchronous$default(com.stripe.android.Stripe,com.stripe.android.model.ConfirmSetupIntentParams,java.lang.String,int,java.lang.Object) throws com.stripe.android.exception.AuthenticationException,com.stripe.android.core.exception.InvalidRequestException,com.stripe.android.core.exception.APIConnectionException,com.stripe.android.core.exception.APIException

To Reproduce

Here is the include.gradle file of this plugin:

android {
    defaultConfig {
      minSdkVersion 21
    }
  packagingOptions {
    pickFirst 'META-INF/stripe_release.kotlin_module'
  }
}
dependencies {
  implementation('com.stripe:stripe-android:19.0.0'){
    transitive = true
  }
  implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.2'
  implementation "androidx.lifecycle:lifecycle-livedata:2.2.0"
  implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"
}

Maybe adding the plugin to a new project is enough (I can provide a sample project if you think this issue belongs here). Then call:

const publishableKey = 'pk_test_xxxxxxxxxxxxxxxxxxxxxxxx'
const stripe = new Stripe(publishableKey)
stripe.confirmSetupIntent('pm_xxxxxxxxxxxxxxxxxxxxxxxx', 'secret_xxxxxxxxxxxxxxxxxxxxxxxx')e

I don't know if it will work with these fake IDs, but I think it should return an API error if the method gets called.

Let me know if you need extra information.

@triniwiz
Copy link
Member

This signature public final void com.stripe.android.Stripe.confirmSetupIntent(androidx.activity.ComponentActivity,com.stripe.android.model.ConfirmSetupIntentParams,java.lang.String) requires 3 but you passed 2 that’s why the error said it doesn’t have a signature like this Error: java.lang.NoSuchMethodError: no static method "Lcom/stripe/android/Stripe;.confirmSetupIntent(Landroidx/activity/ComponentActivity;Lcom/stripe/android/model/ConfirmSetupIntentParams;)V" you’re missing a string

@sebj54
Copy link
Contributor Author

sebj54 commented Sep 29, 2022

Thank you, I'll give it another try soon. I'll let you know in this issue.

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