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

Create token problem in Android #377

Closed
NarendraAmz opened this issue Oct 6, 2021 · 4 comments
Closed

Create token problem in Android #377

NarendraAmz opened this issue Oct 6, 2021 · 4 comments

Comments

@NarendraAmz
Copy link

Stripe initialization

Stripe.publishableKey = stripe_global_key;
Stripe.merchantIdentifier =
'merchant.flutter.stripe.test'; //"Test";//'merchant.flutter.stripe.test';
Stripe.urlScheme = 'flutterstripe';

Card adding

CardField(
autofocus: true,
onCardChanged: (card) {
setState(() {
_card = card;
});
},
),

Using token creation for the specific card

final tokenData = await Stripe.instance.createToken(
CreateTokenParams(type: TokenType.Card, address: address),
);

I got an exception in Android, But iOS is working fine.

PlatformException(flutter_stripe initialization failed, The plugin failed to initialize. Are you using FlutterFragmentActivity? Please check the README: https://github.com/flutter-stripe/flutter_stripe#android, null, null)

@jonasbark
Copy link
Member

Please post the full exception details from the log output.
Also, follow https://github.com/flutter-stripe/flutter_stripe#android closely.

@NarendraAmz
Copy link
Author

Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
I/flutter (20611): CardFieldInputDetails(complete: true, last4: 4242, expiryMonth: 12, expiryYear: 34, postalCode: 5677, brand: Visa, number: null, cvc: null)
I/flutter (20611): connected
E/flutter (20611): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: PlatformException(flutter_stripe initialization failed, The plugin failed to initialize. Are you using FlutterFragmentActivity? Please check the README: https://github.com/flutter-stripe/flutter_stripe#android, null, null)
E/flutter (20611): #0 JSONMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:155:7)
E/flutter (20611): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:156:18)
E/flutter (20611):
E/flutter (20611): #2 MethodChannel.invokeMapMethod (package:flutter/src/services/platform_channel.dart:356:43)
E/flutter (20611):
E/flutter (20611): #3 MethodChannelStripe.createToken (package:stripe_platform_interface/src/method_channel_stripe.dart:203:20)
E/flutter (20611):
E/flutter (20611): #4 Stripe.createToken (package:flutter_stripe/src/stripe.dart:166:25)
E/flutter (20611):
E/flutter (20611): #5 AddCreditCardState.handleCreateTokenPress (package:evoke/Screens/PaymentMethod/addCreditCard.dart:407:25)
E/flutter (20611):
E/flutter (20611):
I/Counters(20611): exceeded sample count in FrameTime

@jonasbark
Copy link
Member

This error has been reported often and it was always a configuration issue. Double-check the readme and follow its instructions on Android 👍

@NarendraAmz
Copy link
Author

NarendraAmz commented Oct 7, 2021

Still, we are facing the same problem

Yes I have same error in example app also

Flutter version 2.5.1

manifest :






    <meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="apikey"/>
    <activity
        android:name="io.flutter.embedding.android.FlutterFragmentActivity"
        android:launchMode="singleTop"
        android:theme="@style/LaunchTheme"
        android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
        android:hardwareAccelerated="true"
        android:windowSoftInputMode="adjustResize"
        android:screenOrientation="portrait">
        <!-- This keeps the window background of the activity showing
             until Flutter renders its first frame. It can be removed if
             there is no splash screen (such as the default splash screen
             defined in @style/LaunchTheme). -->
        <meta-data android:name="com.facebook.sdk.ApplicationId"
            android:value="35661314433"/>
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
        <intent-filter>
            <action android:name="FLUTTER_NOTIFICATION_CLICK" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data
                android:scheme="https"
                android:host="google.com" />

        </intent-filter>
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    </activity>
</application>

Please help me with this

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