2015-06-09 146 views
1

我導入了一個使用roboelectric的項目,但似乎build.gradle文件是錯誤的,我不知道如何解決它。我檢查我的gradle有2.2.1,但我還沒有想通了這個問題尚未...我的日誌:Gradle項目同步失敗 - 未找到Gradle DSL方法:android()

Executing tasks: [:] 

Configuration on demand is an incubating feature. 

FAILURE: Build failed with an exception. 

* Where: 
Build file '/Users/dev1/Desktop/DESARROLLO/AndroidTestExample-master/Starter/build.gradle' line: 3 

* What went wrong: 
A problem occurred evaluating root project 'Starter'. 
> Could not find method android() for arguments [[email protected]] on root project 'Starter'. 

* Try: 
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. 

BUILD FAILED 

Total time: 0.153 secs 

而且的build.gradle:

buildscript { 
repositories { 
    mavenCentral() 
} 
dependencies { 
    classpath 'com.android.tools.build:gradle:1.2.3' 
} 
} 
apply plugin: 'android' 
sourceSets { 
    unitTest { 
     java.srcDir file('src/test/java') 
     resources.srcDir file('src/test/res') 
     } 
} 

configurations { 
unitTestCompile.extendsFrom runtime 
unitTestRuntime.extendsFrom unitTestCompile 
} 

dependencies { 
repositories { 
    mavenCentral() 
} 
    unitTestCompile files("$project.buildDir/classes/release") 
unitTestCompile 'junit:junit:4.10' 
unitTestCompile 'org.robolectric:robolectric:2.1.+' 
unitTestCompile 'com.google.android:android:4.0.1.2' 
} 
task unitTest(type:Test, dependsOn: assemble) { 
    testClassesDir = project.sourceSets.unitTest.output.classesDir 
    classpath = project.sourceSets.unitTest.runtimeClasspath 
} 
check.dependsOn unitTest 

android { 
compileSdkVersion 19 
buildToolsVersion "19.0.0" 

}

回答

0

嘗試將您的buildToolsVersion設置爲21.1.1而不是19.0.0,這可能是您的proplem的原因。

嘗試更新android studio,如果它不是。

希望這會有所幫助。

+0

謝謝,但它仍然說:無法找到方法android()的參數[build_43aogzm0wm94eieabvjhdztqe $ _run_closure1 @ 19a6fd40]在根項目'Starter'上。 – Billyjoker

相關問題