Android: Unable to resolve dependency for ':[email p

时间:2021-10-21 18:18:31

我按照ExoPlayer的github指引添加

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

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

后来在*找到了解决方案,来源为:https://*.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即可