java Android studio v2.2.2 error(27,17) 无法解析junit:junit4.12
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/40396765/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Android studio v2.2.2 error(27,17) failed to resolve junit:junit4.12
提问by Edgell95
I have searched everywhere for this answer and tried multiple ways to fix this but as I'm new to this IDE I need a little help.
我到处搜索这个答案,并尝试了多种方法来解决这个问题,但由于我是这个 IDE 的新手,我需要一些帮助。
All I have done is created an empty project in android studio and before I make changes to the files I cant build and keep coming up with 7 errors in my message gradle sync.
我所做的只是在 android studio 中创建了一个空项目,在我对无法构建的文件进行更改之前,我的消息 gradle 同步中不断出现 7 个错误。
Errors:
错误:
- (27,17) Failed to resolve: junit:junit:4.12
- Failed to resolve: javax.inject:javax.inject:1
- Failed to resolve: javax.annotation:javax.annotation-api:1.2
- Failed to resolve: com.google.code.findbugs:jsr305:2.0.1
- Failed to resolve: org.hamcrest:hamcrest-library:1.3
- Failed to resolve: org.hamcrest:hamcrest-integration:1.3
- Failed to resolve: com.squareup:javawriter:2.1.1
- (27,17) 无法解析:junit:junit:4.12
- 无法解析:javax.inject:javax.inject:1
- 无法解析:javax.annotation:javax.annotation-api:1.2
- 无法解析:com.google.code.findbugs:jsr305:2.0.1
- 无法解析:org.hamcrest:hamcrest-library:1.3
- 无法解析:org.hamcrest:hamcrest-integration:1.3
- 无法解析:com.squareup:javawriter:2.1.1
This is my project called 'myApplication'
这是我的项目,名为“myApplication”
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And this is my build gradle module:app
这是我的构建 gradle 模块:app
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.3"
defaultConfig {
applicationId "test.app.stannah.com.uk"
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
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:24.2.1'
testCompile 'junit:junit:4.12'
}
Can someone please tell me what to do to these errors?
有人可以告诉我如何处理这些错误吗?
Regards
问候
回答by Manoj Perumarath
Remove the unwanted libraries from the build.gradle
,
从删除不需要的库build.gradle
,
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
testCompile 'junit:junit:4.12'
and also
并且
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
回答by kevto
Add mavenCentral()
to your repositories under jcenter()
JCenter doesn't have those dependencies that you require.
mavenCentral()
在jcenter()
JCenter下添加到您的存储库没有您需要的那些依赖项。
Edit: Also couldn't resolve the dependencies because of the proxy filtering traffic from and to maven.
编辑:也无法解决依赖关系,因为代理过滤了来自 Maven 的流量。
回答by Badre
just remove :
只需删除:
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' })
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' })
回答by rakesh rajput
configure proxy then you can able to download
配置代理然后你就可以下载了
javax.inject:javax.inject:1
javax.annotation:javax.annotation-api:1.2
com.google.code.findbugs:jsr305:2.0.1
org.hamcrest:hamcrest-library:1.3
org.hamcrest:hamcrest-integration:1.3
com.squareup:javawriter:2.1.1
回答by Praveen Attigeri
Don't remove the libraries that is not the way to do. This issue due to your internet connection. Set proxy connection in your gradle.properties file
不要删除不合适的库。此问题是由于您的互联网连接造成的。在 gradle.properties 文件中设置代理连接
systemProp.http.proxyHost=hosturl
org.gradle.jvmargs=-Xmx1536m
systemProp.http.proxyPort=portnumber
systemProp.http.proxyUser=username
systemProp.http.proxyPassword=password
systemProp.https.proxyHost=hosturl
systemProp.https.proxyPort=portnumber
systemProp.https.proxyUser=username
systemProp.https.proxyPassword=password