0

I had a problem to run android-studios build gradle, so I tested many solution but unfortunately I couldn't solve my problem: Now i uninstall my old Android studio and Android-sdk , then I download android studio 1.5.1 that contains default SDK . I install them and I create an empty project , But it take 30 minutes to build project, I will add dialog window that shown in this period of time .

Finally project created with this error :

Error:(23, 17) Failed to resolve: junit:junit:4.12

Could any one help me ,please ? enter image description here

build.gradle file content:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "com.armangar.app.fortest"
        minSdkVersion 23
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
}

top build.gradle file content:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

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

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
Community
  • 1
  • 1
Mojtaba
  • 382
  • 1
  • 3
  • 19

3 Answers3

0

testCompile is the configuration for unit tests (located in src/test) and androidTestCompile is used for the test api (located in src/androidTest).

The main distinction between the two is that test runs in a regular Java JVM, and androidTest tests run on an Android device (or an emulator).

So, use

testCompile 'junit:junit:4.12'

instead of

androidTestCompile 'junit:junit:4.12'

source: http://tools.android.com/tech-docs/unit-testing-support

Matias Elorriaga
  • 8,880
  • 5
  • 40
  • 58
0

I think you have SSL problem. Try by replacing

jcenter { url 'http://jcenter.bintray.com' }

with

jcenter()

in both repository blocks in build.gradle file and try to build gradle again.

Brijesh Chopda
  • 195
  • 2
  • 11
0

I change jcenter() to mavenCentral() in build.gradle . So my problem solved

EDIT: This issue was related to my proxy . So I could not download from jcenter(). If you have a problem same this one, please check your Internet proxy .

Mojtaba
  • 382
  • 1
  • 3
  • 19