Reputation: 21
I currently have an android app (react native) that uses Mixpanel's push service (on top of Firebase messaging service)
I have specified an icon which is set in my manifest file, and references a set of image files generated with android studio (stored in drawable)
When I run the app with the debug variant (proguard not enabled), and send a push remotely to trigger a notification, the correct icon appears in the status bar, then when pulling down the notification tray, the correct icon appears next to the title
When I build the app in with the release variant (proguard enabled), when sending a push, the notification appears, but the icon in the top tray falls back to my launcher icon. When I pull the tray down, only a red circle can be seen with no icon asset.
Both tests were performed on an Android device with API level 28 (O)
Android manifest:
<application
...
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
/>
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/my_notification" />
<meta-data android:name="com.google.firebase.messaging.default_notification_color"
android:resource="@color/my_red" />
My build.gradle file has proguard enabled for release:
release {
minifyEnabled enableProguardInProductionBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
I have added the following to my proguard file to ensure the notification builder and mixpanel classes can trigger the notifications properly. As described above, the notification is appearing:
-keep class com.mixpanel.android.mpmetrics.** { *; }
-keep class com.google.android.gms.** { *; }
-keep class android.support.v4.app.** { *; }
I have analyzed the release APK generated using Android studio, and can confirm that the drawable asset is present in drawable (when looking at resources.arsc)
Pretty stumped on this one, any help would be appreciated
Upvotes: 0
Views: 790
Reputation: 21
Finally managed to find the issue!
Proguard was removing resource classes that the mixpanel SDK uses for loading the notification asset
Adding
-keep class **.R$* { *; }
To my proguard fixed the issue As per the instructions in a code comment in the mixpanel SDK here:
Upvotes: 2