firebase / firebase-android-sdk

Firebase Android SDK
https://firebase.google.com
Apache License 2.0
2.27k stars 575 forks source link

Getting crash with Firebase in-app messaging without secondary action #4048

Closed dev-millipede closed 2 years ago

dev-millipede commented 2 years ago

[READ] Step 1: Are you in the right place?

Issues filed here should be about bugs in the code in this repository. If you have a general question, need help debugging, or fall into some other category use one of these other channels:

[REQUIRED] Step 2: Describe your environment

[REQUIRED] Step 3: Describe the problem

Getting crash with Firebase in-app messaging without secondary action. Using Firebase-inapp messaging version 19.1.5 I wanted to create firebase in-app message with title, body and just one button to dismiss.

So, I have created firebase in-app message with title, body and just primary action. I have NOT added secondary action when creating firebase in-app messaging campaign.

When I published the campaign, it got published successfully.

Later I received in-app message in my app, the app crashed because the in-app message was coming with secondary action non null and secondary button null basically it was getting in to this exception code when I debugged.

else if (this.secondaryAction != null && this.secondaryAction.getButton() == null) { throw new IllegalArgumentException("Card model secondary action must be null or have a button"); } The above code is from firebase sdk's CardMessage.java file which is internally executes when you receive the in-app message from firebase.

The above code executes because I typecast my coming in-app message to CardMessage using below code:

with(inAppMessage as CardMessage) { title?.text = this.title.text body?.text = this.body?.text primaryBtn?.text = this.primaryAction.button?.text?.text secondaryBtn?.text = this.secondaryAction?.button?.text?.text } I am getting the crash as below:

Fatal Exception: io.reactivex.exceptions.OnErrorNotImplementedException: Card model secondary action must be null or have a button at io.reactivex.internal.functions.Functions$OnErrorMissingConsumer.accept(Functions.java:704) at io.reactivex.internal.functions.Functions$OnErrorMissingConsumer.accept(Functions.java:701) at io.reactivex.internal.subscribers.LambdaSubscriber.onError(LambdaSubscriber.java:79) at io.reactivex.internal.operators.flowable.FlowableObserveOn$BaseObserveOnSubscriber.checkTerminated(FlowableObserveOn.java:207) at io.reactivex.internal.operators.flowable.FlowableObserveOn$ObserveOnSubscriber.runAsync(FlowableObserveOn.java:392) at io.reactivex.internal.operators.flowable.FlowableObserveOn$BaseObserveOnSubscriber.run(FlowableObserveOn.java:176) at io.reactivex.android.schedulers.HandlerScheduler$ScheduledRunnable.run(HandlerScheduler.java:109) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:226) at android.os.Looper.loop(Looper.java:313) at android.app.ActivityThread.main(ActivityThread.java:8669) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)

