无法解决:错误:(23,17)junit:junit:4.12在android studio 1.4中 [英] Failed to resolve : Error:(23, 17) junit:junit:4.12 in android studio 1.4
问题描述
我正在使用Android Studio 1.4,每次创建新项目时都会发生同样的错误
I am using Android Studio 1.4 and every time I create a new project same error happen
Error:(23, 17)"Failed to resolve: junit:junit:4.12".
我读过上一篇关于同一问题的帖子
错误:(23,17)无法解决:junit:junit:4.12
I read previous post about same problem
Error:(23, 17) Failed to resolve: junit:junit:4.12
并完成了所有给定的答案但是尽管添加了URL(' http://repo1.maven.org/maven2 和 http:// jcenter .bintray.com / ')缺少存储库错误仍然存在
and done all the the given answer but despite adding URL ('http://repo1.maven.org/maven2' and 'http://jcenter.bintray.com/') for missing repository the error remains
这是我最新的build.gradle代码
here is my latest build.gradle code
apply plugin: 'com.android.application'
android {
compileSdkVersion 14
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.example.myapplication"
minSdkVersion 14
targetSdkVersion 14
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:22.+'
}
推荐答案
如果要将它们添加到buildscript中,则会出现错误。
If you are adding them to buildscript you will get an error.
这是buildscript存储库和依赖项的存储库之间的区别。 buildscript用于gradle构建依赖项。
It is a difference between the buildscript repository and the repositories for the dependencies. The buildscript is used for gradle build dependencies.
您需要将以下内容添加到build.gradle文件中,它应该可以正常工作。
You will need to add the following to your build.gradle file and it should work fine.
repositories {
maven { url 'http://repo1.maven.org/maven2' }
jcenter { url "http://jcenter.bintray.com/" }
}
以下应该有效:
apply plugin: 'com.android.application'
repositories {
maven { url 'http://repo1.maven.org/maven2' }
jcenter { url "http://jcenter.bintray.com/" }
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.example.application"
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.1.1'
compile 'com.android.support:design:23.1.1'
}
这篇关于无法解决:错误:(23,17)junit:junit:4.12在android studio 1.4中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!