Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从java连接到Firebase时发生java.lang.NoSuchMethodError_Java_Maven_Firebase_Firebase Admin - Fatal编程技术网

从java连接到Firebase时发生java.lang.NoSuchMethodError

从java连接到Firebase时发生java.lang.NoSuchMethodError,java,maven,firebase,firebase-admin,Java,Maven,Firebase,Firebase Admin,我正在尝试将我的Java web项目连接到Firebase,以便能够将数据存储在Firestore中。我正在使用Java Admin SDK,遵循官方指南:。遗憾的是,我在初始化FirebaseAp时遇到了异常: java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkState(ZLjava/lang/String;Ljava/lang/Object;)V at com.google.firebase.Fir

我正在尝试将我的Java web项目连接到Firebase,以便能够将数据存储在Firestore中。我正在使用Java Admin SDK,遵循官方指南:。遗憾的是,我在初始化FirebaseAp时遇到了异常:

java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkState(ZLjava/lang/String;Ljava/lang/Object;)V
at com.google.firebase.FirebaseApp.checkNotDeleted(FirebaseApp.java:352)
at com.google.firebase.FirebaseApp.getOptions(FirebaseApp.java:267)
at com.google.firebase.FirebaseApp$TokenRefresher.<init>(FirebaseApp.java:434)
at com.google.firebase.FirebaseApp$TokenRefresher$Factory.create(FirebaseApp.java:535)
at com.google.firebase.FirebaseApp.<init>(FirebaseApp.java:113)
at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:201)
at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:188)

我甚至下载了google firebase sdk的github存储库,并删除了那里的所有guava代码引用,但在尝试读/写Firestore时,我也遇到了类似的错误。似乎其他一些google库也依赖于这个蹩脚的小罐子。

我对不同依赖项中的Guava版本也有同样的问题

我在Gradle这样解决了这个问题:

configurations.all {
    resolutionStrategy {
        force 'com.google.guava:guava:17.0'
    }
}
应该有一个Maven方法,否则从所有依赖项中排除Guava,并在您的版本中显式添加它

它在全球范围内强制执行番石榴版本。幸运的是,17版与我所有的依赖项都兼容。无论是16岁还是18岁以上都不是。。。可悲的是,他们用的是番石榴

希望有帮助,
关于

