IT이야기/Android

안드로이드 스튜디오에서 새프로젝트 생성시 빌드가 안될때

FelixShin 2017. 6. 2. 15:24
반응형

사용 툴 : Android studio 2.3.2

 OS : Mac, 그러나 Windows도 같은 상황이 발생할 수 있음


1. 문제 :

Failed to resolve:junit:junit:4.1

새프로젝트 생성시 위와같은 에러가 나며 빌드가 되지 않음



2.해결방안 :  build.gradle의 repositories를 바꿔야함


1) build.gradle  파일 내부(변경전)

// 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:2.3.2'

// 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
}

2) 변경후

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

buildscript {
repositories {
//jcenter()
jcenter { url 'http://jcenter.bintray.com' }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.2'

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

allprojects {
repositories {
jcenter { url 'http://jcenter.bintray.com' }
//jcenter()
}
}

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


문제 원인 : 회사 사내망 개발시 proxy문제 때문에 jcenter의 경로를 구체적으로 적어주어야 한다.


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