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:
- Install the app that uses older LegacyConfigHandler-PersistedConfig
- Update the app to latest Firebase SDK that stores values as JSON
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,
- The olders SDKs store the config as
PersistedConfig
probably using google ptorobuf config. - 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:
- Created 3 years ago
- Reactions:2
- Comments:10 (1 by maintainers)
Top 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 >Top Related Medium Post
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@venkatn41
It would be something like below
Run
./gradlew :app:dependencies > dependencies.log
on your project to understand which all libraries transitively dependend on protobuf.@ckarthick-tnl could you please share your configuration for exclude, I am also facing the same issue.