【发布时间】:2017-05-29 07:02:32
【问题描述】:
我在安装 Android Studio 并创建了一个简单的应用后立即收到错误消息。
后续步骤:
- 全新下载并安装 Android Studio。
- 创建了一个新项目。
加载项目时,gradle失败并出现错误:
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'
}
项目 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
}
我在这里搜索了可能的解决方案。
【问题讨论】:
-
分享
gradle文件 -
您的链接似乎有效删除带有
apply plugin: 'java'的行 -
@Pztar 共享 gradle 文件。
-
@cricket_007 我的 gradle 文件中没有那行。
-
@ajc,如果不行,试试
Rebuild,然后试试File->Invalidate Caches/Restart->Invalidate and Restart
标签: java android android-studio android-gradle-plugin