我在android studio 2.3.1中开始了一个新项目。它开始显示以下错误。
E:\My_Fun_Projects\Android\MyAndroidApps\MyApplication1\app\build.gradle
Error:Error:line (38)Failed to resolve: junit:junit:4.12
<a href="openFile:E:/My_Fun_Projects/Android/MyAndroidApps/MyApplication1/app/build.gradle">Show in File</a><br><a href="open.dependency.in.project.structure">Show in Project Structure dialog</a>
Error:Error:Failed to resolve: javax.inject:javax.inject:1
<a href="openFile:E:/My_Fun_Projects/Android/MyAndroidApps/MyApplication1/app/build.gradle">Open File</a><br><a href="open.dependency.in.project.structure">Show in Project Structure dialog</a>
Error:Error:Failed to resolve: javax.annotation:javax.annotation-api:1.2
<a href="openFile:E:/My_Fun_Projects/Android/MyAndroidApps/MyApplication1/app/build.gradle">Open File</a><br><a href="open.dependency.in.project.structure">Show in Project Structure dialog</a>
Error:Error:Failed to resolve: com.google.code.findbugs:jsr305:2.0.1
<a href="openFile:E:/My_Fun_Projects/Android/MyAndroidApps/MyApplication1/app/build.gradle">Open File</a><br><a href="open.dependency.in.project.structure">Show in Project Structure dialog</a>
Error:Error:Failed to resolve: org.hamcrest:hamcrest-library:1.3
<a href="openFile:E:/My_Fun_Projects/Android/MyAndroidApps/MyApplication1/app/build.gradle">Open File</a><br><a href="open.dependency.in.project.structure">Show in Project Structure dialog</a>
Error:Error:Failed to resolve: org.hamcrest:hamcrest-integration:1.3
<a href="openFile:E:/My_Fun_Projects/Android/MyAndroidApps/MyApplication1/app/build.gradle">Open File</a><br><a href="open.dependency.in.project.structure">Show in Project Structure dialog</a>
Error:Error:Failed to resolve: com.squareup:javawriter:2.1.1
<a href="openFile:E:/My_Fun_Projects/Android/MyAndroidApps/MyApplication1/app/build.gradle">Open File</a><br><a href="open.dependency.in.project.structure">Show in Project Structure dialog</a>
答案 0 :(得分:1)
只需从testCompile 'junit:junit:x.xx'
文件中删除build.gradle
,它就可以正常使用。
如果你想要junit,那么你可能需要添加存储库url。因为android studio可能没有junit库。
android{
repositories {
jcenter()
maven { url "https://www.jitpack.io" }
mavenCentral()
}
答案 1 :(得分:1)
确保您已连接到互联网。
如果你住在像伊朗这样的国家,你应该使用VPN并重新同步你的项目。
答案 2 :(得分:0)
通过删除依赖项区域(位于页面底部)的应用程序级别gradle文件中的testCompile 'junit:junit:4.12'
来实现它的工作