gpt4 book ai didi

java - Gradle 同步失败 : The 'java' plugin has been applied, 但它与 Android 插件不兼容。 (8 秒 991 毫秒)

转载 作者:行者123 更新时间:2023-12-02 05:59:53 24 4
gpt4 key购买 nike

当我更新 Android Studio 新版本时,我的意思是 5.1.1 gredle 给出一些 Gradle 同步失败的错误:“java”插件已应用,但它与 Android 插件不兼容。 (8 秒 991 毫秒)。请帮助我。

android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.beyza.myapplication"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets { main { res.srcDirs = ['src/main/res', 'src/main/res/raw'] } }
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
apply plugin: 'application'
apply plugin: 'announce'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

}

顶级构建文件,您可以在其中添加所有子项目/模块通用的配置选项。

我不知道如何解决这个问题。

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

buildscript {


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


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

}

}

allprojects {
repositories {
google()
jcenter()
}
}

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

最佳答案

从依赖项中删除“应用插件”并将其设置在 gradle 顶部,如下所示:

此外,如果您有“应用插件:'java'”,则将其删除。

apply plugin: 'application'
apply plugin: 'announce'

android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.beyza.myapplication"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets { main { res.srcDirs = ['src/main/res', 'src/main/res/raw'] } }
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

}

关于java - Gradle 同步失败 : The 'java' plugin has been applied, 但它与 Android 插件不兼容。 (8 秒 991 毫秒),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55983844/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com