首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >无法访问颤振项目中的类'com.google.common.util.concurrent.ListenableFuture‘

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

Stack Overflow用户
提问于 2022-10-27 04:34:49
回答 1查看 102关注 0票数 0

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

代码语言:javascript
运行
复制
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

这些都指向这样的守则:

代码语言:javascript
运行
复制
val cameraProviderFuture = ProcessCameraProvider.getInstance(context)
    cameraProviderFuture.addListener({
        cameraProvider = cameraProviderFuture.get()
        bindPreview(cameraProvider, lifecycleOwner)
    }, ContextCompat.getMainExecutor(context))

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

代码语言:javascript
运行
复制
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中:

代码语言:javascript
运行
复制
configurations.all {
        resolutionStrategy {
            force 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'
            force 'com.google.guava:guava:31.0.1-android'
        }
    }

在常规的android项目中,我希望它能正常工作。但对我来说不幸的是,事实并非如此。添加这些行后,仍然会出现相同的问题。然后我也尝试了:

代码语言:javascript
运行
复制
configurations.all {
    all*.exclude group: 'com.google.guava', module: 'listenablefuture'
}

遵循this的答案,也尝试了this方法。什么都没用。

我想知道这是否与颤振如何构建它的项目有关。如何构建它使用的所有必要的本机依赖关系。在我的项目build.gradle中添加此配置强制是否足够?或者,这还不够,它不会影响“从颤振代码”添加的包?是否有其他步骤/方法来处理颤振项目中的依赖冲突?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-10-27 04:54:49

在贴出一个问题之后,我才真正想出了答案。来自SO question mentioned above的建议几乎是正确的,但在我的例子中,我需要在app build.gradle中添加到本地android依赖项中的是整个番石榴:

代码语言:javascript
运行
复制
implementation "com.google.guava:guava:31.0.1-android"

在该构建成功通过之后。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74216853

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档