Firebase-android-sdk: FATAL EXCEPTION: java.lang.ArrayIndexOutOfBoundsException: com.google.protobuf.MessageSchema.newSchemaForRawMessageInfo

Created on 7 Nov 2020  路  13Comments  路  Source: firebase/firebase-android-sdk

[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: 4.1
  • Firebase Component: Firebase Performance (Database, Firestore, Storage, Functions, etc)
  • Component version: 26.0.0

[REQUIRED] Step 3: Describe the problem

App crashes consistently on adding Firebase performance monitoring

implementation platform('com.google.firebase:firebase-bom:26.0.0')
implementation 'com.google.firebase:firebase-perf'

Steps to reproduce:

Create any activity with both the protobuff and firebase plugin
apply plugin: 'com.google.protobuf'
apply plugin: 'com.google.firebase.firebase-perf'
What happened? How can we make the problem occur?

 java.lang.ArrayIndexOutOfBoundsException: length=4; index=4
        at com.google.protobuf.MessageSchema.newSchemaForRawMessageInfo(MessageSchema.java:507)
        at com.google.protobuf.MessageSchema.newSchema(MessageSchema.java:227)
        at com.google.protobuf.ManifestSchemaFactory.newSchema(ManifestSchemaFactory.java:77)
        at com.google.protobuf.ManifestSchemaFactory.createSchema(ManifestSchemaFactory.java:71)
        at com.google.protobuf.Protobuf.schemaFor(Protobuf.java:93)
        at com.google.protobuf.Protobuf.schemaFor(Protobuf.java:107)
        at com.google.protobuf.GeneratedMessageLite.makeImmutable(GeneratedMessageLite.java:175)
        at com.google.protobuf.GeneratedMessageLite$Builder.buildPartial(GeneratedMessageLite.java:395)
        at com.google.protobuf.GeneratedMessageLite$Builder.build(GeneratedMessageLite.java:403)
        at com.google.firebase.perf.v1.ApplicationInfo$Builder.setAndroidAppInfo(ApplicationInfo.java:934)
        at com.google.firebase.perf.internal.FirebasePerfClearcutLogger.syncInit(FirebasePerfClearcutLogger.java:278)
        at com.google.firebase.perf.internal.FirebasePerfClearcutLogger.access$000(FirebasePerfClearcutLogger.java:62)
        at com.google.firebase.perf.internal.FirebasePerfClearcutLogger$1.run(FirebasePerfClearcutLogger.java:169)
        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:923)
2020-11-07 19:55:34.998 16553-16619/? I/Process: Sending signal. PID: 16553 SIG: 9

The Firebase analytics works fine, the problem start as soon as adding the *Firebase Performance *

Relevant Code:

class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
    }
}
performance

Most helpful comment

We are seeing the same issue with the same stack trace. In our case, we aren't using the firebase bom yet. Here are our version numbers:

'firebaseCore'       : '18.0.0',
'firebaseAnalytics'  : '18.0.0',
'firebaseMessaging'  : '21.0.0',
'firebasePerf'       : '19.0.9',
'firebaseConfig'     : '20.0.0'

* Edit *
Just tested with the bom and see the same issue

All 13 comments

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

We are seeing the same issue with the same stack trace. In our case, we aren't using the firebase bom yet. Here are our version numbers:

'firebaseCore'       : '18.0.0',
'firebaseAnalytics'  : '18.0.0',
'firebaseMessaging'  : '21.0.0',
'firebasePerf'       : '19.0.9',
'firebaseConfig'     : '20.0.0'

* Edit *
Just tested with the bom and see the same issue

In my case one of my dependency was using com.google.protobuf:protobuf-javalite:3.13.0 whereas firebase pref uses com.google.protobuf:protobuf-javalite:3.11.0. Excluding the 3.13.0 fixed the issue for firebase. But I think firebase should update to protobuf-javalite:3.13.0

Assigning to current oncallers.

I haven't yet been able to reproduce this issue, but am still working on it. I'll let you know if we need any additional information.

Optional: While not required, it would be helpful to have a repro demo project.

Note: this is being tracked internally at b/173728277.

Thank you for reporting this issue!

The error is still happening on the latest com.google.firebase:firebase-bom:26.1.0 (which uses com.google.firebase:firebase-perf-ktx:19.0.10).

As @SaqibJDev pointed out, forcing its version may work, at least for me:

implementation("com.google.protobuf:protobuf-javalite") {
    version {
        strictly '3.11.0'
    }
}

However, it would be desirable to update the library with a newer protobuf-javalite version.

Thanks. vkryachko@, can you take a look and see if we can update protobuf-javalite version?

@yingdai3 firebase-perf 19.0.10 already depends on protobuf-javalite:3.11.0.

I wonder if some other dependency in the developer's app "bumps" the version to an incompatible one?

@vkryachko sure thing firebase depends on protobuf-javalite:3.11.0, and in my case, other dependency with a min required version of protobuf-javalite:3.12.0 was referenced in the project making firebase library crash while it shouldn't.

I can reproduce the problem with 3.12.0 although I have a different stacktrace:

     Caused by: java.lang.ClassCastException: com.google.protobuf.MapEntryLite cannot be cast to java.lang.String
        at com.google.protobuf.MessageSchema.newSchemaForRawMessageInfo(MessageSchema.java:507)
        at com.google.protobuf.MessageSchema.newSchema(MessageSchema.java:227)
        at com.google.protobuf.ManifestSchemaFactory.newSchema(ManifestSchemaFactory.java:77)
        at com.google.protobuf.ManifestSchemaFactory.createSchema(ManifestSchemaFactory.java:71)
        at com.google.protobuf.Protobuf.schemaFor(Protobuf.java:93)
        at com.google.protobuf.Protobuf.schemaFor(Protobuf.java:107)
        at com.google.protobuf.GeneratedMessageLite.makeImmutable(GeneratedMessageLite.java:175)
        at com.google.protobuf.GeneratedMessageLite$Builder.buildPartial(GeneratedMessageLite.java:395)
        at com.google.protobuf.GeneratedMessageLite$Builder.build(GeneratedMessageLite.java:403)
        at com.google.firebase.perf.metrics.AppStartTrace.onActivityResumed(AppStartTrace.java:214)
        at android.app.Application.dispatchActivityResumed(Application.java:436)
        at android.app.Activity.dispatchActivityResumed(Activity.java:1265)
        at android.app.Activity.onResume(Activity.java:1789)
        at androidx.fragment.app.FragmentActivity.onResume(FragmentActivity.java:456)
        at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1446)
        at android.app.Activity.performResume(Activity.java:7939)
        at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4195)
        at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4237)聽
        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:2016)聽
        at android.os.Handler.dispatchMessage(Handler.java:107)聽
        at android.os.Looper.loop(Looper.java:214)聽
        at android.app.ActivityThread.main(ActivityThread.java:7356)聽
        at java.lang.reflect.Method.invoke(Native Method)聽
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)聽
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)聽

The only mitigation for now is to force downgrade as described in https://github.com/firebase/firebase-android-sdk/issues/2158#issuecomment-732989095
Short term we will upgrade all SDKs to the latest protobuf-javalite, but mid/long term we will remove the protobuf dependency altogether as it does not follow semver and is not binary compatible across releases.

Thanks a lot @vkryachko, that would help us so much. And if you guys add gRPC client network monitoring support in the near future, even much better! :wink: (already filled the feature request to your support team)

Thanks @vkryachko and @XabierGoros !

@XabierGoros I'm going to close this issue now since there is a mitigation and we have mid/long term plans.

Was this page helpful?
0 / 5 - 0 ratings