java.lang.NoSuchMethodError: No static method registerDefaultInstance with Firebase Performance and Espresso Instrumented Tests

Viewed 3065

When I adding implementation 'com.google.firebase:firebase-perf-ktx:19.1.0' I cannot start espresso instrumented tests ("app" scheme building ok). When I trying to start Espresso test, I have

Test running failed: Process crashed.
java.lang.NoSuchMethodError: No static method registerDefaultInstance(Ljava/lang/Class;Lcom/google/protobuf/GeneratedMessageLite;)V in class Lcom/google/protobuf/GeneratedMessageLite

But if I'm deleting implementation 'com.google.firebase:firebase-perf-ktx:19.1.0' everything working fine. How to keep Firebase Performance library and Espresso Instrumented tests?

4 Answers

In my case it seems to be caused by protobuf-lite:3.0.1 dependency from recently updated androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.4.0' which I was able to fix with this exclude

androidTestImplementation (androidx.test.espresso:espresso-contrib:3.4.0'){
    exclude module: "protobuf-lite"
}

In case of KTX

testImplementation('androidx.test.espresso:espresso-contrib:3.4.0') {
        exclude(module = "protobuf-lite")
    }

This is work:

androidTestImplementation("androidx.test.espresso:espresso-contrib:3.4.0") 
{
    exclude(group: "com.google.protobuf", module: "protobuf-lite")
}

This is work:

androidTestImplementation('androidx.test.espresso:espresso-contrib:3.4.0') {
exclude module: "protobuf-lite"

} androidTestImplementation ('androidx.test.espresso:espresso-accessibility:3.4.0') { exclude module: "protobuf-lite" }

Related