Gradle错误“Java插件与android插件不兼容” [英] Gradle error "Java plugin is not compatible with android plugins"

查看:603
本文介绍了Gradle错误“Java插件与android插件不兼容”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过Android Studio上的gradle来运行我的testng测试。我使用unitTest gradle功能将源代码和测试放置在gradle文件中。所以要使用测试任务,我必须应用java插件,但android studio会给我一个错误,指出Java插件与android插件不兼容。我知道android和java插件不兼容,但是有没有解决方案?这是我的build.gradle,看起来像

  apply plugin:'com.android.application'
apply plugin:' java'
dependencies {
// Android支持库
compile'c​​om.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'
}

测试{

useTestNG()
/ /options.suites(\"src/androidTest/res/groups.xml)

}



I am trying to run my testng tests through gradle on Android studio. I have source code and tests placed in the gradle file using unitTest gradle feature. 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". I know android and java plugins are not compatible with each other, but is there any solution for it? This is my build.gradle looks like

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")

}

解决方案

It works by changing the androidTestCompile to testCompile

这篇关于Gradle错误“Java插件与android插件不兼容”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