能否尝试在代码中的某个位置添加以下行,并查看它是否编译<代码>先决条件。检查状态(true,“,new Object())还有一个可能的修复程序正在开发中,您可以在其中尝试。
[INFO] Scanning for projects...
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-dependency-plugin/2.8/maven-dependency-plugin-2.8.pom
Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-dependency-plugin/2.8/maven-dependency-plugin-2.8.pom (11 kB at 18 kB/s)
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-dependency-plugin/2.8/maven-dependency-plugin-2.8.jar
Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-dependency-plugin/2.8/maven-dependency-plugin-2.8.jar (153 kB at 709 kB/s)
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building trekking-project 1.0
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for primefaces:primefaces:jar:5.3 is missing, no dependency information available
[WARNING] The POM for primefaces.blacktie:primefaces.blacktie:jar:1.0 is missing, no dependency information available
[WARNING] The POM for bootstrap:bootstrap:jar:1.0 is missing, no dependency information available
[WARNING] The POM for org.apache.commons.validator.routines.EmailValidatororg.apache.commons.validator.routines.EmailValidator:org.apache.commons.validator.routines.EmailValidator:jar:1.0 is missing, no dependency information available
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ trekking-project ---
Downloading from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-archiver/2.3/plexus-archiver-2.3.pom
Downloaded from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-archiver/2.3/plexus-archiver-2.3.pom (3.4 kB at 38 kB/s)
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-dependency-analyzer/1.4/maven-dependency-analyzer-1.4.pom
Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-dependency-analyzer/1.4/maven-dependency-analyzer-1.4.pom (5.2 kB at 58 kB/s)
Downloading from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-archiver/2.3/plexus-archiver-2.3.jar
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-dependency-analyzer/1.4/maven-dependency-analyzer-1.4.jar
Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-dependency-analyzer/1.4/maven-dependency-analyzer-1.4.jar (27 kB at 105 kB/s)
Downloaded from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-archiver/2.3/plexus-archiver-2.3.jar (186 kB at 704 kB/s)
[INFO] com.greenstudio:trekking-project:war:1.0
[INFO] +- com.google.firebase:firebase-admin:jar:5.6.0:compile
[INFO] |  +- com.google.api-client:google-api-client:jar:1.22.0:compile
[INFO] |  |  +- com.google.oauth-client:google-oauth-client:jar:1.22.0:compile
[INFO] |  |  \- com.google.http-client:google-http-client-jackson2:jar:1.22.0:compile
[INFO] |  |     \- com.fasterxml.jackson.core:jackson-core:jar:2.1.3:compile
[INFO] |  +- com.google.api-client:google-api-client-gson:jar:1.22.0:compile
[INFO] |  |  \- com.google.http-client:google-http-client-gson:jar:1.22.0:compile
[INFO] |  |     \- com.google.code.gson:gson:jar:2.1:compile
[INFO] |  +- com.google.http-client:google-http-client:jar:1.22.0:compile
[INFO] |  |  \- com.google.code.findbugs:jsr305:jar:1.3.9:compile
[INFO] |  +- com.google.api:api-common:jar:1.2.0:compile
[INFO] |  +- com.google.auth:google-auth-library-oauth2-http:jar:0.8.0:compile
[INFO] |  |  \- com.google.auth:google-auth-library-credentials:jar:0.8.0:compile
[INFO] |  +- com.google.cloud:google-cloud-storage:jar:1.7.0:compile
[INFO] |  |  +- com.google.cloud:google-cloud-core:jar:1.7.0:compile
[INFO] |  |  |  +- com.google.api:gax:jar:1.8.1:compile
[INFO] |  |  |  +- com.google.protobuf:protobuf-java-util:jar:3.3.1:compile
[INFO] |  |  |  +- com.google.api.grpc:proto-google-common-protos:jar:0.1.20:compile
[INFO] |  |  |  \- com.google.api.grpc:proto-google-iam-v1:jar:0.1.20:compile
[INFO] |  |  +- com.google.cloud:google-cloud-core-http:jar:1.7.0:compile
[INFO] |  |  |  +- com.google.http-client:google-http-client-appengine:jar:1.22.0:compile
[INFO] |  |  |  \- com.google.http-client:google-http-client-jackson:jar:1.22.0:compile
[INFO] |  |  |     \- org.codehaus.jackson:jackson-core-asl:jar:1.9.11:compile
[INFO] |  |  \- com.google.apis:google-api-services-storage:jar:v1-rev108-1.22.0:compile
[INFO] |  +- com.google.cloud:google-cloud-firestore:jar:0.25.0-beta:compile
[INFO] |  |  +- io.netty:netty-tcnative-boringssl-static:jar:2.0.3.Final:compile
[INFO] |  |  +- com.google.cloud:google-cloud-core-grpc:jar:1.7.0:compile
[INFO] |  |  |  +- com.google.protobuf:protobuf-java:jar:3.3.1:compile
[INFO] |  |  |  +- io.grpc:grpc-protobuf:jar:1.6.1:compile
[INFO] |  |  |  |  \- io.grpc:grpc-protobuf-lite:jar:1.6.1:compile
[INFO] |  |  |  \- io.grpc:grpc-context:jar:1.6.1:compile
[INFO] |  |  +- com.google.api:gax-grpc:jar:0.25.1:compile
[INFO] |  |  |  +- com.google.auto.value:auto-value:jar:1.2:compile
[INFO] |  |  |  \- org.threeten:threetenbp:jar:1.3.3:compile
[INFO] |  |  +- com.google.api.grpc:proto-google-cloud-firestore-v1beta1:jar:0.1.20:compile
[INFO] |  |  +- io.grpc:grpc-netty:jar:1.6.1:compile
[INFO] |  |  |  +- io.grpc:grpc-core:jar:1.6.1:compile (version selected from constraint [1.6.1,1.6.1])
[INFO] |  |  |  |  +- com.google.errorprone:error_prone_annotations:jar:2.0.19:compile
[INFO] |  |  |  |  +- com.google.instrumentation:instrumentation-api:jar:0.4.3:compile
[INFO] |  |  |  |  \- io.opencensus:opencensus-api:jar:0.5.1:compile
[INFO] |  |  |  +- io.netty:netty-codec-http2:jar:4.1.14.Final:compile (version selected from constraint [4.1.14.Final,4.1.14.Final])
[INFO] |  |  |  \- io.netty:netty-handler-proxy:jar:4.1.14.Final:compile
[INFO] |  |  |     \- io.netty:netty-codec-socks:jar:4.1.14.Final:compile
[INFO] |  |  +- io.grpc:grpc-stub:jar:1.6.1:compile
[INFO] |  |  \- io.grpc:grpc-auth:jar:1.6.1:compile
[INFO] |  +- org.json:json:jar:20160810:compile
[INFO] |  +- org.slf4j:slf4j-api:jar:1.7.25:compile
[INFO] |  +- io.netty:netty-codec-http:jar:4.1.14.Final:compile
[INFO] |  |  \- io.netty:netty-codec:jar:4.1.14.Final:compile
[INFO] |  +- io.netty:netty-handler:jar:4.1.14.Final:compile
[INFO] |  |  \- io.netty:netty-buffer:jar:4.1.14.Final:compile
[INFO] |  |     \- io.netty:netty-common:jar:4.1.14.Final:compile
[INFO] |  \- io.netty:netty-transport:jar:4.1.14.Final:compile
[INFO] |     \- io.netty:netty-resolver:jar:4.1.14.Final:compile
[INFO] +- com.google.guava:guava:jar:21.0:compile
[INFO] +- joda-time:joda-time:jar:2.9.9:compile
[INFO] +- org.eclipse.persistence:eclipselink:jar:2.5.2:provided
[INFO] |  +- org.eclipse.persistence:javax.persistence:jar:2.1.0:provided
[INFO] |  \- org.eclipse.persistence:commonj.sdo:jar:2.1.1:provided
[INFO] +- org.eclipse.persistence:org.eclipse.persistence.jpa.modelgen.processor:jar:2.5.2:provided
[INFO] |  +- org.eclipse.persistence:org.eclipse.persistence.core:jar:2.5.2:provided
[INFO] |  |  \- org.eclipse.persistence:org.eclipse.persistence.asm:jar:2.5.2:provided
[INFO] |  \- org.eclipse.persistence:org.eclipse.persistence.jpa:jar:2.5.2:provided
[INFO] |     +- org.eclipse.persistence:org.eclipse.persistence.antlr:jar:2.5.2:provided
[INFO] |     \- org.eclipse.persistence:org.eclipse.persistence.jpa.jpql:jar:2.5.2:provided
[INFO] +- org.apache.httpcomponents:httpcore:jar:4.3.3:compile
[INFO] +- org.apache.httpcomponents:httpclient:jar:4.3.6:compile
[INFO] |  +- commons-logging:commons-logging:jar:1.1.3:compile
[INFO] |  \- commons-codec:commons-codec:jar:1.6:compile
[INFO] +- primefaces:primefaces:jar:5.3:compile
[INFO] +- primefaces.blacktie:primefaces.blacktie:jar:1.0:compile
[INFO] +- bootstrap:bootstrap:jar:1.0:compile
[INFO] +- org.apache.commons.validator.routines.EmailValidatororg.apache.commons.validator.routines.EmailValidator:org.apache.commons.validator.routines.EmailValidator:jar:1.0:compile
[INFO] \- javax:javaee-web-api:jar:7.0:provided
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.897 s
[INFO] Finished at: 2018-01-12T10:16:59+01:00
[INFO] Final Memory: 15M/215M
[INFO] ------------------------------------------------------------------------
configurations.all {
    resolutionStrategy {
        force 'com.google.guava:guava:17.0'
    }
}