美文网首页
flutter 使用url_launcher插件报错 Could

flutter 使用url_launcher插件报错 Could

作者: Pino | 来源:发表于2023-11-28 09:33 被阅读0次

首先报这个错的原因是啥?
这个依赖库中使用了 androidx.annotation:annotation:1.7.0,
但指定的版本与你的项目中的其他库版本不一致,导致了版本冲突

image.png

解决办法

image.png
  configurations.all {
        resolutionStrategy {
            force 'androidx.annotation:annotation:1.1.0'
        }
    }

通过强制指定特定库的版本,可以确保与其他库的兼容性,并解决可能导致构建失败或运行时错误的问题
2023-12-13又遇到类似的问题
集成 google_maps_flutter: ^2.5.0
报错如下

Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Could not find com.google.android.gms:play-services-maps:18.2.0.
     Searched in the following locations:
     Required by:
         project :app > project :google_maps_flutter_android

很明显这个库肯定是冲突了 com.google.android.gms:play-services-maps:18.2.0
复制com.google.android.gms:play-services-maps 全局搜索,切换到scoqe,发现这个库google_maps_flutter: ^2.5.0
两个地方使用了不同版本的play-services-maps,一个是18.2.0一个17.0.0,这就是导致冲突的原因
说来也奇怪,另外一个同事和我一起开发的,完全没有这个问题,可以正常运行,不会报错,太邪门了


image.png

最后修改如下,强制使用18.0.2版本,为什么不用17.0.0或者18.2.0,我试了都不行,只能18.0.2,其他没有试了

configurations.all {
        resolutionStrategy {
            force 'androidx.annotation:annotation:1.1.0'
            force 'com.google.android.gms:play-services-maps:18.0.2'
        }
    }

这玩意太扯淡了

相关文章

网友评论

      本文标题:flutter 使用url_launcher插件报错 Could

      本文链接:https://www.haomeiwen.com/subject/siwtgdtx.html