【问题标题】:Android gradle exclude does not work as expectedAndroid gradle exclude 无法按预期工作
【发布时间】:2019-11-19 18:53:24
【问题描述】:

我正在开发一个 React Native 项目并使用第三方库 react-native-geolocation-service。在该库的 build.gradle 文件中,play-services-location 的版本定义如下:(请参阅this link 了解整个 build.gradle 文件)

dependencies {
    def googlePlayServicesVersion = rootProject.hasProperty('googlePlayServicesVersion') ? rootProject.googlePlayServicesVersion : DEFAULT_GOOGLE_PLAY_SERVICES_VERSION

    implementation "com.google.android.gms:play-services-location:$googlePlayServicesVersion"
}

在我的项目的 build.gradle 文件中,我有以下内容:

buildscript {
    ext {
        ...
        googlePlayServicesVersion = "16.1.0"
    }
}

在我的项目的 app/build.gradle 文件中:

dependencies {
    implementation(project(':react-native-geolocation-service')) {
        exclude group: 'com.google.android.gms', module: 'play-services-location'
    }
    implementation ('com.google.android.gms:play-services-location:16.0.0') {
      force = true
    }
}

即使我在 gradle 文件中指定使用 16.0.0 版本作为 play-services-location,我在运行 gradlew clean 然后运行 ​​gradlew build 后仍然收到以下错误:

任务 ':react-native-geolocation-service:generateDebugRFile' 执行失败。

无法解析配置“:react-native-geolocation-service:debugRuntimeClasspath”的所有文件。

找不到 com.google.android.gms:play-services-location:16.1.0。

为什么 gradle 还在寻找 16.1.0 版而不是 16.0.0 版?

【问题讨论】:

    标签: android react-native gradle


    【解决方案1】:

    如果您要查看来自Here 的发行说明。

    2019 年 6 月 17 日

    发布是

    com.google.android.gms:play-services-location:17.0.0
    

    2018 年 10 月 2 日

    发布是

    com.google.android.gms:play-services-location:16.0.0
    

    因此,位置

    没有发布版本 16.1.0

    【讨论】:

    • 是的,我知道位置没有 16.1.0 版本,因此我尝试使用 exclude 和 force = true 在我的 build.gradle 文件中强制使用 16.0.0。但由于一些我无法理解的原因,gradle 仍在寻找 16.1.0
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-14
    • 2023-03-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-19
    相关资源
    最近更新 更多