报错信息
Error:(27, 17) Failed to resolve: junit:junit:4.12
<a href="openFile:H:/MyApplication/app/build.gradle">Show in File</a><br><a href="open.dependency.in.project.structure">Show in Project Structure dialog</a>
Error:(26, 13) Failed to resolve: com.android.support:appcompat-v7:34.+
<a href="install.m2.repo">Install Repository and sync project</a><br><a href="openFile:H:/MyApplication/app/build.gradle">Show in File</a><br><a href="open.dependency.in.project.structure">Show in Project Structure dialog</a>
Error:Failed to resolve: javax.inject:javax.inject:1
<a href="openFile:H:/MyApplication/app/build.gradle">Open File</a><br><a href="open.dependency.in.project.structure">Show in Project Structure dialog</a>
Error:Failed to resolve: com.google.code.findbugs:jsr305:2.0.1
<a href="openFile:H:/MyApplication/app/build.gradle">Open File</a><br><a href="open.dependency.in.project.structure">Show in Project Structure dialog</a>
Error:Failed to resolve: org.hamcrest:hamcrest-library:1.3
<a href="openFile:H:/MyApplication/app/build.gradle">Open File</a><br><a href="open.dependency.in.project.structure">Show in Project Structure dialog</a>
Error:Failed to resolve: com.squareup:javawriter:2.1.1
<a href="openFile:H:/MyApplication/app/build.gradle">Open File</a><br><a href="open.dependency.in.project.structure">Show in Project Structure dialog</a>
解决办法
1.删除(注释)依赖信息||添加maven
发现还有部分报错。
2.打开File-Setting,查看我们SDK工具的版本
我这里是26.1.1
我们使用34版的SDK进行了编译,并且使用了34版即以上版本的V7包。但是工具的SDK版本只有26,所以编译版本和工具的SDK版本不匹配导致出现了这个问题。
3.将我们build.gradle文件中的版本依赖全部修改为26即以下,重新同步点击Try Again.
如果删除或者注释的依赖库我们是需要的,可以引用maven。
maven {
url 'https://maven.aliyun.com/repository/public/'
}
问题解决
总结
当我们在Andorid Studio重新导入新的工程或者新建工程的时候,我们要注意gradle版本以及共工程编译gradle版本是否兼容。相关库的引用是否合理,版本是否兼容等问题。