登录

无法访问颤振项目中的类'com.google.common.util.concurrent.ListenableFuture‘

内容来源于 Stack Overflow,遵循 CC BY-SA 4.0 许可协议进行翻译与使用。IT领域专用引擎提供翻译支持

腾讯云小微IT领域专用引擎提供翻译支持

原文
Karzel 修改于2022-10-27
  • 该问题已被编辑
  • 提问者: Karzel
  • 提问时间: 2022-10-27 04:34

将一些依赖项添加到我的项目+将camerax依赖项 本地添加到颤振项目的android部分(我希望创建本地Android视图,然后在Flutter中显示它)。在构建项目时,我遇到了一个错误:

e: pathandroid/camera/AndroidCameraView.kt: (35, 58): Cannot access class 'com.google.common.util.concurrent.ListenableFuture'. Check your module classpath for missing or conflicting dependencies
        e: pathandroid/camera/AndroidCameraView.kt: (36, 9): Cannot access class 'com.google.common.util.concurrent.ListenableFuture'. Check your module classpath for missing or conflicting dependencies
        e: pathandroid/camera/AndroidCameraView.kt: (36, 30): Unresolved reference: addListener
        e: pathandroid/camera/AndroidCameraView.kt: (37, 30): Cannot access class 'com.google.common.util.concurrent.ListenableFuture'. Check your module classpath for missing or conflicting dependencies
        e: pathandroid/camera/AndroidCameraView.kt: (37, 51): Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
public operator fun MatchGroupCollection.get(name: String): MatchGroup? defined in kotlin.text

这些都指向这样的守则:

val cameraProviderFuture = ProcessCameraProvider.getInstance(context)
    cameraProviderFuture.addListener({
        cameraProvider = cameraProviderFuture.get()
        bindPreview(cameraProvider, lifecycleOwner)
    }, ContextCompat.getMainExecutor(context))

我已经生成了一棵依赖关系树,在多个项目/库中有如下行:

com.google.guava:guava:28.1-android -> 31.0.1-android
com.google.guava:listenablefuture:1.0 -> 9999.0-empty-to-avoid-conflict-with-guava
com.google.guava:listenablefuture:{strictly 9999.0-empty-to-avoid-conflict-with-guava} -> 9999.0-empty-to-avoid-conflict-with-guava (c)

所以我所做的就是添加到build.gradle中:

configurations.all {
        resolutionStrategy {