Ajay Bhargav
Ajay Bhargav

Reputation: 17

Android studio 2.3.1: Gradle project sync failed

I started a new project in android studio 2.3.1. It started showing the following errors.

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>

Upvotes: 0

Views: 3995

Answers (3)

Mehran Abi.
Mehran Abi.

Reputation: 73

Make sure you are connected to internet.

If you live in a country like Iran you should use VPN and resync your project.

Upvotes: 1

Erastus Uso
Erastus Uso

Reputation: 1

it worked by removing thetestCompile 'junit:junit:4.12' on the app level gradle file in the dependencies area (down at the bottom of the page)

Upvotes: 0

Christlin Panneer
Christlin Panneer

Reputation: 1647

Just remove the testCompile 'junit:junit:x.xx' from build.gradle file, it should work fine.

If you want junit, then you may need to add the repository url. Because android studio might not have the junit library.

android{
    repositories {
    jcenter()
    maven { url "https://www.jitpack.io" }
    mavenCentral()
}

Upvotes: 1

Related Questions