question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PBandK 0.10.0.beta3 incompatible with Firebase Performance monitoring 19.0.10 or lower

See original GitHub issue

I’ve found a side effect of updating the protobuf-javalite version to 3.15.5 in 0.10.0.beta.3: now pbandk is only compatible with Firebase performance monitoring 19.0.11 (or higher): https://firebase.google.com/support/release-notes/android#performance_v19-0-11

This is because Firebase performance monitoring below 19.0.11 hasprotobuf-javalite:3.11.0 as a transitive dependency and when Gradle resolves this to a newer version (due to pbandk-runtime), this causes a runtime crash when minification is enabled:

java.lang.RuntimeException: Unable to resume activity {<packagename>/<packagename>.MainActivity}: java.lang.ClassCastException: c.c.h.z0 cannot be cast to java.lang.String
        at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4444)
        at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4476)
        at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:52)
        at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:223)
        at android.app.ActivityThread.main(ActivityThread.java:7656)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
     Caused by: java.lang.ClassCastException: c.c.h.z0 cannot be cast to java.lang.String
        at c.c.h.j1.S(SourceFile:507)
        at c.c.h.j1.Q(SourceFile:227)
        at c.c.h.y0.e(SourceFile:77)
        at c.c.h.y0.a(SourceFile:71)
        at c.c.h.w1.d(SourceFile:90)
        at c.c.h.w1.e(SourceFile:104)
        at com.google.protobuf.GeneratedMessageLite.makeImmutable(SourceFile:175)
        at com.google.protobuf.GeneratedMessageLite$b.n(SourceFile:397)
        at com.google.protobuf.GeneratedMessageLite$b.l(SourceFile:405)
        at com.google.firebase.perf.metrics.AppStartTrace.onActivityResumed(SourceFile:219)
        at android.app.Application.dispatchActivityResumed(Application.java:436)
        at android.app.Activity.dispatchActivityResumed(Activity.java:1379)
        at android.app.Activity.onResume(Activity.java:1905)
        at b.k.b.e.onResume(SourceFile:411)
        at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1456)
        at android.app.Activity.performResume(Activity.java:8135)
        at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4434)
        at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4476) 
        at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:52) 
        at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176) 
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        at android.os.Looper.loop(Looper.java:223) 
        at android.app.ActivityThread.main(ActivityThread.java:7656) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947) 

Notice how nasty of a bug this is:

  1. Minification needs to be enabled
  2. This happens on implicitly loading Firebase performance monitoring via a ContentProvider at app startup -> so the stacktrace doesn’t have any meaningful information.

I think this could potentially be solvable by adding specific Proguard exclusions to tackle this error, but I haven’t been able to pin down what those exceptions should be yet. Also I’m doubtful whether this is something that should be solved within pbandk

Should we maybe add a section with known issues to the release notes or readme?

Edit: minification is not required to reproduce this bug

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
garypcommented, Mar 26, 2021

Ugh, that’s terrible. I’m quite surprised that a library like protobuf does not provide proper ABI compatibility between releases. But I just went digging in their docs and apparently the lite runtime has no compatibility guarantees 😞

From https://github.com/protocolbuffers/protobuf/blob/master/java/README.md#compatibility-notice:

Protobuf LITE runtime APIs are not stable yet. They are subject to change even in minor version releases.

And from https://github.com/protocolbuffers/protobuf/blob/master/java/lite.md:

Note that in order to achieve maximum performance and code size, we will NOT guarantee API/ABI stability for Java Lite. If this is not acceptable for your use-case, please use the full Java runtime instead.

I don’t understand how they could expect this to work when protobuf-javalite is a transitive dependency for so many other projects.

1reaction
JeroenMolscommented, Mar 19, 2021

So basically, the issue is that the combination of

    implementation "com.google.protobuf:protobuf-javalite:3.14.0"
    implementation "com.google.firebase:firebase-perf:19.0.9"

Crashes at runtime with message com.google.protobuf.MapEntryLite cannot be cast to java.lang.String

And having pbandk as a dependency in a project might cause this, but likely other dependencies would as well.

Solution is to update firebase-perf to 19.0.11 or higher

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found