【问题标题】:Android studio ERROR: The java plugin has been applied, but it is not compatible with the Android pluginsAndroid studio ERROR: The java plugin has been applied, but it is not compatible with the Android plugins
【发布时间】:2019-05-05 12:49:14
【问题描述】:

自从我更新 Android Studio 后,我的应用程序无法正常运行,因为它在更新之前可以正常运行。

我已经尝试删除缓存文件夹

代码如下:

       apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId 'daxilgames.footballplayersquiz2019'
        minSdkVersion 17
        targetSdkVersion 28
        apply plugin: 'jdepend'
        apply plugin: 'antlr'
        apply plugin: 'announce'
        apply plugin: 'com.android.application'
        versionCode 3
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
            debuggable false
        }
    }
    productFlavors {
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.google.android.gms:play-services-ads:11.0.4'
    testImplementation 'junit:junit:4.12'
}

【问题讨论】:

  • 会发生什么?错误?描述问题。
  • 当我运行我的应用程序时,出现这个错误:ERROR: The 'java' plugin has been applied, but it is not compatible with the Android plugins .
  • 看看这个:stackoverflow.com/questions/26861011/…。我在您的代码块中没有看到apply plugin: 'java',但也许您只是没有将它包含在您的代码清单中?
  • 谢谢奥利奥特,但我的代码中有 apply plugin: 'com.android.application',不需要应用你的插件,正如你在链接的问题中看到的那样。顺便说一句,我已经尝试过了,但它给了我同样的错误
  • 相反:java 插件与com.android.application 不兼容。但是如果你没有那个apply plugin: 'java' - 也许它被隐式应用或以其他方式应用到你的程序中?

标签: java android gradle


【解决方案1】:

ANTLR 插件 antlr 扩展了 Java 插件 java(并隐式应用它),并且您不能在同一模块中同时应用 com.android.applicationjava 插件,因此会出现错误

'java'插件已应用,但与安卓插件不兼容。

尝试删除apply plugin: 'antlr'这一行。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-12-27
    • 1970-01-01
    • 2019-09-05
    • 1970-01-01
    • 1970-01-01
    • 2018-12-12
    • 1970-01-01
    • 2020-05-28
    相关资源
    最近更新 更多