安卓Firebase库,仪表化测试-无静电方法registerDefaultInstance(Ljava/lang/Class;Lcom/google/protobuf/GeneratedMessageLite

Android Firebase Libraries, Instrumented Test - No static method registerDefaultInstance(Ljava/lang/Class;Lcom/google/protobuf/GeneratedMessageLite(安卓Firebase库,仪表化测试-无静电方法registerDefaultInstance(Ljava/lang/Class;Lcom/google/protobuf/GeneratedMessageLite)

本文介绍了安卓Firebase库,仪表化测试-无静电方法registerDefaultInstance(Ljava/lang/Class;Lcom/google/protobuf/GeneratedMessageLite的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试在Android Studio中运行指令插入的测试会导致

Test running failed: Process crashed.

在logcat中详细介绍

E: FATAL EXCEPTION: main
    Process: com.nikolam.colorme.debug, PID: 19841
    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 /data/app/com.nikolam.colorme.debug.test-lZqsu6pVWp2DVtFzU1uYgg==/base.apk)
        at com.google.firebase.perf.v1.ApplicationInfo.<clinit>(ApplicationInfo.java:1085)
        at com.google.firebase.perf.v1.ApplicationInfo.newBuilder(ApplicationInfo.java:533)
        at com.google.firebase.perf.transport.TransportManager.<init>(TransportManager.java:139)
        at com.google.firebase.perf.transport.TransportManager.<clinit>(TransportManager.java:91)
        at com.google.firebase.perf.transport.TransportManager.getInstance(TransportManager.java:149)
        at com.google.firebase.perf.internal.AppStateMonitor.getInstance(AppStateMonitor.java:64)
        at com.google.firebase.perf.provider.FirebasePerfProvider.attachInfo(FirebasePerfProvider.java:65)
        at android.app.ActivityThread.installProvider(ActivityThread.java:6983)
        at android.app.ActivityThread.installContentProviders(ActivityThread.java:6528)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6445)
        at android.app.ActivityThread.access$1300(ActivityThread.java:219)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1859)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

我找到的最接近的是this issue on github,但是我尝试了多种设置,以便从我的依赖项中排除协议buf java。我试图将其从所有项目中排除,仅从app模块中排除,从除app模块之外的所有模块中排除,等等。我在多个模块中使用Firebase性能。

我尝试查找protobuf-java,这里是我找到它的位置

lintClassPath - The lint embedded classpath
--- com.android.tools.lint:lint-gradle:27.1.0
     +--- com.android.tools:sdk-common:27.1.0
     |    +--- com.android.tools:sdklib:27.1.0
     |    |    +--- com.android.tools.layoutlib:layoutlib-api:27.1.0
     |    |    |    +--- com.android.tools:common:27.1.0
     |    |    |    |    +--- com.android.tools:annotations:27.1.0
     |    |    |    |    +--- com.google.guava:guava:28.1-jre
     |    |    |    |    |    +--- com.google.guava:failureaccess:1.0.1
     |    |    |    |    |    +--- com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava
     |    |    |    |    |    +--- com.google.code.findbugs:jsr305:3.0.2
     |    |    |    |    |    +--- org.checkerframework:checker-qual:2.8.1
     |    |    |    |    |    +--- com.google.errorprone:error_prone_annotations:2.3.2
     |    |    |    |    |    +--- com.google.j2objc:j2objc-annotations:1.3
     |    |    |    |    |    --- org.codehaus.mojo:animal-sniffer-annotations:1.18
     |    |    |    |    --- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.72
     |    |    |    |         +--- org.jetbrains.kotlin:kotlin-stdlib:1.3.72
     |    |    |    |         |    +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.72
     |    |    |    |         |    --- org.jetbrains:annotations:13.0
     |    |    |    |         --- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.72
     |    |    |    |              --- org.jetbrains.kotlin:kotlin-stdlib:1.3.72 (*)
     |    |    |    +--- net.sf.kxml:kxml2:2.3.0
     |    |    |    +--- com.android.tools:annotations:27.1.0
     |    |    |    --- org.jetbrains:annotations:13.0
     |    |    +--- com.android.tools:dvlib:27.1.0
     |    |    |    --- com.android.tools:common:27.1.0 (*)
     |    |    +--- com.android.tools:repository:27.1.0
     |    |    |    +--- com.android.tools:common:27.1.0 (*)
     |    |    |    +--- com.sun.activation:javax.activation:1.2.0
     |    |    |    +--- org.apache.commons:commons-compress:1.12
     |    |    |    +--- org.glassfish.jaxb:jaxb-runtime:2.3.1
     |    |    |    |    +--- javax.xml.bind:jaxb-api:2.3.1
     |    |    |    |    |    --- javax.activation:javax.activation-api:1.2.0
     |    |    |    |    +--- org.glassfish.jaxb:txw2:2.3.1
     |    |    |    |    +--- com.sun.istack:istack-commons-runtime:3.0.7
     |    |    |    |    +--- org.jvnet.staxex:stax-ex:1.8
     |    |    |    |    +--- com.sun.xml.fastinfoset:FastInfoset:1.2.15
     |    |    |    |    --- javax.activation:javax.activation-api:1.2.0
     |    |    |    +--- com.google.jimfs:jimfs:1.1
     |    |    |    |    --- com.google.guava:guava:18.0 -> 28.1-jre (*)
     |    |    |    --- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.72 (*)
     |    |    +--- com.google.code.gson:gson:2.8.5
     |    |    +--- org.apache.commons:commons-compress:1.12
     |    |    +--- org.apache.httpcomponents:httpmime:4.5.6
     |    |    |    --- org.apache.httpcomponents:httpclient:4.5.6
     |    |    |         +--- org.apache.httpcomponents:httpcore:4.4.10
     |    |    |         +--- commons-logging:commons-logging:1.2
     |    |    |         --- commons-codec:commons-codec:1.10
     |    |    --- org.apache.httpcomponents:httpcore:4.4.10
     |    +--- com.android.tools.build:builder-test-api:4.1.0
     |    |    --- com.android.tools.ddms:ddmlib:27.1.0
     |    |         +--- com.android.tools:common:27.1.0 (*)
     |    |         +--- net.sf.kxml:kxml2:2.3.0
     |    |         --- com.google.protobuf:protobuf-java:3.10.0
     |    +--- com.android.tools.build:builder-model:4.1.0
     |    |    +--- com.android.tools:annotations:27.1.0
     |    |    --- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.72 (*)
     |    +--- com.android.tools.ddms:ddmlib:27.1.0 (*)
     |    +--- com.android.tools.analytics-library:shared:27.1.0
     |    |    +--- com.android.tools.analytics-library:protos:27.1.0
     |    |    |    --- com.google.protobuf:protobuf-java:3.10.0
     |    |    +--- com.android.tools:annotations:27.1.0
     |    |    +--- com.android.tools:common:27.1.0 (*)
     |    |    +--- com.google.guava:guava:28.1-jre (*)
     |    |    +--- com.google.code.gson:gson:2.8.5
     |    |    --- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.72 (*)
     |    +--- org.bouncycastle:bcpkix-jdk15on:1.56
     |    |    --- org.bouncycastle:bcprov-jdk15on:1.56
     |    +--- org.bouncycastle:bcprov-jdk15on:1.56
     |    +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.72 (*)
     |    +--- org.jetbrains.kotlin:kotlin-reflect:1.3.72
     |    |    --- org.jetbrains.kotlin:kotlin-stdlib:1.3.72 (*)
     |    +--- com.google.protobuf:protobuf-java:3.10.0  -- HERE 
     |    +--- javax.inject:javax.inject:1
     |    +--- org.jetbrains.trove4j:trove4j:20160824
     |    --- com.android.tools.build:aapt2-proto:4.1.0-alpha01-6193524
     |         --- com.google.protobuf:protobuf-java:3.10.0 -- HERE 
     +--- com.android.tools.build:builder:4.1.0
     |    +--- com.android.tools.build:builder-model:4.1.0 (*)
     |    +--- com.android.tools.build:builder-test-api:4.1.0 (*)
     |    +--- com.android.tools:sdklib:27.1.0 (*)
     |    +--- com.android.tools:sdk-common:27.1.0 (*)
     |    +--- com.android.tools:common:27.1.0 (*)
     |    +--- com.android.tools.build:manifest-merger:27.1.0
     |    |    +--- com.android.tools:common:27.1.0 (*)
     |    |    +--- com.android.tools:sdklib:27.1.0 (*)
     |    |    +--- com.android.tools:sdk-common:27.1.0 (*)
     |    |    +--- com.google.code.gson:gson:2.8.5
     |    |    +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.72 (*)
     |    |    --- net.sf.kxml:kxml2:2.3.0
     |    +--- com.android.tools.ddms:ddmlib:27.1.0 (*)
     |    +--- com.android:zipflinger:4.1.0
     |    |    --- com.android.tools:common:27.1.0 (*)
     |    +--- com.android:signflinger:4.1.0
     |    |    +--- com.android.tools.build:apksig:4.1.0
     |    |    --- com.android:zipflinger:4.1.0 (*)
     |    +--- com.android.tools.analytics-library:protos:27.1.0 (*)
     |    +--- com.android.tools.analytics-library:tracker:27.1.0
     |    |    +--- com.android.tools:annotations:27.1.0
     |    |    +--- com.android.tools:common:27.1.0 (*)
     |    |    +--- com.android.tools.analytics-library:protos:27.1.0 (*)
     |    |    +--- com.android.tools.analytics-library:shared:27.1.0 (*)
     |    |    +--- com.google.protobuf:protobuf-java:3.10.0
     |    |    +--- com.google.guava:guava:28.1-jre (*)
     |    |    --- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.72 (*)
     |    +--- com.android.tools.build:apksig:4.1.0
     |    +--- com.android.tools.build:apkzlib:4.1.0
     |    |    +--- com.google.code.findbugs:jsr305:1.3.9 -> 3.0.2
     |    |    +--- com.google.guava:guava:23.0 -> 28.1-jre (*)
     |    |    +--- org.bouncycastle:bcpkix-jdk15on:1.56 (*)
     |    |    +--- org.bouncycastle:bcprov-jdk15on:1.56
     |    |    --- com.android.tools.build:apksig:4.1.0
     |    +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.72 (*)
     |    +--- com.squareup:javawriter:2.5.0
     |    +--- org.bouncycastle:bcpkix-jdk15on:1.56 (*)
     |    +--- org.bouncycastle:bcprov-jdk15on:1.56
     |    +--- org.ow2.asm:asm:7.0
     |    +--- org.ow2.asm:asm-tree:7.0
     |    |    --- org.ow2.asm:asm:7.0
     |    +--- javax.inject:javax.inject:1
     |    +--- org.ow2.asm:asm-commons:7.0
     |    |    +--- org.ow2.asm:asm:7.0
     |    |    +--- org.ow2.asm:asm-tree:7.0 (*)
     |    |    --- org.ow2.asm:asm-analysis:7.0
     |    |         --- org.ow2.asm:asm-tree:7.0 (*)
     |    +--- org.ow2.asm:asm-util:7.0
     |    |    +--- org.ow2.asm:asm:7.0
     |    |    +--- org.ow2.asm:asm-tree:7.0 (*)
     |    |    --- org.ow2.asm:asm-analysis:7.0 (*)
     |    +--- it.unimi.dsi:fastutil:7.2.0
     |    +--- net.sf.jopt-simple:jopt-simple:4.9
     |    --- com.googlecode.json-simple:json-simple:1.1
     +--- com.android.tools.build:builder-model:4.1.0 (*)
     +--- com.android.tools.external.com-intellij:intellij-core:27.1.0
     |    --- org.jetbrains.trove4j:trove4j:20160824
     +--- com.android.tools.external.com-intellij:kotlin-compiler:27.1.0
     +--- com.android.tools.external.org-jetbrains:uast:27.1.0
     +--- com.android.tools.build:manifest-merger:27.1.0 (*)
     +--- com.android.tools.lint:lint:27.1.0
     |    +--- com.android.tools.lint:lint-checks:27.1.0
     |    |    +--- com.android.tools.lint:lint-api:27.1.0
     |    |    |    +--- com.android.tools:sdk-common:27.1.0 (*)
     |    |    |    +--- com.android.tools.lint:lint-model:27.1.0
     |    |    |    |    +--- com.android.tools:common:27.1.0 (*)
     |    |    |    |    +--- com.android.tools:sdk-common:27.1.0 (*)
     |    |    |    |    +--- com.android.tools.build:builder-model:4.1.0 (*)
     |    |    |    |    +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.72 (*)
     |    |    |    |    --- net.sf.kxml:kxml2:2.3.0
     |    |    |    +--- com.google.guava:guava:28.1-jre (*)
     |    |    |    +--- com.android.tools.external.com-intellij:intellij-core:27.1.0 (*)
     |    |    |    +--- com.android.tools.external.com-intellij:kotlin-compiler:27.1.0
     |    |    |    +--- com.android.tools.external.org-jetbrains:uast:27.1.0
     |    |    |    +--- com.android.tools.build:manifest-merger:27.1.0 (*)
     |    |    |    +--- org.ow2.asm:asm:7.0
     |    |    |    +--- org.ow2.asm:asm-tree:7.0 (*)
     |    |    |    +--- org.jetbrains.kotlin:kotlin-reflect:1.3.72 (*)
     |    |    |    +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.72 (*)
     |    |    |    --- com.android.tools.build:builder-model:4.1.0 (*)
     |    |    +--- com.google.guava:guava:28.1-jre (*)
     |    |    +--- com.android.tools.external.com-intellij:intellij-core:27.1.0 (*)
     |    |    +--- com.android.tools.external.com-intellij:kotlin-compiler:27.1.0
     |    |    +--- com.android.tools.external.org-jetbrains:uast:27.1.0
     |    |    --- org.ow2.asm:asm-analysis:7.0 (*)
     |    +--- com.google.guava:guava:28.1-jre (*)
     |    +--- com.android.tools.external.org-jetbrains:uast:27.1.0
     |    +--- com.android.tools.external.com-intellij:kotlin-compiler:27.1.0
     |    +--- com.android.tools.build:manifest-merger:27.1.0 (*)
     |    +--- com.android.tools.analytics-library:shared:27.1.0 (*)
     |    +--- com.android.tools.analytics-library:protos:27.1.0 (*)
     |    +--- com.android.tools.analytics-library:tracker:27.1.0 (*)
     |    +--- org.jetbrains.kotlin:kotlin-reflect:1.3.72 (*)
     |    --- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.72 (*)
     +--- com.android.tools.lint:lint-gradle-api:27.1.0
     |    +--- com.android.tools:sdklib:27.1.0 (*)
     |    +--- com.android.tools.lint:lint-model:27.1.0 (*)
     |    +--- com.android.tools.build:gradle-api:4.1.0
     |    |    +--- com.android.tools.build:builder-test-api:4.1.0 (*)
     |    |    +--- com.google.guava:guava:28.1-jre (*)
     |    |    --- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.72 (*)
     |    +--- org.jetbrains.kotlin:kotlin-reflect:1.3.72 (*)
     |    +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.72 (*)
     |    --- com.google.guava:guava:28.1-jre (*)
     +--- com.android:zipflinger:4.1.0 (*)
     +--- org.codehaus.groovy:groovy-all:2.4.15
     +--- org.jetbrains.kotlin:kotlin-reflect:1.3.72 (*)
     --- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.72 (*)

其他Firebase库依赖于

com.google.protobuf:protobuf-javalite:3.14.0

整个ependencies.log很大,我不知道如何发布它

推荐答案

在我的情况下,它似乎是由最近更新的androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.4.0'依赖项引起的,我可以通过此排除修复

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

并且它可以满足我的需要(我仅将此库用于DrawerActions),但它不是非常优雅的解决方案。

考虑到您的帖子日期,它可能是由其他原因引起的(因为提到的库是在几天前更新的),除非您使用的是某个Alpha版本。

我建议检查Gradle文件中最近更新的依赖项。您还可以比较./gradlew :app:dependencies | grep protobuf在该依赖关系更改前后的输出差异,然后检查完整的依赖关系树以查找原因。

这篇关于安卓Firebase库,仪表化测试-无静电方法registerDefaultInstance(Ljava/lang/Class;Lcom/google/protobuf/GeneratedMessageLite的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:安卓Firebase库,仪表化测试-无静电方法registerDefaultInstance(Ljava/lang/Class;Lcom/google/protobuf/GeneratedMessageLite

基础教程推荐