Adyen / adyen-flutter

MIT License
23 stars 4 forks source link

Error inflating class com.google.android.material.textfield.TextInputLayout #133

Closed ChandraPrakashJangid closed 5 months ago

ChandraPrakashJangid commented 5 months ago

Describe the bug I am implementing adyen_checkout to my app. I am using card component advance flow. But I am facing following error:

Here is the log:

D/EGL_emulation(21596): app_time_stats: avg=2177.41ms min=13.13ms max=4341.69ms count=2
D/TrafficStats(21596): tagSocket(150) with statsTag=0xffffffff, statsUid=-1
D/TrafficStats(21596): tagSocket(137) with statsTag=0xffffffff, statsUid=-1
E/AndroidRuntime(21596): FATAL EXCEPTION: main
E/AndroidRuntime(21596): Process: com.mycomp.my_app, PID: 21596
E/AndroidRuntime(21596): android.view.InflateException: Binary XML file line #26 in com.mycomp.my_app:layout/card_view: Binary XML file line #26 in com.mycomp.my_app:layout/card_view: Error inflating class com.google.android.material.textfield.TextInputLayout
E/AndroidRuntime(21596):    Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@c63adad, Dispatchers.Main.immediate]
E/AndroidRuntime(21596): Caused by: android.view.InflateException: Binary XML file line #26 in com.mycomp.my_app:layout/card_view: Error inflating class com.google.android.material.textfield.TextInputLayout
E/AndroidRuntime(21596): Caused by: java.lang.reflect.InvocationTargetException
E/AndroidRuntime(21596):    at java.lang.reflect.Constructor.newInstance0(Native Method)
E/AndroidRuntime(21596):    at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
E/AndroidRuntime(21596):    at android.view.LayoutInflater.createView(LayoutInflater.java:866)
E/AndroidRuntime(21596):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1018)
E/AndroidRuntime(21596):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:973)
E/AndroidRuntime(21596):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:1135)
E/AndroidRuntime(21596):    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1096)
E/AndroidRuntime(21596):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:1138)
E/AndroidRuntime(21596):    at android.view.LayoutInflater.inflate(LayoutInflater.java:664)
E/AndroidRuntime(21596):    at android.view.LayoutInflater.inflate(LayoutInflater.java:538)
E/AndroidRuntime(21596):    at android.view.LayoutInflater.inflate(LayoutInflater.java:485)
E/AndroidRuntime(21596):    at com.adyen.checkout.card.databinding.CardViewBinding.inflate(CardViewBinding.java:175)
E/AndroidRuntime(21596):    at com.adyen.checkout.card.internal.ui.view.CardView.<init>(CardView.kt:72)
E/AndroidRuntime(21596):    at com.adyen.checkout.card.internal.ui.view.CardView.<init>(CardView.kt:60)
E/AndroidRuntime(21596):    at com.adyen.checkout.card.internal.ui.CardViewProvider.getView(CardViewProvider.kt:27)
E/AndroidRuntime(21596):    at com.adyen.checkout.ui.core.AdyenComponentView.loadView(AdyenComponentView.kt:121)
E/AndroidRuntime(21596):    at com.adyen.checkout.ui.core.AdyenComponentView.access$loadView(AdyenComponentView.kt:48)
E/AndroidRuntime(21596):    at com.adyen.checkout.ui.core.AdyenComponentView$attach$1.invokeSuspend(AdyenComponentView.kt:104)
E/AndroidRuntime(21596):    at com.adyen.checkout.ui.core.AdyenComponentView$attach$1.invoke(Unknown Source:8)
E/AndroidRuntime(21596):    at com.adyen.checkout.ui.core.AdyenComponentView$attach$1.invoke(Unknown Source:4)
E/AndroidRuntime(21596):    at kotlinx.coroutines.flow.FlowKt__TransformKt$onEach$$inlined$unsafeTransform$1$2.emit(Emitters.kt:223)
E/AndroidRuntime(21596):    at kotlinx.coroutines.flow.StateFlowImpl.collect(StateFlow.kt:396)
E/AndroidRuntime(21596):    at kotlinx.coroutines.flow.StateFlowImpl$collect$1.invokeSuspend(Unknown Source:15)
E/AndroidRuntime(21596):    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
E/AndroidRuntime(21596):    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
E/AndroidRuntime(21596):    at kotlinx.coroutines.EventLoop.processUnconfinedEvent(EventLoop.common.kt:68)
E/AndroidRuntime(21596):    at kotlinx.coroutines.internal.DispatchedContinuationKt.resumeCancellableWith(DispatchedContinuation.kt:373)
E/AndroidRuntime(21596):    at kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable(Cancellable.kt:30)
E/AndroidRuntime(21596):    at kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable$default(Cancellable.kt:25)
E/AndroidRuntime(21596):    at kotlinx.coroutines.CoroutineStart.invoke(CoroutineStart.kt:110)
E/AndroidRuntime(21596):    at kotlinx.coroutines.AbstractCoroutine.start(AbstractCoroutine.kt:126)
E/AndroidRuntime(21596):    at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch(Builders.common.kt:56)
E/AndroidRuntime(21596):    at kotlinx.coroutines.BuildersKt.launch(Unknown Source:1)
E/AndroidRuntime(21596):    at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch$default(Builders.common.kt:47)
E/AndroidRuntime(21596):    at kotlinx.coroutines.BuildersKt.launch$default(Unknown Source:1)
E/AndroidRuntime(21596):    at kotlinx.coroutines.flow.FlowKt__CollectKt.launchIn(Collect.kt:49)
E/AndroidRuntime(21596):    at kotlinx.coroutines.flow.FlowKt.launchIn(Unknown Source:1)
E/AndroidRuntime(21596):    at com.adyen.checkout.ui.core.AdyenComponentView.attach(AdyenComponentView.kt:111)
E/AndroidRuntime(21596):    at com.adyen.checkout.flutter.components.ComponentWrapperView.addComponent(ComponentWrapperView.kt:46)
E/AndroidRuntime(21596):    at com.adyen.checkout.flutter.components.card.BaseCardComponent.addComponent(BaseCardComponent.kt:77)
E/AndroidRuntime(21596):    at com.adyen.checkout.flutter.components.card.advanced.CardAdvancedComponent.<init>(CardAdvancedComponent.kt:37)
E/AndroidRuntime(21596):    at com.adyen.checkout.flutter.components.card.CardComponentFactory.create(CardComponentFactory.kt:32)
E/AndroidRuntime(21596):    at io.flutter.plugin.platform.PlatformViewsController.createPlatformView(PlatformViewsController.java:520)
E/AndroidRuntime(21596):    at io.flutter.plugin.platform.PlatformViewsController$1.createForTextureLayer(PlatformViewsController.java:193)
E/AndroidRuntime(21596):    at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.create(PlatformViewsChannel.java:128)
E/AndroidRuntime(21596):    at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.onMethodCall(PlatformViewsChannel.java:55)
E/AndroidRuntime(21596):    at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:267)
E/AndroidRuntime(21596):    at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295)
E/AndroidRuntime(21596):    at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:322)
E/AndroidRuntime(21596):    at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
E/AndroidRuntime(21596):    at android.os.Handler.handleCallback(Handler.java:958)
E/AndroidRuntime(21596):    at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(21596):    at android.os.Looper.loopOnce(Looper.java:205)
E/AndroidRuntime(21596):    at android.os.Looper.loop(Looper.java:294)
E/AndroidRuntime(21596):    at android.app.ActivityThread.main(ActivityThread.java:8177)
E/AndroidRuntime(21596):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(21596):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
E/AndroidRuntime(21596):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
E/AndroidRuntime(21596): Caused by: java.lang.IllegalArgumentException: The style on this component requires your app theme to be Theme.MaterialComponents (or a descendant).
E/AndroidRuntime(21596):    at com.google.android.material.internal.ThemeEnforcement.checkTheme(ThemeEnforcement.java:247)
E/AndroidRuntime(21596):    at com.google.android.material.internal.ThemeEnforcement.checkMaterialTheme(ThemeEnforcement.java:216)
E/AndroidRuntime(21596):    at com.google.android.material.internal.ThemeEnforcement.checkCompatibleTheme(ThemeEnforcement.java:144)
E/AndroidRuntime(21596):    at com.google.android.material.internal.ThemeEnforcement.obtainTintedStyledAttributes(ThemeEnforcement.java:114)
E/AndroidRuntime(21596):    at com.google.android.material.textfield.TextInputLayout.<init>(TextInputLayout.java:476)
E/AndroidRuntime(21596):    at com.google.android.material.textfield.TextInputLayout.<init>(TextInputLayout.java:455)
E/AndroidRuntime(21596):    ... 58 more
D/EGL_emulation(21596): app_time_stats: avg=6.73ms min=2.21ms max=68.36ms count=55
D/EGL_emulation(21596): app_time_stats: avg=3.69ms min=1.58ms max=6.60ms count=60
D/EGL_emulation(21596): app_time_stats: avg=3.04ms min=1.62ms max=6.26ms count=60
D/EGL_emulation(21596): app_time_stats: avg=3.47ms min=1.70ms max=6.30ms count=61
D/EGL_emulation(21596): app_time_stats: avg=3.77ms min=1.92ms max=6.70ms count=60
I/my_app(21596): Thread[6,tid=21601,WaitingInMainSignalCatcherLoop,Thread*=0xb4000072c9b40b20,peer=0x13207438,"Signal Catcher"]: reacting to signal 3
I/my_app(21596): 
I/my_app(21596): Wrote stack traces to tombstoned
D/EGL_emulation(21596): app_time_stats: avg=15.89ms min=1.64ms max=249.13ms count=35
D/EGL_emulation(21596): app_time_stats: avg=3.18ms min=1.69ms max=6.33ms count=60
I/Process (21596): Sending signal. PID: 21596 SIG: 9
Robert-SD commented 5 months ago

Hi @ChandraPrakashJangid, we will look into the issue and reply again when we have more information. Thanks for providing the log. It looks like that the issue is styling related so we will investigate into that.

ChandraPrakashJangid commented 5 months ago

@Robert-SD Thanks for looking into the issue. I found the issue and solution for this. In AndroidMainfest.xml it is required to use:

<meta-data android:name="io.flutter.embedding.android.NormalTheme" android:resource="@style/AppTheme" />

By default it is:

<meta-data android:name = "io.flutter.embedding.android.SplashScreenDrawable"  android:resource = "@drawable/launch_background" />

After this I am run the app.

Robert-SD commented 5 months ago

@ChandraPrakashJangid Thank you very much for your update. Happy to hear that you found a solution and for providing it! Feel free to reach out in case you have any further questions.

alextarrago commented 1 month ago

@ChandraPrakashJangid did you change something else besides this line on the Manifest. I still got the crash on Android. Can you share your styles.xml file, please?

alextarrago commented 1 month ago

Besides what you changed, we needed to add these lines to our styles.xml

<style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
</style>