Kar*_*zel 15 android gradle guava flutter flutter-dependencies
在向我的项目添加一些依赖项+将camerax依赖项本机添加到Flutter项目的android部分之后(我想创建本机Android视图,然后在Flutter中显示它)。构建项目时,我\xe2\x80\x99ve遇到错误:
\ne: pathandroid/camera/AndroidCameraView.kt: (35, 58): Cannot access class \'com.google.common.util.concurrent.ListenableFuture\'. Check your module classpath for missing or conflicting dependencies\n 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\n e: pathandroid/camera/AndroidCameraView.kt: (36, 30): Unresolved reference: addListener\n 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\n e: pathandroid/camera/AndroidCameraView.kt: (37, 51): Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:\npublic operator fun MatchGroupCollection.get(name: String): MatchGroup? defined in kotlin.text\nRun Code Online (Sandbox Code Playgroud)\n那些指向这样的代码:
\nval cameraProviderFuture = ProcessCameraProvider.getInstance(context)\n cameraProviderFuture.addListener({\n cameraProvider = cameraProviderFuture.get()\n bindPreview(cameraProvider, lifecycleOwner)\n }, ContextCompat.getMainExecutor(context))\nRun Code Online (Sandbox Code Playgroud)\nI\xe2\x80\x99ve 生成了依赖关系树,并且在多个项目/库中存在如下行:
\ncom.google.guava:guava:28.1-android -> 31.0.1-android\ncom.google.guava:listenablefuture:1.0 -> 9999.0-empty-to-avoid-conflict-with-guava\ncom.google.guava:listenablefuture:{strictly 9999.0-empty-to-avoid-conflict-with-guava} -> 9999.0-empty-to-avoid-conflict-with-guava (c)\nRun Code Online (Sandbox Code Playgroud)\n所以我所做的就是添加到 build.gradle 中:
\nconfigurations.all {\n resolutionStrategy {\n force \'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava\'\n force \'com.google.guava:guava:31.0.1-android\'\n }\n }\nRun Code Online (Sandbox Code Playgroud)\n在常规的 Android 项目中,我希望它能够工作。但对我来说不幸的是它没有。添加这些行后,仍然出现相同的问题。\n然后我也尝试过:
\nconfigurations.all {\n all*.exclude group: \'com.google.guava\', module: \'listenablefuture\'\n}\nRun Code Online (Sandbox Code Playgroud)\n\n我\xe2\x80\x99m想知道它\xe2\x80\x99s是否与Flutter如何构建\xe2\x80\x99s项目有关。它如何构建它传递使用的所有必要的本机依赖项。\n在我的项目 build.gradle 中添加此配置是否足够?或者也许它\xe2\x80\x99s还不够,它不会\xe2\x80\x99t影响从flutter代码\xe2\x80\x9d添加的\xe2\x80\x9c的包?\n是否有一些额外的步骤/处理方法Flutter项目中的依赖冲突?
\nKar*_*zel 40
发布问题后,我实际上能够弄清楚。上面提到的SO问题的建议几乎是正确的,但就我而言,我需要添加到本机android依赖项中的app build.gradle是整个番石榴:
implementation "com.google.guava:guava:31.0.1-android"
Run Code Online (Sandbox Code Playgroud)
之后构建成功通过。
| 归档时间: |
|
| 查看次数: |
7222 次 |
| 最近记录: |