jonasbark / flutter_stripe_payment

[DISCONTINUED] A flutter plugin with stripe payment plugin integration
MIT License
309 stars 244 forks source link

No static method fromString(Ljava/lang/String;)Lcom/stripe/android/model/Token #257

Closed petroniuchacz closed 3 years ago

petroniuchacz commented 3 years ago

Hi, I'm trying to integrate stripe_payment into my app for native payments and my app is crashing. Android 10 API 29

`StripePayment.setOptions( StripeOptions( publishableKey: response.apiKey, merchantId: "Test", androidPayMode: 'test', ), );

final token = await StripePayment.paymentRequestWithNativePay(
  androidPayOptions: AndroidPayPaymentRequest(
    totalPrice: event.finalPrice.money.amountAsString,
    currencyCode: event.finalPrice.currency,
    lineItems: [
      LineItem(
        description: eventTitle,
      ),
    ],
  ),
  applePayOptions: ApplePayPaymentOptions(
    countryCode: 'DE',
    currencyCode: event.finalPrice.currency,
    items: [
      ApplePayItem(
        label: eventTitle,
        amount: event.finalPrice.amount.toString(),
      )
    ],
  ),
);

await StripePayment.completeNativePayRequest();`

D/AndroidRuntime(24292): Shutting down VM E/AndroidRuntime(24292): FATAL EXCEPTION: main E/AndroidRuntime(24292): Process: com.onwelo.tennisfy_flutter_user, PID: 24292 E/AndroidRuntime(24292): java.lang.NoSuchMethodError: No static method fromString(Ljava/lang/String;)Lcom/stripe/android/model/Token; in class Lcom/stripe/android/model/Token; or its super classes (declaration of 'com.stripe.android.model.Token' appears in /data/app/com.example.tennisfy_flutter_user-8di2gG05vqN0Yk2vrOa6fA==/base.apk!classes3.dex) E/AndroidRuntime(24292): at com.gettipsi.stripe.GoogleApiPayFlowImpl.onActivityResult(GoogleApiPayFlowImpl.java:233) E/AndroidRuntime(24292): at com.gettipsi.stripe.StripeModule$1.onActivityResult(StripeModule.java:73) E/AndroidRuntime(24292): at io.flutter.embedding.engine.FlutterEnginePluginRegistry$FlutterEngineActivityPluginBinding.onActivityResult(FlutterEnginePluginRegistry.java:691) E/AndroidRuntime(24292): at io.flutter.embedding.engine.FlutterEnginePluginRegistry.onActivityResult(FlutterEnginePluginRegistry.java:378) E/AndroidRuntime(24292): at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onActivityResult(FlutterActivityAndFragmentDelegate.java:625) E/AndroidRuntime(24292): at io.flutter.embedding.android.FlutterActivity.onActivityResult(FlutterActivity.java:583) E/AndroidRuntime(24292): at android.app.Activity.dispatchActivityResult(Activity.java:8110) E/AndroidRuntime(24292): at android.app.ActivityThread.deliverResults(ActivityThread.java:4838) E/AndroidRuntime(24292): at android.app.ActivityThread.handleSendResult(ActivityThread.java:4886) E/AndroidRuntime(24292): at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:51) E/AndroidRuntime(24292): at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) E/AndroidRuntime(24292): at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) E/AndroidRuntime(24292): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016) E/AndroidRuntime(24292): at android.os.Handler.dispatchMessage(Handler.java:107) E/AndroidRuntime(24292): at android.os.Looper.loop(Looper.java:214) E/AndroidRuntime(24292): at android.app.ActivityThread.main(ActivityThread.java:7356) E/AndroidRuntime(24292): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime(24292): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) E/AndroidRuntime(24292): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930) I/Process (24292): Sending signal. PID: 24292 SIG: 9

ritheshSalyan commented 3 years ago

@petroniuchacz Are You using two Stripe sdks? Do you have the following line in your build.gradle

implementation 'com.stripe:stripe-android:14.5.0'

if yes remove that line. That Solved the issue for me.

Solution from https://github.com/jonasbark/flutter_stripe_payment/issues/183#issuecomment-671709560

amswiatkowski commented 3 years ago

It's working when deleted implementation 'com.stripe:stripe-android:14.5.0'

petroniuchacz commented 3 years ago

The solution of ritheshSalyan works. Thanks!