Caused by java.lang.IllegalArgumentException: Card model secondary action must be null or have a button at com.google.firebase.inappmessaging.model.CardMessage$Builder.build(CardMessage.java:249) at com.google.firebase.inappmessaging.model.ProtoMarshallerClient.decode(ProtoMarshallerClient.java:231) at com.google.firebase.inappmessaging.internal.InAppMessageStreamManager.triggeredInAppMessage(InAppMessageStreamManager.java:365) at com.google.firebase.inappmessaging.internal.InAppMessageStreamManager.lambda$getTriggeredInAppMessageMaybe$27(InAppMessageStreamManager.java:341) at com.google.firebase.inappmessaging.internal.InAppMessageStreamManager$$Lambda$9.apply(InAppMessageStreamManager.java:6) at io.reactivex.internal.operators.maybe.MaybeFlatten$FlatMapMaybeObserver.onSuccess(MaybeFlatten.java:89) at io.reactivex.internal.operators.flowable.FlowableElementAtMaybe$ElementAtSubscriber.onNext(FlowableElementAtMaybe.java:80) at io.reactivex.internal.operators.flowable.FlowableFlattenIterable$FlattenIterableSubscriber.drain(FlowableFlattenIterable.java:313) at io.reactivex.internal.operators.flowable.FlowableFlattenIterable$FlattenIterableSubscriber.onNext(FlowableFlattenIterable.java:175) at io.reactivex.internal.operators.flowable.FlowableMap$MapSubscriber.onNext(FlowableMap.java:57) at io.reactivex.internal.subscriptions.DeferredScalarSubscription.complete(DeferredScalarSubscription.java:118) at io.reactivex.internal.operators.flowable.FlowableToList$ToListSubscriber.onComplete(FlowableToList.java:86) at io.reactivex.internal.operators.flowable.FlowableFlatMapMaybe$FlatMapMaybeSubscriber.drainLoop(FlowableFlatMapMaybe.java:327) at io.reactivex.internal.operators.flowable.FlowableFlatMapMaybe$FlatMapMaybeSubscriber.drain(FlowableFlatMapMaybe.java:280) at io.reactivex.internal.operators.flowable.FlowableFlatMapMaybe$FlatMapMaybeSubscriber.onComplete(FlowableFlatMapMaybe.java:152) at io.reactivex.internal.operators.flowable.FlowableFlatMapMaybe$FlatMapMaybeSubscriber.drainLoop(FlowableFlatMapMaybe.java:327) at io.reactivex.internal.operators.flowable.FlowableFlatMapMaybe$FlatMapMaybeSubscriber.drain(FlowableFlatMapMaybe.java:280) at io.reactivex.internal.operators.flowable.FlowableFlatMapMaybe$FlatMapMaybeSubscriber.onComplete(FlowableFlatMapMaybe.java:152) at io.reactivex.internal.operators.flowable.FlowableFlatMapMaybe$FlatMapMaybeSubscriber.drainLoop(FlowableFlatMapMaybe.java:327) at io.reactivex.internal.operators.flowable.FlowableFlatMapMaybe$FlatMapMaybeSubscriber.drain(FlowableFlatMapMaybe.java:280) at io.reactivex.internal.operators.flowable.FlowableFlatMapMaybe$FlatMapMaybeSubscriber.onComplete(FlowableFlatMapMaybe.java:152) at io.reactivex.internal.subscribers.BasicFuseableSubscriber.onComplete(BasicFuseableSubscriber.java:120) at io.reactivex.internal.subscribers.BasicFuseableConditionalSubscriber.onComplete(BasicFuseableConditionalSubscriber.java:119) at io.reactivex.internal.operators.flowable.FlowableFromIterable$IteratorConditionalSubscription.fastPath(FlowableFromIterable.java:338) at io.reactivex.internal.operators.flowable.FlowableFromIterable$BaseRangeSubscription.request(FlowableFromIterable.java:123) at io.reactivex.internal.subscribers.BasicFuseableConditionalSubscriber.request(BasicFuseableConditionalSubscriber.java:152) at io.reactivex.internal.subscribers.BasicFuseableSubscriber.request(BasicFuseableSubscriber.java:153) at io.reactivex.internal.operators.flowable.FlowableFlatMapMaybe$FlatMapMaybeSubscriber.onSubscribe(FlowableFlatMapMaybe.java:107) at io.reactivex.internal.subscribers.BasicFuseableSubscriber.onSubscribe(BasicFuseableSubscriber.java:67) at io.reactivex.internal.subscribers.BasicFuseableConditionalSubscriber.onSubscribe(BasicFuseableConditionalSubscriber.java:66) at io.reactivex.internal.operators.flowable.FlowableFromIterable.subscribe(FlowableFromIterable.java:66) at io.reactivex.internal.operators.flowable.FlowableFromIterable.subscribeActual(FlowableFromIterable.java:47) at io.reactivex.Flowable.subscribe(Flowable.java:14349) at io.reactivex.internal.operators.flowable.FlowableFilter.subscribeActual(FlowableFilter.java:34) at io.reactivex.Flowable.subscribe(Flowable.java:14349) at io.reactivex.internal.operators.flowable.FlowableFilter.subscribeActual(FlowableFilter.java:37) at io.reactivex.Flowable.subscribe(Flowable.java:14349) at io.reactivex.internal.operators.flowable.FlowableFlatMapMaybe.subscribeActual(FlowableFlatMapMaybe.java:54) at io.reactivex.Flowable.subscribe(Flowable.java:14349) at io.reactivex.internal.operators.flowable.FlowableFlatMapMaybe.subscribeActual(FlowableFlatMapMaybe.java:54) at io.reactivex.Flowable.subscribe(Flowable.java:14349) at io.reactivex.internal.operators.flowable.FlowableFlatMapMaybe.subscribeActual(FlowableFlatMapMaybe.java:54) at io.reactivex.Flowable.subscribe(Flowable.java:14349) at io.reactivex.internal.operators.flowable.FlowableToList.subscribeActual(FlowableToList.java:44) at io.reactivex.Flowable.subscribe(Flowable.java:14349) at io.reactivex.internal.operators.flowable.FlowableMap.subscribeActual(FlowableMap.java:38) at io.reactivex.Flowable.subscribe(Flowable.java:14349) at io.reactivex.internal.operators.flowable.FlowableFlattenIterable.subscribeActual(FlowableFlattenIterable.java:81) at io.reactivex.Flowable.subscribe(Flowable.java:14349) at io.reactivex.internal.operators.flowable.FlowableElementAtMaybe.subscribeActual(FlowableElementAtMaybe.java:36) at io.reactivex.Maybe.subscribe(Maybe.java:4073) at io.reactivex.internal.operators.maybe.MaybeFlatten.subscribeActual(MaybeFlatten.java:42) at io.reactivex.Maybe.subscribe(Maybe.java:4073) at io.reactivex.internal.operators.maybe.MaybeFlatten$FlatMapMaybeObserver.onSuccess(MaybeFlatten.java:97) at io.reactivex.internal.operators.maybe.MaybeSwitchIfEmpty$SwitchIfEmptyMaybeObserver.onSuccess(MaybeSwitchIfEmpty.java:75) at io.reactivex.internal.operators.maybe.MaybeOnErrorNext$OnErrorNextMaybeObserver.onSuccess(MaybeOnErrorNext.java:89) at io.reactivex.internal.operators.maybe.MaybePeek$MaybePeekObserver.onSuccess(MaybePeek.java:122) at io.reactivex.internal.operators.maybe.MaybePeek$MaybePeekObserver.onSuccess(MaybePeek.java:122) at io.reactivex.internal.operators.maybe.MaybePeek$MaybePeekObserver.onSuccess(MaybePeek.java:122) at io.reactivex.internal.operators.maybe.MaybeFilter$FilterMaybeObserver.onSuccess(MaybeFilter.java:89) at io.reactivex.internal.operators.maybe.MaybeSwitchIfEmpty$SwitchIfEmptyMaybeObserver$OtherMaybeObserver.onSuccess(MaybeSwitchIfEmpty.java:108) at io.reactivex.internal.operators.maybe.MaybePeek$MaybePeekObserver.onSuccess(MaybePeek.java:122) at io.reactivex.internal.operators.maybe.MaybeFromCallable.subscribeActual(MaybeFromCallable.java:61) at io.reactivex.Maybe.subscribe(Maybe.java:4073) at io.reactivex.internal.operators.maybe.MaybePeek.subscribeActual(MaybePeek.java:56) at io.reactivex.Maybe.subscribe(Maybe.java:4073) at io.reactivex.internal.operators.maybe.MaybeSwitchIfEmpty$SwitchIfEmptyMaybeObserver.onComplete(MaybeSwitchIfEmpty.java:88) at io.reactivex.internal.operators.maybe.MaybeFromCallable.subscribeActual(MaybeFromCallable.java:59) at io.reactivex.Maybe.subscribe(Maybe.java:4073) at io.reactivex.internal.operators.maybe.MaybeSwitchIfEmpty.subscribeActual(MaybeSwitchIfEmpty.java:38) at io.reactivex.Maybe.subscribe(Maybe.java:4073) at io.reactivex.internal.operators.maybe.MaybeFilter.subscribeActual(MaybeFilter.java:39) at io.reactivex.Maybe.subscribe(Maybe.java:4073) at io.reactivex.internal.operators.maybe.MaybePeek.subscribeActual(MaybePeek.java:56) at io.reactivex.Maybe.subscribe(Maybe.java:4073) at io.reactivex.internal.operators.maybe.MaybePeek.subscribeActual(MaybePeek.java:56) at io.reactivex.Maybe.subscribe(Maybe.java:4073) at io.reactivex.internal.operators.maybe.MaybePeek.subscribeActual(MaybePeek.java:56) at io.reactivex.Maybe.subscribe(Maybe.java:4073) at io.reactivex.internal.operators.maybe.MaybeOnErrorNext.subscribeActual(MaybeOnErrorNext.java:46) at io.reactivex.Maybe.subscribe(Maybe.java:4073) at io.reactivex.internal.operators.maybe.MaybeSwitchIfEmpty.subscribeActual(MaybeSwitchIfEmpty.java:38) at io.reactivex.Maybe.subscribe(Maybe.java:4073) at io.reactivex.internal.operators.maybe.MaybeFlatten.subscribeActual(MaybeFlatten.java:42) at io.reactivex.Maybe.subscribe(Maybe.java:4073) at io.reactivex.internal.operators.maybe.MaybeToFlowable.subscribeActual(MaybeToFlowable.java:45) at io.reactivex.Flowable.subscribe(Flowable.java:14349) at io.reactivex.Flowable.subscribe(Flowable.java:14295) at io.reactivex.internal.operators.flowable.FlowableConcatMap$ConcatMapImmediate.drain(FlowableConcatMap.java:344) at io.reactivex.internal.operators.flowable.FlowableConcatMap$BaseConcatMapSubscriber.onNext(FlowableConcatMap.java:159) at io.reactivex.internal.operators.flowable.FlowableObserveOn$ObserveOnSubscriber.runBackfused(FlowableObserveOn.java:441) at io.reactivex.internal.operators.flowable.FlowableObserveOn$BaseObserveOnSubscriber.run(FlowableObserveOn.java:172) at io.reactivex.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:66) at io.reactivex.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:57) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:920)

Can anyone pls help me with this issue.

Steps to reproduce:

Create Firebase in-app message campaign with only primary button

Relevant Code:

else if (this.secondaryAction != null && this.secondaryAction.getButton() == null) { throw new IllegalArgumentException("Card model secondary action must be null or have a button"); }

The above code is from firebase sdk's CardMessage.java file which is internally executes when you receive the in-app message from firebase.

google-oss-bot commented 2 years ago

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

argzdev commented 2 years ago

Hi @dev-millipede, thanks for reporting. I tried recreating this version with our quickstart project and I don't seem to encounter the error with the version 19.1.5. Could you try using our latest version 20.1.2 and see if this fixes your issue?

You could also take a look at our quickstart samples. This'll help you check if there are any configuration setup issues.

google-oss-bot commented 2 years ago

Hey @dev-millipede. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot commented 2 years ago

Since there haven't been any recent updates here, I am going to close this issue.

@dev-millipede if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.