【发布时间】:2016-10-13 19:45:52
【问题描述】:
我刚刚在我的工作计算机上安装了 Android Studios,并创建了一个新的空白项目。但是,我收到以下错误。
无法解决:junit:junit:4.12
从上一次被问到这个问题时,我尝试了许多解决方案,但似乎没有一个有效。我尝试注释掉整行 compile files('libs/junit-4.12.jar')。我尝试将 jar 文件从 Android studio lib 文件夹复制粘贴到我的项目 lib 文件夹并将其添加为库。最重要的是,gradle 总是需要 10 多分钟才能构建。所以我想尝试的任何解决方案都需要一段时间。请帮忙。
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.3"
defaultConfig {
applicationId "com.example.mabbasi.myapplication"
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(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:24.2.1'
testCompile 'junit:junit:4.12'
compile files('libs/junit-4.12.jar')
}
build.bradle(项目)
// 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.2.1'
// 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
}
【问题讨论】:
-
请添加全局 build.gradle 文件(这是特定于应用程序的)
-
对不起@MatiasElorriaga,我不太明白。你能告诉我更详细的吗?
-
你的项目中应该有两个 build.gradle 文件。请添加另一个(一个已经发布:P)
-
完成!检查编辑。很抱歉@MatiasElorriaga
标签: android android-gradle-plugin junit4