【发布时间】:2014-08-11 21:22:04
【问题描述】:
我正在使用 Android Studio,在我的应用程序的依赖项中,我尝试添加一个 testCompile 依赖项,如下所示:http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
当我同步我的文件时,我收到错误:
我不明白发生了什么,我根文件夹中的 gradle 构建文件设置为 classpath 'com.android.tools.build:gradle:0.12.+',这是最新版本。为什么它不能识别 testCompile?我不想将测试依赖项部署到生产环境...任何帮助将不胜感激。
编辑:这是项目构建文件
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
这里是 src 构建文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 17
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.example.edu.myApp"
minSdkVersion 14
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug{
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/scribe-1.3.5.jar')
compile files('libs/json_simple-1.1.jar')
compile 'com.google.android.gms:play-services:5.0.77'
// Can't be higher than 19 if we want to support smaller android versions
compile 'com.android.support:appcompat-v7:19.+'
// You must install or update the Support Repository through the SDK manager to use this dependency.
compile 'com.android.support:support-v4:19.+'
// This Mockito includes all dependancies (great for us)
testCompile "org.mockito:mockito-core:1.9.+"
testCompile 'org.hamcrest:hamcrest-all:1.3'
testCompile 'org.objenesis:objenesis:1.2'
}
【问题讨论】:
-
请将您的构建文件添加到您的问题中。
-
我没有在其中看到 testCompile 语句。
-
只是因为我删除了它,我对最后3个依赖项进行了测试编译,我会编辑它。
标签: gradle android-studio android-gradle-plugin