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?
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")
}
It looks like you might need to modify how you specify your dependency and use something like this:
implementation(Deps.Firebase.performance)
{
exclude(group = "com.google.protobuf", module="protobuf-java")
}
Source:
https://github.com/firebase/firebase-android-sdk/issues/1907
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" }
As pointed out, it's the protobuf-lite runtime, which is coming with androidx.test.espresso:espresso-contrib dep.
When inspecting dependencies, it seems that this dep comes in play when running Instumentation test in debug mode (debugAndroidTestRuntimeClasspath)
./gradlew app:dependencies
Adding following line in apps build.gradle will exclude it on debugAndroidTestRuntimeClasspath configuration and your test should be running fine again:)
configurations
{
debugAndroidTestRuntimeClasspath.exclude group: 'com.google.protobuf' module: 'protobuf-lite'
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.