在向我的專案添加一些依賴項 將 camerax 依賴項本地添加到 Flutter 專案的 android 部分之后(我想創建 Native 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'
}
按照這個答案,也嘗試過這種方法。沒有任何效果。
我想知道它是否與 Flutter 如何構建它的專案有關。它如何構建它傳遞使用的所有必要的本機依賴項。在我的專案 build.gradle 中添加此配置力是否足夠?或者這還不夠,它不會影響“從顫振代碼”添加的包?是否有一些額外的步驟/方法來處理 Flutter 專案中的依賴沖突?
uj5u.com熱心網友回復:
發布一個問題后,我實際上能夠弄清楚。上面提到的 SO 問題的建議幾乎是正確的,但在我的情況下,我需要添加到原生 android 依賴項中的app build.gradle是整個番石榴:
implementation "com.google.guava:guava:31.0.1-android"
之后構建成功通過。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/526359.html
上一篇:使用代理時Gradle包裝器超時
