首页 > 解决方案 > 如何解决“:app@releaseUnitTest/compileClasspath”的依赖关系

问题描述

无法解析 ':app@releaseUnitTest/compileClasspath' 的依赖关系:找不到任何与 com.android.support:appcompat-v7:29.+ 匹配的版本。

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    defaultConfig {
        applicationId "com.example.usman.testing"
        minSdkVersion 15
        targetSdkVersion 29
        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(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:29.+'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    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'
}

标签: androidandroid-studioandroid-support-libraryandroid-appcompat

解决方案


您的应用包含库依赖项不包含的构建类型

android {
  buildTypes {
      release {
          ...
      }
      dexOptions {
          ...
        // release & debug is in project animators
        matchingFallbacks = ['release', 'debug']
      }
      debug {
          ...
      }
    }
}

设置匹配的配置回退显然是解决这个问题的正确方法。


推荐阅读