-
Notifications
You must be signed in to change notification settings - Fork 626
Closed
Labels
Description
[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:
- For general technical questions, post a question on StackOverflow
with the firebase tag. - For general Firebase discussion, use the firebase-talk
google group. - For help troubleshooting your application that does not fall under one
of the above categories, reach out to the personalized
Firebase support channel.
[REQUIRED] Step 2: Describe your environment
- Android Studio version: 2021.2.1 Patch 2
- Firebase Component: inAppMessaging
- Component version: 20.2.0
[REQUIRED] Step 3: Describe the problem
Firebase crash.
Steps to reproduce:
message.getMessageType is null
Relevant Code:
// branch code
private List<Action> extractActions(InAppMessage message) {
List<Action> actions = new ArrayList<>();
switch (message.getMessageType()) {
case BANNER:
actions.add(((BannerMessage) message).getAction());
break;
case CARD:
actions.add(((CardMessage) message).getPrimaryAction());
actions.add(((CardMessage) message).getSecondaryAction());
break;
case IMAGE_ONLY:
actions.add(((ImageOnlyMessage) message).getAction());
break;
case MODAL:
actions.add(((ModalMessage) message).getAction());
break;
default:
// An empty action is treated like a dismiss
actions.add(Action.builder().build());
}
return actions;
}
// Log
Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'com.google.firebase.inappmessaging.model.MessageType kb.i.c()' on a null object reference
at com.google.firebase.inappmessaging.display.FirebaseInAppMessagingDisplay.extractActions(FirebaseInAppMessagingDisplay.java:437)
at com.google.firebase.inappmessaging.display.FirebaseInAppMessagingDisplay.inflateBinding(FirebaseInAppMessagingDisplay.java:308)
at com.google.firebase.inappmessaging.display.FirebaseInAppMessagingDisplay.access$000(FirebaseInAppMessagingDisplay.java:79)
at com.google.firebase.inappmessaging.display.FirebaseInAppMessagingDisplay$1.run(FirebaseInAppMessagingDisplay.java:286)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:246)
at android.app.ActivityThread.main(ActivityThread.java:8512)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1139)
// suggested code
private List<Action> extractActions(InAppMessage message) {
List<Action> actions = new ArrayList<>();
if(InAppMessage != null){
switch (message.getMessageType()) {
case BANNER:
actions.add(((BannerMessage) message).getAction());
break;
case CARD:
actions.add(((CardMessage) message).getPrimaryAction());
actions.add(((CardMessage) message).getSecondaryAction());
break;
case IMAGE_ONLY:
actions.add(((ImageOnlyMessage) message).getAction());
break;
case MODAL:
actions.add(((ModalMessage) message).getAction());
break;
default:
// An empty action is treated like a dismiss
actions.add(Action.builder().build());
}
}
return actions;
}
gonojuarez