gpt4 book ai didi

java - Android Studio 3.0.1(错误 :The 'java' plugin has been applied, 但与 Android 插件不兼容。)

转载 作者:太空狗 更新时间:2023-10-29 15:25:20 25 4
gpt4 key购买 nike

我最近将我的 android studio 更新到 3.0.1 版本,但我的 gradle 应用程序编译遇到了问题。尝试在 android studio 3.0.1 上构建我的 gradle 时出现此错误错误:“java”插件已应用,但它与 Android 插件不兼容。

我已经将我的 Java 开发工具包更新到最新版本

请帮助我,我是新手。下面是我的构建脚本。我已经将我的 Java 开发工具包更新到最新版本

 apply plugin: 'com.android.application'
apply plugin: 'kotlin'

buildscript {
repositories {
google() // Gradle 4.0+////////
maven { url "https://maven.google.com" } // Gradle < 4.0
}

dependencies {
classpath "com.android.tools.build:gradle:3.0.1"
}
}
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.android.happybirthday"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}


dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.0.0-beta1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:0.5'
androidTestImplementation 'com.android.support.test.espresso:espresso-
core:2.2.2'
compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"
}
buildscript {
ext.kotlin_version = '1.2.0'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
repositories {
mavenCentral()
}
compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}

最佳答案

试试这个构建脚本:

//Your root Gradle file
buildscript {
ext.kotlin_version = '1.2.21'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

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

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



// Your application Gradle file
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.android.happybirthday"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

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

testOptions {
unitTests.returnDefaultValues = true
}

compileKotlin {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

kotlinOptions {
jvmTarget = "1.8"
apiVersion = "1.2"
languageVersion = "1.2"
}
}
}
}


dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.0.0-beta1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:0.5'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:2.2.2'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
}

关于java - Android Studio 3.0.1(错误 :The 'java' plugin has been applied, 但与 Android 插件不兼容。),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48718739/

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