简体   繁体   English

Gradle错误“ Java插件与android插件不兼容”

[英]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.

相关问题 Gradle 构建:Java 插件与 Android 插件不兼容 - Gradle build: Java plugin not compatible with Android plugins “java”插件与 Android 插件不兼容 - 'java' plugin is not compatible with the Android plugins 解释错误:'java' 插件已被应用,但与 Android 插件不兼容 - Explain Error:The 'java' plugin has been applied, but it is not compatible with the Android plugins Gradle sync失败:已经应用了'java'插件,但它与Android插件不兼容。 (8 s 991 ms) - Gradle sync failed: The 'java' plugin has been applied, but it is not compatible with the Android plugins. (8 s 991 ms) Android Studio 3.0.1(错误:已应用'java'插件,但它与Android插件不兼容。) - Android Studio 3.0.1( Error:The 'java' plugin has been applied, but it is not compatible with the Android plugins.) Android studio ERROR:已经应用了java插件,但它与Android插件不兼容 - Android studio ERROR: The java plugin has been applied, but it is not compatible with the Android plugins 安卓编译错误; 已应用Java插件,与android不兼容 - Android compile error; Java plugin has been applied, not compatible with android Gradle 预编译脚本插件可以使用 java-gradle-plugin 吗? - Can Gradle precompiled scripts plugins use java-gradle-plugin? Android gradle 插件需要 java 11 - Android gradle plugin requires java 11 Gradle构建错误:无法应用插件[class'org.gradle.api.plugins.JavaPlugin - Gradle Build Error: Failed to appy plugin[class 'org.gradle.api.plugins.JavaPlugin
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM