Error in Android Studio, Failed to resolve junit: junit: 4.12 [closed]

0

I have an error when importing a project on Android to another computer. I have been working on this project for almost a month and it has not given me problems, but I have been forced to change my computer. After installing Android Studio on the new computer and importing the project, I get the following error messages:

The code of my file app/build.gradle is the following:

apply plugin: 'com.android.application'
android {
    compileSdkVersion 26
    buildToolsVersion "26.0.1"
    defaultConfig {
        applicationId "com.tigestion.guillermo.agendagui"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
testCompile 'junit:junit:4.12'
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.volley:volley:1.0.0'
}

And the code of build.gradle general:

buildscript {
repositories {
    jcenter()
    mavenCentral()
}
dependencies {
    classpath 'com.android.tools.build:gradle:2.3.3'
}
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

I have watched tutorials on YouTube and in this forum, in Spanish and in English, and no solution is of any use. It does not help me to comment on the testCompile line, it does not help to add:

repositories {
    maven { url 'http://repo1.maven.org/maven2' }
    jcenter { url "http://jcenter.bintray.com/" }
}

It does not help me to download a junit 4-12.jar file and manually add it to the project structure by deleting the previous junit and I do not know what to do anymore because basically those are all the solutions I found.

Both Android configurations (both the old computer and the new one) are the ones that the installation leaves by default. The operating system in the previous one was Windows 7 and in the new Windows 8.

Please help.

    
asked by G. Corporales 17.10.2017 в 09:53
source

2 answers

0

I have it set up like this:

a). build.gradle (the one that is outside the folders)

buildscript { 
    repositories { 
                    jcenter() 
                    mavenCentral() 
                 }

In that same file:

allprojects { 
     repositories { 
                    jcenter() 
                  } 
}

b). build.gradle within the folder app

I put only the relative to JUnit ... the rest do not change it.

apply plugin: 'com.android.application'

android {


    defaultConfig {
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

}

dependencies {
    testCompile 'junit:junit:4.12'
}
    
answered by 17.10.2017 / 12:07
source
0

Have you tried going to Build-> clean build and when you finish processing Build-> Rebuild?

Sometimes Android Studio crashes for any temporary file created or for different unexplained issues ...

    
answered by 17.10.2017 в 13:56