Skip to content

CardField not showing and throwing exception on flutter_stripe 2.1.0, flutter 2.8.1 #534

Closed
@aris-1

Description

@aris-1

Same as #393, but since that is closed and not getting any reply, I opened a new one.

Applied all the requirements at https://github.com/flutter-stripe/flutter_stripe#android, but still not working.
Tried calling applySettings as suggested by jonasbark on above mentioned issue, but that also gives an error.

Using:
flutter_stripe: ^2.1.0
Flutter 2.8.1
ext.kotlin_version = '1.5.0'

Code:

import 'package:flutter_stripe/flutter_stripe.dart';
Stripe.publishableKey = "xxxxxx";
final stripeCardController = CardEditController();

Container(child: CardField(
controller: stripeCardController,
onCardChanged: (card) {
print("onCardChanged1 $card");
},
));

Checked requirements:

  • Android 5.0 (API level 21) and above
    minSdkVersion 21

  • Kotlin version 1.5.0 and above:
    ext.kotlin_version = '1.5.0'

  • Using a descendant of Theme.AppCompat for your activity
    in values/styles.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
        <!-- Show a splash screen on the activity. Automatically removed when
             Flutter draws its first frame -->
        <item name="android:windowBackground">@drawable/launch_background</item>
    </style>
    <style name="NormalTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="android:windowBackground">?android:colorBackground</item>
    </style>
</resources>
  • Using an up-to-date Android gradle build tools version:
  dependencies {
       classpath 'com.android.tools.build:gradle:4.1.2'  
       classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"  
    distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
  • Using FlutterFragmentActivity instead of FlutterActivity in MainActivity.kt:
  import io.flutter.embedding.android.FlutterActivity
  import io.flutter.embedding.android.FlutterFragmentActivity 
class MainActivity: FlutterFragmentActivity() { 
}

Error report:

E/MethodChannel#flutter/platform_views(14280): Failed to handle method call
E/MethodChannel#flutter/platform_views(14280): kotlin.UninitializedPropertyAccessException: lateinit property stripeSdk has not been initialized
E/MethodChannel#flutter/platform_views(14280): at com.flutter.stripe.StripeAndroidPlugin.getStripeSdk(StripeAndroidPlugin.kt:28)
E/MethodChannel#flutter/platform_views(14280): at com.flutter.stripe.StripeAndroidPlugin$onAttachedToEngine$1.invoke(StripeAndroidPlugin.kt:51)
E/MethodChannel#flutter/platform_views(14280): at com.flutter.stripe.StripeAndroidPlugin$onAttachedToEngine$1.invoke(StripeAndroidPlugin.kt:51)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions