Error:Unable to resolve dependency for ':app@sourceSets/compileClasspath': Could not resolve proj...

今天在依赖别的工程库的时候发现报了下面这个错:
Error:Unable to resolve dependency for ':app@sourceSets/compileClasspath': Could not resolve project :weiyi.

造成这个错误的原因是app下build.gradle里面的buildtypes配置和module下build.gradle中的
buildtypes配置不一样。依赖的工程里都要加

下面是app下build.gradle里面的buildtypes配置


Error:Unable to resolve dependency for ':app@sourceSets/compileClasspath': Could not resolve proj..._第1张图片
image.png

包含release{} sourceSets{}两部分

再看依赖工程里module下的build.gradle里面的buildtypes配置


Error:Unable to resolve dependency for ':app@sourceSets/compileClasspath': Could not resolve proj..._第2张图片
image.png

缺少了sourceSets{}部分,module里面必须要也app中有同样的配置,写成空的也行,如下:

Error:Unable to resolve dependency for ':app@sourceSets/compileClasspath': Could not resolve proj..._第3张图片
image.png

还有其他依赖的库,都要加上

Error:Unable to resolve dependency for ':app@sourceSets/compileClasspath': Could not resolve proj..._第4张图片
image.png

这几个库都要加上就能正常编译运行了

Error:Unable to resolve dependency for ':app@sourceSets/compileClasspath': Could not resolve proj..._第5张图片
image.png

Error:Unable to resolve dependency for ':app@sourceSets/compileClasspath': Could not resolve proj..._第6张图片
image.png

你可能感兴趣的:(Error:Unable to resolve dependency for ':app@sourceSets/compileClasspath': Could not resolve proj...)