加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

“java”插件与Android插件不兼容

发布时间:2020-12-14 05:23:10 所属栏目:Java 来源:网络整理
导读:我安装了 Android studio并创建了一个简单的应用程序后,我收到了错误. 步骤如下: 新鲜下载安装了Android studio. 创建一个新项目. 当项目加载时,毕业生失败,错误: Error:The 'java' plugin has been applied,but it is not compatible with the Android pl
我安装了 Android studio并创建了一个简单的应用程序后,我收到了错误.

步骤如下:

>新鲜下载&安装了Android studio.
>创建一个新项目.

当项目加载时,毕业生失败,错误:

Error:The 'java' plugin has been applied,but it is not compatible with the Android plugins.

模块Gradle文件:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "info.ankitjc.happybirthday"
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs',include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2',{
        exclude group: 'com.android.support',module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.1.0'
    testCompile 'junit:junit:4.12'
}

Project Gradle文件:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

我在这里寻找可能的解决方案.

> Android compile error; Java plugin has been applied,not compatible with android
> Gradle error “Java plugin is not compatible with android plugins”

后文件>无效缓存/重新启动

After File ></p> Invalidate Cache/Restart

解决方法

androidTestCompile可以抛出你这个错误
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2',{
            exclude group: 'com.android.support',module: 'support-annotations'
        })

将androidTestCompile更改为testCompile

两者之间的主要区别是测试源运行在常规Java JVM中,而AndroidTest源集测试则在Android设备(或仿真器)上运行.就像冲突一样!

如果它没有任何机会

删除testInstrumentationRunner“android.support.test.runner.AndroidJUnitRunner”

可能会发生错误,因为它不允许您在同一版本中与两个测试运行程序一起运行测试.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读