java - Build Gradle 依赖项中的库版本 28 和 26.1 不兼容

标签 java android google-api android-sdk-tools

我正在尝试制作一个使用谷歌地图 API 的应用程序。

但是库方面似乎存在错误,不兼容。

它说

'Found versions 28.0.0 and 26.1.0 examples including com.android.support:animated_vector_drawable:28.0.0 and com.android.support:support-media-compact:26.1.0

这会对调用 R.id 产生影响吗?

我尝试过清理和重建,以及无效的缓存重置。 我尝试将文件添加为依赖项版本 28.0.0,但收到 2 个错误:

Failed to resolve: com.android.support:support-media-compact:28.0.0 Failed to resolve: com.android

dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        implementation 'com.android.support:appcompat-v7:28.0.0'
        implementation 'com.android.support:support-media-compact:28.0.0'
        implementation 'com.android.support:animated_vector_drawable:28.0.0'
        implementation 'com.android.support.constraint:constraint-layout:1.1.3'
        implementation 'com.android.support:design:28.0.0'
        implementation 'com.google.android.gms:play-services-location:16.0.0'
        implementation 'com.google.android.gms:play-services-maps:16.0.0'
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'com.android.support.test:runner:1.0.2'
        androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

我本以为重写版本可以解决问题,但“com.android.support:appcompat-v7:28.0.0”仍然带有红色下划线。

最佳答案

使用 Gradle View 插件 http://plugins.jetbrains.com/plugin/7150-gradle-view ,我确定问题是 play-services-location:16.0.0 依赖于 com.android.support:support-media-compat:26.1.0。这里描述了我发现的一种消除警告的技术:https://docs.gradle.org/current/userguide/managing_transitive_dependencies.html

这导致我将其添加到我的 gradle 文件中:

implementation("com.android.support:appcompat-v7:28.0.0") {
        force = true
    }

关于java - Build Gradle 依赖项中的库版本 28 和 26.1 不兼容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54575479/

相关文章:

java - 如何使 jtextfield 文本在标签进入时消失(Netbeans)

Android参数传递方法

python - GAE 上的 Flask - 连接到 Google API - 无法使用 JSON 文件

mysql - Google API 对 Google Cloud 上的 MySQL 代理的身份验证范围不足

java - 未创建 Lagom cassandra readside 表

java - 使 Web 服务架构验证将空标签视为缺失

android - 如何在 android 中使用 yelp 分享评论

Android:从抽屉导航更改 ActionBar 中的标题

google-api - OAuth2.0 token 奇怪的行为(无效凭证 401)

java - JSP - 何时使用指令以及何时使用 jsp 标签?