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.

No static method com/google/protobuf/GeneratedMessageLite#registerDefaultInstance

See original GitHub issue

[REQUIRED] Step 2: Describe your environment

  • Android Studio version: 4.1
  • Firebase Component: firebase-config
  • Component version: firebase-database:19.3.1, firebase-auth:19.3.2, firebase-perf:19.0.8, firebase-crashlytics:17.1.1, firebase-common:16.0.4, firebase-cloud-messaging:20.2.3, firebase-analytics:17.4.4

We don’t use firebase-config directly in our app. We assume that it is one of the transitive dependency of the other Firebase libraries that we are using.

[REQUIRED] Step 3: Describe the problem

Application Crashes on Launch after upgrading the Firebase Libraries.

Fatal Exception: java.lang.NoSuchMethodError: No static method registerDefaultInstance(Ljava/lang/Class;Lcom/google/protobuf/GeneratedMessageLite;)V in class Lcom/google/protobuf/GeneratedMessageLite; or its super classes (declaration of 'com.google.protobuf.GeneratedMessageLite' appears in base.apk!classes3.dex)
       at com.google.firebase.remoteconfig.proto.ConfigPersistence$PersistedConfig.<clinit>(ConfigPersistence.java:813)
       at com.google.firebase.remoteconfig.proto.ConfigPersistence$PersistedConfig.parseFrom(ConfigPersistence.java:402)
       at com.google.firebase.remoteconfig.internal.LegacyConfigsHandler.readPersistedConfig(LegacyConfigsHandler.java:340)
       at com.google.firebase.remoteconfig.internal.LegacyConfigsHandler.getConvertedLegacyConfigs(LegacyConfigsHandler.java:196)
       at com.google.firebase.remoteconfig.internal.LegacyConfigsHandler.saveLegacyConfigsIfNecessary(LegacyConfigsHandler.java:151)
       at com.google.firebase.remoteconfig.RemoteConfigComponent$$Lambda$4.call(RemoteConfigComponent.java:2)
       at com.google.android.gms.tasks.zzz.run(zzz.java:2)
       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:919)

Steps to reproduce:

The legacy SDK stores configs in the App’s disk space as a {@link PersistedConfig}. The new SDK stores values as JSON

Relevant Code:

As the documentation says,

  1. The olders SDKs store the config as PersistedConfig probably using google ptorobuf config.
  2. The newer SDKs store the config as JSON.

We never declared google protobuf as one of the dependencies of the Application Module. So, we believe it has been resolved transitively. Now after the library upgrade, we are facing a crash as protobuf is not available at runtime

The crash is happenning when PersistedConfig.parseFrom is called.

private PersistedConfig readPersistedConfig() {
    if (context == null) {
      return null;
    }
    PersistedConfig persistedConfig;
    FileInputStream fileInputStream = null;
    try {
      fileInputStream = context.openFileInput(LEGACY_CONFIGS_FILE_NAME);
      persistedConfig = PersistedConfig.parseFrom(fileInputStream);
    } catch (FileNotFoundException fileNotFoundException) {
      Log.d(TAG, "Persisted config file was not found.", fileNotFoundException);
      return null;
    }

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
ckarthick-tnlcommented, Aug 26, 2020

@venkatn41

It would be something like below

implementation(Deps.Firebase.performance)
    {
        exclude(group = "com.google.protobuf", module="protobuf-java")
    }

Run ./gradlew :app:dependencies > dependencies.log on your project to understand which all libraries transitively dependend on protobuf.

0reactions
venkatn41commented, Aug 26, 2020

@ckarthick-tnl could you please share your configuration for exclude, I am also facing the same issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No static method combineMeasuredStates With ...
Finally, I resolved my issue by adding design library for bottom navigation view. Other library version are as it is. compileSdkVersion 27 buildToolsVersion ......
Read more >
java.lang.NoSuchMethodError: No static method parseString
when I use the library with java code to handle the bug of Android 12 and above I got this error when I...
Read more >
Java Error: Non-static Variable/Method X Cannot be Referenced
Attempting to access a non-static variable/method from a static context without a class instance creates ambiguity.
Read more >
Difference between static and non-static method in Java
A static method can only access static data members and static methods of another class or same class but cannot access non-static methods...
Read more >
Static vs. Non-Static Methods in Java - Study.com
In Java, methods can be static when belonging to a class, or non-static when an object of the class. Compare static and non-static...
Read more >

github_iconTop Related Medium Post

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