将一些依赖项添加到我的项目+将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 {
force 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'
force 'com.google.guava:guava:31.0.1-android'
}
}在常规的android项目中,我希望它能正常工作。但对我来说不幸的是,事实并非如此。添加这些行后,仍然会出现相同的问题。然后我也尝试了:
configurations.all {
all*.exclude group: 'com.google.guava', module: 'listenablefuture'
}我想知道这是否与颤振如何构建它的项目有关。如何构建它使用的所有必要的本机依赖关系。在我的项目build.gradle中添加此配置强制是否足够?或者,这还不够,它不会影响“从颤振代码”添加的包?是否有其他步骤/方法来处理颤振项目中的依赖冲突?
发布于 2022-10-27 04:54:49
在贴出一个问题之后,我才真正想出了答案。来自SO question mentioned above的建议几乎是正确的,但在我的例子中,我需要在app build.gradle中添加到本地android依赖项中的是整个番石榴:
implementation "com.google.guava:guava:31.0.1-android"在该构建成功通过之后。
https://stackoverflow.com/questions/74216853
复制相似问题