java - Gradle 同步失败:“java”插件已应用,但与 Android 插件不兼容。(8 秒 991 毫秒)
问题描述
当我更新 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'
}
推荐阅读
- arrays - 计算一段时间内满足多个条件的不同客户 ID
- django - ajax django登录系统不工作,它返回用户为无
- python - 使用 for 循环添加两个数组
- python - python threading Event : why do we need clear()
- javascript - 如何限制幻灯片的大小(JS)
- google-apps-script - How to create address fields in Google Contacts using Google App Script
- python - How do I manipulate text submitted in a Django form?
- mysql - Repeatable read regarding select * with order by and limit
- ssas - Changing color in a measure in SSAS
- php - 您的包名无效 - Composer 2.0