Kotlin插件更新后Gradle项目同步失败



在我更新到kotlin的最新插件后,我在我的项目中遇到了这个构建错误

Caused by: org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException: Could not find method 1.8() for arguments [1.8] on object of type org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptionsImpl.

我的成绩是

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.71'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

def nav_version = "2.1.0"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"        // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
flatDir {
dirs 'libs'
}
maven { url 'https://jitpack.io' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

其他文件是

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'androidx.navigation.safeargs.kotlin'
android {
compileSdkVersion 28
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8" JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId "com.example.barrechat191"
minSdkVersion 24
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
dataBinding {
enabled = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
// To inline the bytecode built with JVM target 1.8 into
// bytecode that is being built with JVM target 1.6. (e.g. navArgs)
}
dependencies {
def lifecycle_version = "2.1.0"
def nav_version = "2.1.0"
def paging_version = "2.1.1"
implementation 'com.luckycatlabs:SunriseSunsetCalculator:1.2'
//Page Lib implementation and RecyclerView
implementation "androidx.paging:paging-runtime-ktx:$paging_version"
// For Kotlin use paging-runtime-ktx
implementation 'com.android.support:recyclerview-v7:28.0.0'
//Implement Glide
implementation 'com.github.bumptech.glide:glide:4.11.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.navigation:navigation-fragment-ktx:2.2.1'
implementation 'androidx.navigation:navigation-ui-ktx:2.2.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
//Implement constraintLayout
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
// Kotlin
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
// ViewModel and LiveData
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
// alternatively - just ViewModel
implementation "androidx.lifecycle:lifecycle-viewmodel:$lifecycle_version"
// For Kotlin use lifecycle-viewmodel-ktx
// alternatively - just LiveData
implementation "androidx.lifecycle:lifecycle-livedata:$lifecycle_version"
// alternatively - Lifecycles only (no ViewModel or LiveData). Some UI
//     AndroidX libraries use this lightweight import for Lifecycle
implementation "androidx.lifecycle:lifecycle-runtime:$lifecycle_version"

implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.0'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.0'

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.2.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
//Kotlin Coroutine support for ViewModel
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.0-alpha01'
//Coroutine support for LiveData
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.0-alpha01'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.0-alpha01'
//Dependency Injection
api 'com.google.dagger:dagger:2.25.2'
annotationProcessor 'com.google.dagger:dagger-compiler:2.25.2'
//*******************************************
//*************  A   W   S ******************
//*******************************************
// Mobile Client for initializing the SDK
implementation('com.amazonaws:aws-android-sdk-mobile-client:@aar') { transitive = true }
// Cognito UserPools for SignIn
implementation 'com.android.support:support-v4:28.0'
implementation('com.amazonaws:aws-android-sdk-auth-userpools:@aar') { transitive = true }
// Sign in UI Library
implementation 'com.android.support:appcompat-v7:28.0'
implementation('com.amazonaws:aws-android-sdk-auth-ui:@aar') { transitive = true }

//******************************************
//************  GOOGLE MAPS ****************
//******************************************
implementation name: 'maps-sdk-3.0.0-beta', ext: 'aar'
implementation 'com.google.android.gms:play-services-basement:17.2.1'
implementation 'com.google.android.gms:play-services-base:17.2.1'
implementation 'com.google.android.gms:play-services-gcm:17.0.0'
implementation 'com.google.android.gms:play-services-location:17.0.0'

//******************************************
//**************** ROOM ********************
//******************************************
def room_version = "2.2.3"
implementation "androidx.room:room-runtime:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version"
// For Kotlin use kapt instead of annotationProcessor
// optional - Kotlin Extensions and Coroutines support for Room
implementation "androidx.room:room-ktx:$room_version"

implementation 'com.google.android.gms:play-services-maps:17.0.0'
/**
*
* TESTING ->
*
*/
testImplementation "androidx.room:room-testing:$room_version"
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test:rules:1.2.0'
implementation "com.github.drfonfon:android-kotlin-geohash:1.0"
}

不确定这里可能出了什么问题。在最近的升级之前一切都很好。关于如何解决这个问题,有什么想法吗?

我试着检查并确保所有内容都是同步的和正确的版本。但它仍然抛出相同的构建错误。

尝试使用

android {
...
kotlinOptions {
jvmTarget = '1.8'
}
...
}

看起来有点奇怪

jvm目标="1.8">JavaVersion.VERSION_1_8

最新更新