Gradle显示依赖错误

时间:2018-11-06 07:08:23

标签: android android-studio kotlin android-design-library

当我将约束布局版本更改为alpha-2时,它显示错误。以前我使用的是旧版本,没有显示任何错误:

旧版本可以正常运行,没有错误:

dependencies {
  implementation fileTree(dir: 'libs', include: ['*.jar'])
  implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
  implementation 'com.android.support:appcompat-v7:28.0.0'
  implementation 'com.android.support.constraint:constraint-layout:2.0.0-alpha2' 
}

有错误的新版本:

dependencies {
  implementation fileTree(dir: 'libs', include: ['*.jar'])
  implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
  implementation 'com.android.support:appcompat-v7:28.0.0'
  implementation 'com.android.support.constraint:constraint-layout:2.0.0-alpha2' 
}

等级:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
  compileSdkVersion 28
  defaultConfig {
     applicationId "com.m3tech.transitionspractice"
     minSdkVersion 21
     targetSdkVersion 28
     versionCode 1
     versionName "1.0"
     testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
  }
  buildTypes {
      release {
        minifyEnabled false
           proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
      }
  } 
}

dependencies {
     implementation fileTree(dir: 'libs', include: ['*.jar'])
     implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
     implementation 'com.android.support:appcompat-v7:28.0.0'
     implementation 'com.android.support.constraint:constraint-layout:2.0.0-alpha2' 
 }

错误:

enter image description here

2 个答案:

答案 0 :(得分:1)

我使用此代码修复了该问题。放入您的应用模块build.gradle

configurations.all {
    resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion "28.0.0"
            }
        }
    }
}

答案 1 :(得分:0)

更改

implementation 'com.android.support.constraint:constraint-layout:2.0.0-alpha2'

implementation 'com.android.support.constraint:constraint-layout:1.1.3'