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

When layout cardformfield render second time on screen #1585

Closed
sachindamco opened this issue Jan 3, 2024 · 7 comments
Closed

When layout cardformfield render second time on screen #1585

sachindamco opened this issue Jan 3, 2024 · 7 comments
Labels
Android Issue related to Android native bindings Awaiting response Awaiting response from the issuer

Comments

@sachindamco
Copy link

[ERROR:flutter/fml/platform/android/jni_util.cc(206)] java.lang.IllegalStateException: The Android view returned from PlatformView#getView() was already added to a parent view.
E/flutter (14644): at io.flutter.plugin.platform.PlatformViewsController.initializePlatformViewIfNeeded(PlatformViewsController.java:1094)
E/flutter (14644): at io.flutter.plugin.platform.PlatformViewsController.onDisplayPlatformView(PlatformViewsController.java:1152)
E/flutter (14644): at io.flutter.embedding.engine.FlutterJNI.onDisplayPlatformView(FlutterJNI.java:1461)
E/flutter (14644): at android.os.MessageQueue.nativePollOnce(Native Method)
E/flutter (14644): at android.os.MessageQueue.next(MessageQueue.java:335)
E/flutter (14644): at android.os.Looper.loop(Looper.java:193)
E/flutter (14644): at android.app.ActivityThread.main(ActivityThread.java:8057)
E/flutter (14644): at java.lang.reflect.Method.invoke(Native Method)
E/flutter (14644): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:620)
E/flutter (14644): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1011)
E/flutter (14644):
F/flutter (14644): [FATAL:flutter/shell/platform/android/platform_view_android_jni_impl.cc(1694)] Check failed: fml::jni::CheckException(env).
F/libc (14644): Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 14644

@sachindamco sachindamco added the needs triage Needs triage label Jan 3, 2024
@sachindamco sachindamco changed the title When layout cardformfield render When layout cardformfield render second time on screen Jan 4, 2024
@jonasbark
Copy link
Member

Do you have a reproducible example code for this behavior?

@jonasbark jonasbark added Android Issue related to Android native bindings Awaiting response Awaiting response from the issuer and removed needs triage Needs triage labels Jan 8, 2024
@sachindamco
Copy link
Author

Do you have a reproducible example code for this behavior?

I just used Cardformfield. first time screen will shown but second time app crashed.

@remonh87
Copy link
Member

remonh87 commented Mar 2, 2024

closed as cannot reproduce

@remonh87 remonh87 closed this as completed Mar 2, 2024
@ebjorklund01
Copy link

ebjorklund01 commented May 21, 2024

We are running into this issue as well. This is crashing our Flutter Android apps when run in --release mode but not in --development mode. Adding

minifyEnabled false
shrinkResources false

To our android/app/build.gradle fixes the issue so it seems like a resource is being removed during Android shrinking and obfuscation. I would hypothesize that the proguard-rules.txt file needs an additional rule.

Stripe Versions:

flutter_stripe: "10.1.1"
stripe_android: "10.1.1"

Sample code

          Center(
            child: stripe.CardField(
              controller: _cardEditController,
              onCardChanged: (card) async {
                if (card?.complete ?? false) {
                  widget.onCardDetailsCompleted(true);
                } else {
                  widget.onCardDetailsCompleted(false);
                }
              },
            ),
          ),

Flutter Doctor

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.19.6, on macOS 14.4.1 23E224 darwin-arm64, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.3)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2023.1)
[✓] VS Code (version 1.89.1)
[✓] Connected device (5 available)
[✓] Network resources

• No issues found!

@ebjorklund01
Copy link

It seems like the crash is related to the icon and font used inside of the CardField.

@ebjorklund01
Copy link

Additional context:

Setting

minifyEnabled true
shrinkResources true

and

stripe.CardField(
  androidPlatformViewRenderType: stripe.AndroidPlatformViewRenderType.androidView

Will prevent the app from crashing, but will leave the input field empty (not icons, or hint text) and I cannot enter payment info. However, if I leave and return to the screen, the card input field does show the card hint, but does not show the credit card icon on the far left side. I can also enter payment info.

Setting

minifyEnabled false
shrinkResources false

Will once again resolve all issues and I can see all of the expected card info fields, and enter payment info.

All of the above applies to --release builds only.

@ebjorklund01
Copy link

@remonh87 Do you have any initial thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Android Issue related to Android native bindings Awaiting response Awaiting response from the issuer
Projects
None yet
Development

No branches or pull requests

4 participants