M.ds M.ds - 1 year ago 262
Android Question

Fixing A Run Time Error for An Android Program

when I was trying to run a simple program , I got an error related to Gradle :

Error:A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration':app:_debugUnitTestCompile'.
> Could not resolve junit:junit:4.12.
Required by:
> Could not resolve junit:junit:4.12.
> Could not get resource 'https://jcenter.bintray.com/junit/junit/4.12/junit-4.12.pom'.
> Could not GET 'htps://jcenter.bintray.com/junit/junit/4.12/junit-4.12.pom'.
> Connection to htps://jcenter.bintray.com refused .

I don't know how can I fix it , please help .( I am currently using the android studio version 2.1.2 )
my module build-gradle includes these codes:

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.3"

defaultConfig {
applicationId "com.example.n5110.myapplication"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

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

Answer Source

The problematic part with your gralde.build is this line:

testCompile 'junit:junit:4.12'

This is a unit testing library. If you are just starting and are probably not gonna write testcases for your project then, you can resolve the issue by simply deleting the line. If however you essentially need that library then refer here.