3
我在項目中使用谷歌的volley
lib。我將它作爲模塊添加,但是在編譯期間會出現以下錯誤。如何修復抽排測試編譯
這裏是目錄結構:
我嘗試添加
// testing
testCompile 'org.robolectric:robolectric:2.4'
testCompile 'junit:junit:4.+'
到應用程序的build.gradle
,但這並沒有幫助。
所以顯而易見的問題是如何使它工作?
UPDATE:
排球的build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0+'
// testing
testCompile 'org.robolectric:robolectric:2.4'
testCompile 'junit:junit:4.+'
}
}
apply plugin: 'com.android.library'
android {
compileSdkVersion 19
buildToolsVersion = '21.1.0'
}
apply from: 'rules.gradle'
應用的build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "19.1.0"
defaultConfig {
applicationId "com.example.vjdhama.project"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile project(":volley")
}
錯誤:
/home/vjdhama/Documents/Coding/Android/project/volley/build.gradle
Error:Error:line (18)Gradle DSL method not found: 'testCompile()'
Possible causes:<ul><li>The project 'project' may be using a version of Gradle that does not contain the method.
<a href="openGradleSettings">Gradle settings</a></li><li>The build file may be missing a Gradle plugin.
<a href="apply.gradle.plugin">Apply Gradle plugin</a></li>
是必需的依賴於排球,而不是應用程序模塊。你可以分享排球構建Gradle或者排球的位置 – 2015-04-03 18:16:57
我更新了問題。我也嘗試使用'androidtestcompile'建議在[這裏](http://stackoverflow.com/questions/25252637/gradle-build-script-error-occurs-when-i-attempt-to-use-testcompile-in-依賴),但它也沒有工作。 – vjdhama 2015-04-04 10:03:33
您將依賴關係添加到錯誤的地方。正確的文件,但應爲構建腳本 – 2015-04-04 10:31:20