我正在使用Android Studio 2.1.2并且它提供错误“错误:(29,17)无法解决:junit:junit:4.12”任何第三方库的类似错误。我尝试从项目设置中删除并添加junit库,但仍然给出相同的错误。我不确定这个代理是否有问题?我已经检查了来自Studio的maven链接的连接,它显示成功。以下是我的 build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.0"
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
defaultConfig {
applicationId "com.example.administrator.myapplication"
minSdkVersion 17
targetSdkVersion 24
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:24.0.0'
}
项目级别build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
repositories {
jcenter()
mavenCentral()
}
allprojects {
repositories {
jcenter()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
如果我错过了什么以及如何解决这个问题,请告诉我。
答案 0 :(得分:0)
经过大量努力,我能够解决这个问题。问题在于代理设置,我在gradle.properties文件中添加了以下行,并且gradle已成功同步并已解决依赖关系
systemProp.http.proxyHost=x.x.x.x
systemProp.https.proxyPort=xxxx
systemProp.https.proxyHost=x.x.x.x
systemProp.http.proxyPort=xxxx