GAS +云存储+番石榴= appspot上的NoSuchMethodError吗? [英] GAE + Cloud Storage + Guava = NoSuchMethodError on appspot?
问题描述
将我的GAE应用程序部署到appspot之后,我不断从API请求中收到以下错误: NoSuchMethodError:com.google.common.hash.Hashing.crc32c()Lcom/google/common/hash/HashFunction;
After deploying my GAE application to appspot, I keep getting the following error from an API request: NoSuchMethodError: com.google.common.hash.Hashing.crc32c()Lcom/google/common/hash/HashFunction;
在本地运行时,我没有任何错误.调用时抛出错误: com.google.cloud.storage.StorageOptions.getDefaultInstance().getService().create
I don't get any errors when running locally. The error is thrown when calling: com.google.cloud.storage.StorageOptions.getDefaultInstance().getService().create
我已经尝试了Guava 18-20版本,并且正在运行Java 7,具有以下依赖关系:
I've tried Guava versions 18-20 and am running Java 7 with the following dependencies:
dependencies {
appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.53'
compile 'com.google.appengine:appengine-endpoints:1.9.53'
compile 'com.google.appengine:appengine-endpoints-deps:1.9.53'
compile 'com.google.appengine.tools:appengine-gcs-client:0.6'
compile 'com.google.api-client:google-api-client:1.22.0'
compile 'com.google.guava:guava:20.0'
compile 'com.google.cloud:google-cloud-storage:1.0.1'
compile 'com.googlecode.objectify:objectify:5.1.1'
compile 'javax.servlet:servlet-api:2.5'
compile 'org.jsoup:jsoup:1.10.2'
}
感谢您的帮助!
推荐答案
我最终发现了这个问题...
I did eventually figured this out...
我正在使用Google Cloud Storage库(com.google.appengine.tools:appengine-gcs-client:0.6),该库使用的guava-jdk5库与我使用的Guava版本冲突;HashFunction在Guava的jdk5版本中不存在.
I was using the Google Cloud Storage library (com.google.appengine.tools:appengine-gcs-client:0.6) which uses the guava-jdk5 library, which was conflicting with the version of Guava I was using; the HashFunction doesn't exist in the jdk5 version(s) of Guava.
解决方案是从Google Cloud Storage库导入中排除guava-jdk5.我的.gradle文件的相关部分如下所示:
The solution was to exclude guava-jdk5 from Google Cloud Storage library import. The relevant portion of my .gradle file looks like the following:
compile 'com.google.guava:guava:19.0'
compile ('com.google.appengine.tools:appengine-gcs-client:0.6') {
exclude group: 'com.google.guava', module: 'guava-jdk5'
}
对于其他人来说,冲突可能是由其他库造成的,因此请务必检查库中的依赖项,以查看您尝试使用的Guava版本是否存在冲突.
For others, it's possible that the conflict is being created by a different library so be sure to check the dependencies on your libraries to see if there's a conflict with the version of Guava you're trying to use.
这篇关于GAS +云存储+番石榴= appspot上的NoSuchMethodError吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!