Android: Unable to resolve dependency for ':app@debugUnitTest/compileClasspath':

我按照ExoPlayer的github指引添加

implementation 'com.google.android.exoplayer:exoplayer:2.X.X'

发现根本run不起来,并报错如题

后来在stackoverflow找到了解决方案,来源为:https://stackoverflow.com/questions/46949622/android-studio-3-0-unable-to-resolve-dependency-for-appdexoptions-compileclas
出现问题的原因在于app含有buildtype但是library的依赖没有,所以我们需要添加一个matching configuration fallbacks

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

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

        }
    }

在dexOptions下增加callback即可

你可能感兴趣的:(Android: Unable to resolve dependency for ':app@debugUnitTest/compileClasspath':)