Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 657
Владимир Фишер Avatar asked Feb 11 '21 12:02

Владимир Фишер


1 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")
    }
like image 188
Amir Avatar answered Nov 16 '22 19:11

Amir