【问题标题】:Mixing android dependency versions error message in build.gradle file, however can't find the dependencies that are different在 build.gradle 文件中混合 android 依赖版本错误消息,但是找不到不同的依赖项
【发布时间】:2019-04-02 02:32:21
【问题描述】:

我在 build.gradle 文件中收到以下错误消息:

所有 com.android.support 库必须使用完全相同的版本规范(混合版本可能导致运行时崩溃)。找到版本 28.0.0、25.2.0。示例包括 com.android.support:animated-vector-drawable:28.0.0 和 com.android.support:support-media-compat:25.2.0 less... (Ctrl+F1) 有一些库或工具和库的组合是不兼容的,或者可能导致错误。一种这样的不兼容性是使用不是最新版本的 Android 支持库版本(或者特别是低于您的 targetSdkVersion 的版本)进行编译。

下面是我的 build.gradle 文件的当前状态。但是,我看不到对上述错误消息中提到的不同版本的依赖项的任何明确引用。

 apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    buildToolsVersion "28.0.3"
    defaultConfig {
        applicationId "com.parse.ideanetwork"
        minSdkVersion 15
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        versionCode 5
        vectorDrawables.useSupportLibrary = true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:28'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.android.support:design:28.0.0'
    compile 'com.google.android.gms:play-services-ads:11.0.0'
    compile "com.github.parse-community.Parse-SDK-Android:parse:1.18.5"
}

非常感谢任何帮助。谢谢。

【问题讨论】:

    标签: android gradle


    【解决方案1】:

    用最新版本显式声明最旧版本依赖似乎可行。我不认为这是更好的解决方案(也许它根本不是一个解决方案),但它忽略了警告。 这就是我正在做的事情,直到现在没有任何问题。

    【讨论】:

      【解决方案2】:

      使用这个,它会修复依赖版本不兼容的问题。

      configurations.all {
      resolutionStrategy.eachDependency { DependencyResolveDetails details ->
          def requested = details.requested
          if (requested.group == 'com.android.support') {
              // Skip multidex because it follows a different versioning pattern.
              if (!requested.name.startsWith("multidex")) {
                  details.useVersion '28.0.0'
              }
          }
      }
      

      }

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-11-04
        • 1970-01-01
        • 2021-01-21
        • 2015-12-31
        • 2018-01-12
        • 2018-10-25
        相关资源
        最近更新 更多