2017-05-02 105 views

回答

1

您的build.gradle中没有列出作为依赖项的tools.jar。

这就是我为本地解决方法所做的工作,它对于运行/测试非常适用。请注意,如果您释放工件,则不会包含依赖项。

repositories { 
    flatDir dirs: System.getenv("JAVA_HOME") + "/lib/" 
} 

dependencies { 
    compile ":tools" 
} 

请确保您的JAVA_HOME环境变量设置正确。另一种选择是directly load the classes,但这有点棘手。

+0

谢谢!但是现在我又得到另外一个错误:“在org.gradle.api.interna[email protected]6bbe50c9”上找不到方法compile()来获取参数[:tools]。有什么我做错了吗? –

+0

@RayoVerweij你很可能把它放在错误的地方。将这两个块放在* module * build.gradle文件的根级别。或者,您可以尝试将它们放入您的根项目build.gradle中的buildscript块中 - 这是您将用“classpath”替换“compile”的位置,它将起作用。我不知道你的项目配置,所以我不能告诉你哪一个是正确的做法。最有可能的是它将成为buildscript中的类路径,但我只是在猜测。 –