[英]Gradle error “Java plugin is not compatible with android plugins”
I am trying to run my testng tests through gradle on Android studio. 我正在尝试通过gradle在Android Studio上运行testng测试。 I have source code and tests placed in the gradle file using unitTest gradle feature.
我使用unitTest gradle功能将源代码和测试放置在gradle文件中。 So to use the test task i have to apply java plugin but android studio is giving me an error saying "Java plugin is not compatible with android plugins".
因此,要使用测试任务,我必须应用Java插件,但是android studio给我一个错误,提示“ Java插件与android插件不兼容”。 I know android and java plugins are not compatible with each other, but is there any solution for it?
我知道android和java插件彼此不兼容,但是有什么解决方案吗? This is my build.gradle looks like
这是我的build.gradle看起来像
apply plugin: 'com.android.application'
apply plugin: 'java'
dependencies {
// Android Support Library
compile 'com.android.support:support-v4:21.0.3'
androidTestCompile 'org.testng:testng:6.8.7'
androidTestCompile 'dom4j:dom4j:1.6.1'
androidTestCompile 'org.seleniumhq.selenium:selenium-server:2.44.0'
androidTestCompile 'jaxen:jaxen:1.1.6'
androidTestCompile 'io.appium:java-client:2.2.0'
}
test {
useTestNG()
//options.suites("src/androidTest/res/groups.xml")
}
As I said in the comments you don't need the Java plugin for testing; 正如我在评论中所说,您不需要Java插件即可进行测试; Android Studio already has built-in support for testing (as of 1.1).
Android Studio已经内置了对测试的支持(从1.1版本开始)。 So I suggest you taking a look at the Android Studio testing support which you can find here .
因此,我建议您看看可在此处找到的Android Studio测试支持。 It is described very nicely how to install and use (with screenshots).
很好地描述了如何安装和使用(带有屏幕截图)。
通过将androidTestCompile更改为testCompile可以工作
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.