【发布时间】:2017-07-14 04:47:16
【问题描述】:
我在安装 Android Studio 2.3.3 后创建了一个新项目,然后由于以下三个错误,Gradle 构建失败:
错误:无法解决:junit:junit:4.12
打开文件
在项目结构对话框中显示
错误:无法解决:org.hamcrest:hamcrest-library:1.3
打开文件
在项目结构对话框中显示
错误:无法解决:org.hamcrest:hamcrest-integration:1.3
打开文件
在项目结构对话框中显示
我尝试查看类似的问题及其答案,但它们对我不起作用。 我尝试删除 gradle.build 中的 testCompile 行,并尝试在 gradle.build 文件中添加 url maven "{ url 'http://repo1.maven.org/maven2' }",我检查了防火墙并下载了 junit.jar,但没有任何效果.
编辑:
build.gradle(模块)
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "com.example.tasneem.sunshine"
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
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:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
}
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.3'
// 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
}
【问题讨论】:
-
我已经在上面的问题中说过,我已经尝试过类似问题的答案,但没有奏效。
-
请您添加您的 gradle 吗??
标签: java android android-studio