I found that the R8 code shrinker causes the intercom plugin to result in an app crash with certain versions of gradle/AGP/kotlin (see details below). This happens when calling Intercom.instance.displayMessenger, but likely other methods can incur it as well. It is only reproducible when running the app in --release mode, as the code shrinker takes no effect otherwise.
Crash logs:
```
[ ] E/AndroidRuntime(11955): java.lang.IncompatibleClassChangeError: Class 'android.content.res.XmlBlock$Parser' does not implement interface 'cf.a' in call to 'int cf.a.next()' (declaration of 'Y0.c' appears in /data/app/~~rnPEU8oL63JJs5TNPzhGIw==/com.stint.stint-j_efgM1VfK7pE6EWGwwQxw==/base.apk)
[ ] E/AndroidRuntime(11955): at Y0.c.d(SourceFile:1)
[ ] E/AndroidRuntime(11955): at m1.f.b(SourceFile:55)
[ ] E/AndroidRuntime(11955): at m1.f.c(SourceFile:85)
[ ] E/AndroidRuntime(11955): at io.intercom.android.sdk.m5.components.intercombadge.IntercomBadgeKt$IntercomBadge$1.invoke(SourceFile:34)
[ ] E/AndroidRuntime(11955): at io.intercom.android.sdk.m5.components.intercombadge.IntercomBadgeKt$IntercomBadge$1.invoke(SourceFile:1)
[ ] E/AndroidRuntime(11955): at G0.b.d(SourceFile:45)
[ ] E/AndroidRuntime(11955): at G0.b.invoke(SourceFile:2)
[ ] E/AndroidRuntime(11955): at v0.n$a.invoke(SourceFile:24)
[ ] E/AndroidRuntime(11955): at v0.n$a.invoke(SourceFile:1)
[ ] E/AndroidRuntime(11955): at G0.b.e(SourceFile:45)
[ ] E/AndroidRuntime(11955): at G0.b.invoke(SourceFile:1)
[ ] E/AndroidRuntime(11955): at v0.z0$b.invoke(SourceFile:36)
[ ] E/AndroidRuntime(11955): at v0.z0$b.invoke(SourceFile:1)
[ ] E/AndroidRuntime(11955): at G0.b.e(SourceFile:45)
[ ] E/AndroidRuntime(11955): at G0.b.invoke(SourceFile:1)
[ ] E/AndroidRuntime(11955): at y0.y.b(SourceFile:31)
[ ] E/AndroidRuntime(11955): at v0.z0.a(SourceFile:187)
[ ] E/AndroidRuntime(11955): at v0.n.a(SourceFile:414)
[ ] E/AndroidRuntime(11955): at io.intercom.android.sdk.m5.components.intercombadge.IntercomBadgeKt.IntercomBadge-vxvQc8A(SourceFile:354)
[ ] E/AndroidRuntime(11955): at io.intercom.android.sdk.m5.home.ui.HomeScreenKt$HomeScreen$2.invoke(SourceFile:57)
[ ] E/AndroidRuntime(11955): at io.intercom.android.sdk.m5.home.ui.HomeScreenKt$HomeScreen$2.invoke(SourceFile:1)
...
```
I found a workaround by adding the following in android/gradle.properties
android.enableR8.fullMode=false
However to me this likely indicates that a certain set of proguard rules are missing, and should be added when using the intercom plugin. Perhaps something that is part of the setup guide for anrdoid? Here's all the details around gradle/AGP/kotlin versions that this issue is reproducible with:
android/settings.gradle
```
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "8.7.0" apply false
id "org.jetbrains.kotlin.android" version "2.0.20" apply false
id "com.google.gms.google-services" version "4.3.14" apply false
}
```
This issue here seems related at a first glance https://github.com/flutter/flutter/issues/146266, but it seems to conclude that upgrading to AGP 8.5+ should fix it. However, I am using AGP 8.7 and am experience an issue with the intercom plugin specifically.
I found that the R8 code shrinker causes the intercom plugin to result in an app crash with certain versions of gradle/AGP/kotlin (see details below). This happens when calling
Intercom.instance.displayMessenger
, but likely other methods can incur it as well. It is only reproducible when running the app in--release
mode, as the code shrinker takes no effect otherwise.
``` [ ] E/AndroidRuntime(11955): java.lang.IncompatibleClassChangeError: Class 'android.content.res.XmlBlock$Parser' does not implement interface 'cf.a' in call to 'int cf.a.next()' (declaration of 'Y0.c' appears in /data/app/~~rnPEU8oL63JJs5TNPzhGIw==/com.stint.stint-j_efgM1VfK7pE6EWGwwQxw==/base.apk) [ ] E/AndroidRuntime(11955): at Y0.c.d(SourceFile:1) [ ] E/AndroidRuntime(11955): at m1.f.b(SourceFile:55) [ ] E/AndroidRuntime(11955): at m1.f.c(SourceFile:85) [ ] E/AndroidRuntime(11955): at io.intercom.android.sdk.m5.components.intercombadge.IntercomBadgeKt$IntercomBadge$1.invoke(SourceFile:34) [ ] E/AndroidRuntime(11955): at io.intercom.android.sdk.m5.components.intercombadge.IntercomBadgeKt$IntercomBadge$1.invoke(SourceFile:1) [ ] E/AndroidRuntime(11955): at G0.b.d(SourceFile:45) [ ] E/AndroidRuntime(11955): at G0.b.invoke(SourceFile:2) [ ] E/AndroidRuntime(11955): at v0.n$a.invoke(SourceFile:24) [ ] E/AndroidRuntime(11955): at v0.n$a.invoke(SourceFile:1) [ ] E/AndroidRuntime(11955): at G0.b.e(SourceFile:45) [ ] E/AndroidRuntime(11955): at G0.b.invoke(SourceFile:1) [ ] E/AndroidRuntime(11955): at v0.z0$b.invoke(SourceFile:36) [ ] E/AndroidRuntime(11955): at v0.z0$b.invoke(SourceFile:1) [ ] E/AndroidRuntime(11955): at G0.b.e(SourceFile:45) [ ] E/AndroidRuntime(11955): at G0.b.invoke(SourceFile:1) [ ] E/AndroidRuntime(11955): at y0.y.b(SourceFile:31) [ ] E/AndroidRuntime(11955): at v0.z0.a(SourceFile:187) [ ] E/AndroidRuntime(11955): at v0.n.a(SourceFile:414) [ ] E/AndroidRuntime(11955): at io.intercom.android.sdk.m5.components.intercombadge.IntercomBadgeKt.IntercomBadge-vxvQc8A(SourceFile:354) [ ] E/AndroidRuntime(11955): at io.intercom.android.sdk.m5.home.ui.HomeScreenKt$HomeScreen$2.invoke(SourceFile:57) [ ] E/AndroidRuntime(11955): at io.intercom.android.sdk.m5.home.ui.HomeScreenKt$HomeScreen$2.invoke(SourceFile:1) ... ```Crash logs:
I found a workaround by adding the following in
android/gradle.properties
However to me this likely indicates that a certain set of proguard rules are missing, and should be added when using the intercom plugin. Perhaps something that is part of the setup guide for anrdoid? Here's all the details around gradle/AGP/kotlin versions that this issue is reproducible with:
``` plugins { id "dev.flutter.flutter-plugin-loader" version "1.0.0" id "com.android.application" version "8.7.0" apply false id "org.jetbrains.kotlin.android" version "2.0.20" apply false id "com.google.gms.google-services" version "4.3.14" apply false } ```android/settings.gradle
``` distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip ```android/gradle/gradle-wrapper.properties
``` org.gradle.jvmargs=-Xmx4G -Dkotlin.daemon.jvm.options=-Xmx2G -XX:+HeapDumpOnOutOfMemoryError -XX:+UseParallelGC -Dfile.encoding=UTF-8 android.useAndroidX=true android.enableJetifier=true org.gradle.daemon=true ```android/gradle.properties
This issue here seems related at a first glance https://github.com/flutter/flutter/issues/146266, but it seems to conclude that upgrading to AGP 8.5+ should fix it. However, I am using AGP 8.7 and am experience an issue with the intercom plugin specifically.
Any help/tips would be much appreciated!