android - 混合版本会导致运行时崩溃。帮忙找个理由

标签 android build.gradle android-support-library

我所有的依赖项都从版本 27 开始,但是构建任务仍然以异常结束:

Error: All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 27.1.1, 25.4.0. Examples include com.android.support:animated-vector-drawable:27.1.1 and com.android.support:cardview-v7:25.4.0 [GradleCompatible]

我知道我可以添加

  lintOptions {
      abortOnError false
  }

它会解决我的问题,但我想找出原因。

这是我的 build.gradle 文件:

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "my.company.app"
        minSdkVersion 19
        targetSdkVersion 27
        multiDexEnabled true
        versionCode 1
        versionName "0.10.8"
        vectorDrawables.useSupportLibrary = true
    }

    testOptions {
        unitTests.returnDefaultValues = true
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

            buildConfigField("String", "ENV_URL_PREFIX", "\"https://\"")
            buildConfigField("String", "ENVIRONMENT", "\"release\"")
        }

        staging {
            initWith debug

            buildConfigField("String", "ENV_URL_PREFIX", "\"https://staging.\"")
            buildConfigField("String", "ENVIRONMENT", "\"staging\"")
        }

        debug {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

            buildConfigField("String", "ENV_URL_PREFIX", "\"https://dev.\"")
            buildConfigField("String", "ENVIRONMENT", "\"dev\"")
        }
    }

    flavorDimensions "app"
    productFlavors {
        _Live {
            dimension "app"
            buildConfigField("String", "TYPE", "\"live\"")
        }
        _Test {
            dimension "app"
            buildConfigField("String", "TYPE", "\"test\"")
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    packagingOptions {
        exclude 'lib/x86_64/darwin/libscrypt.dylib'
        exclude 'lib/x86_64/freebsd/libscrypt.so'
        exclude 'lib/x86_64/linux/libscrypt.so'
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    implementation 'com.android.support:gridlayout-v7:27.1.1'
    implementation 'com.android.support:design:27.1.1'

    implementation 'com.squareup.retrofit2:retrofit:2.4.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
    implementation 'com.squareup.okhttp3:logging-interceptor:3.9.1'

    implementation 'com.jakewharton.threetenabp:threetenabp:1.1.0'
    implementation 'me.dm7.barcodescanner:zxing:1.8.4'
    implementation 'com.crowdfire.cfalertdialog:cfalertdialog:1.1.0'

    implementation 'com.google.firebase:firebase-core:16.0.1'
    implementation 'com.google.firebase:firebase-messaging:17.1.0'
    implementation 'com.google.android.gms:play-services-location:15.0.1'
    implementation 'com.google.android.gms:play-services-places:15.0.1'
    implementation 'com.google.android.gms:play-services-maps:15.0.1'
    implementation 'com.google.zxing:zxing-parent:3.3.3'
    implementation 'com.google.zxing:core:3.3.2'
    implementation 'com.google.guava:guava:22.0'

    implementation project(':mobile_api') // a module compiled with java plugin

    testImplementation 'junit:junit:4.12'
    testImplementation 'org.mockito:mockito-core:1.10.19'
}

我的想法是某些依赖项通过 25.4.0 版传输 com.android.support 库。 如有任何建议,我将不胜感激。 提前致谢!

最佳答案

您正在使用这个库“com.crowdfire.cfalertdialog:cfalertdialog:1.1.0”, 它又使用 dependency 'com.android.support:cardview-v7:25.4.0' 也许这就是冲突的原因。

关于android - 混合版本会导致运行时崩溃。帮忙找个理由,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51598153/

相关文章:

gradle - 无法使用 Gradle 在 Artifactory 上部署 Artifactory

android - FragmentTransation setCustomAnimations 不起作用

android - fragment 已添加。支持库

Android sdk 管理器我没有 Android 支持库

Android API 24。在包 'minimalSize' 中找不到属性 'android' 的资源标识符

Android 依赖在编译和运行时有不同的版本

android - getItemViewType() - 如何返回一个 int 值

Docker - 当应用程序尚未在本地构建时复制失败?

Android 首选项 Activity - R 无法解析为变量

android - RecyclerView 在使用 Runnable 从 Handler 使用 notifyItemChanged 时崩溃 [IllegalArgumentException]