NoSuchMethodError:没有静态方法捕获(Lcom / google / common / util / concurrent / ListenableFuture

时间:2018-10-27 15:11:22

标签: android google-api google-api-client google-photos-api android-guava

我想使用google-api-client将照片上传到Google-Photo。这是我的代码:

渐变文件:

while(true)...

初始化照片客户端:

    api 'com.google.api-client:google-api-client:1.26.0'
    api 'com.google.api-client:google-api-client-android:1.26.0'
    api 'io.grpc:grpc-okhttp:1.16.1'
    api 'com.google.photos.library:google-photos-library-client:1.0.1'
    api 'com.google.android.gms:play-services-auth:16.0.1'
    api 'com.google.android.gms:play-services-drive:16.0.0'

uploadFile:

private fun initializePhotoClient(): PhotosLibraryClient? {
    val token = authRepository.getAccessToken()
    val credentials = googleAuth.getUserCredentials(token) ?: return null
    val settings = PhotosLibrarySettings.newBuilder()
            .setCredentialsProvider { credentials }.build()
    return PhotosLibraryClient.initialize(settings)
}

val fileName = localFileProvider.getFileName(uri) val uploadRequest = UploadMediaItemRequest.newBuilder() .setFileName(fileName) .setDataFile(RandomAccessFile(uri, "r")) .build() val uploadResponse = photosLibraryClient.uploadMediaItem(uploadRequest) 方法始终返回错误,如下所示。有谁知道如何解决这一问题?请给我一个提示。

uploadMediaItem

已更新:添加用于将photosLibraryClient初始化为@Ricardo的函数。照片客户端可以正常创建我的相册

1 个答案:

答案 0 :(得分:0)

降级grpc-okhttp库使其对我有用。 我使用此版本:

implementation 'io.grpc:grpc-okhttp:1.15.1'

此后,Future类中的某些内容必须已更改,并且Google Photos库尚未更新以使用更改。