Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

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

未關閉
#1,708 2 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
25/100
Issue 類型
缺陷
描述清晰度
需要釐清
活躍度
停滯
技術堆疊
android, java
領域
mobile-dev

研究方向

從外掛程式的 include.gradle 和 issue 中所示的 Stripe.confirmSetupIntent 呼叫開始。使用列出的 NativeScript 和 Stripe 版本重現該呼叫,然後將執行時期的方法簽章與失敗的呼叫進行比較。當執行個體方法可以在不出現 NoSuchMethodError 的情況下呼叫,且無效 ID 能夠到達預期的 API 錯誤時,即表示完成。

由索引模型根據 Issue 內容生成。

描述

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 https://github.com/triniwiz/nativescript-plugins/issues/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.

主要語言
C++
星號
563
分支
144
平均合併
10 小時 45 分鐘
30 天內合併 PR
11

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

NativeScript/android 的其他 Issue

查看 NativeScript/android 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。